mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2025-04-27 23:40:36 +05:30
Make all YT tests in MOCK mode use mock data
This commit is contained in:
parent
cf5df3fcff
commit
177262485a
@ -16,7 +16,6 @@ import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
|
|||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.schabi.newpipe.downloader.DownloaderFactory;
|
import org.schabi.newpipe.downloader.DownloaderFactory;
|
||||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
|
||||||
import org.schabi.newpipe.extractor.ExtractorAsserts;
|
import org.schabi.newpipe.extractor.ExtractorAsserts;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||||
@ -25,7 +24,6 @@ import org.schabi.newpipe.extractor.channel.tabs.ChannelTabs;
|
|||||||
import org.schabi.newpipe.extractor.exceptions.AccountTerminatedException;
|
import org.schabi.newpipe.extractor.exceptions.AccountTerminatedException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
|
||||||
import org.schabi.newpipe.extractor.linkhandler.ReadyChannelTabListLinkHandler;
|
import org.schabi.newpipe.extractor.linkhandler.ReadyChannelTabListLinkHandler;
|
||||||
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest;
|
||||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelExtractor;
|
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelExtractor;
|
||||||
@ -70,7 +68,7 @@ public class YoutubeChannelExtractorTest {
|
|||||||
final ChannelExtractor extractor =
|
final ChannelExtractor extractor =
|
||||||
YouTube.getChannelExtractor("https://www.youtube.com/channel/UCTGjY2I-ZUGnwVoWAGRd7XQ");
|
YouTube.getChannelExtractor("https://www.youtube.com/channel/UCTGjY2I-ZUGnwVoWAGRd7XQ");
|
||||||
|
|
||||||
AccountTerminatedException ex =
|
final AccountTerminatedException ex =
|
||||||
assertThrows(AccountTerminatedException.class, extractor::fetchPage);
|
assertThrows(AccountTerminatedException.class, extractor::fetchPage);
|
||||||
assertEquals(AccountTerminatedException.Reason.VIOLATION, ex.getReason());
|
assertEquals(AccountTerminatedException.Reason.VIOLATION, ex.getReason());
|
||||||
}
|
}
|
||||||
@ -81,7 +79,7 @@ public class YoutubeChannelExtractorTest {
|
|||||||
final ChannelExtractor extractor =
|
final ChannelExtractor extractor =
|
||||||
YouTube.getChannelExtractor("https://www.youtube.com/channel/UC0AuOxCr9TZ0TtEgL1zpIgA");
|
YouTube.getChannelExtractor("https://www.youtube.com/channel/UC0AuOxCr9TZ0TtEgL1zpIgA");
|
||||||
|
|
||||||
AccountTerminatedException ex =
|
final AccountTerminatedException ex =
|
||||||
assertThrows(AccountTerminatedException.class, extractor::fetchPage);
|
assertThrows(AccountTerminatedException.class, extractor::fetchPage);
|
||||||
assertEquals(AccountTerminatedException.Reason.VIOLATION, ex.getReason());
|
assertEquals(AccountTerminatedException.Reason.VIOLATION, ex.getReason());
|
||||||
}
|
}
|
||||||
@ -93,7 +91,7 @@ public class YoutubeChannelExtractorTest {
|
|||||||
final ChannelExtractor extractor =
|
final ChannelExtractor extractor =
|
||||||
YouTube.getChannelExtractor("https://www.youtube.com/channel/UCPWXIOPK-9myzek6jHR5yrg");
|
YouTube.getChannelExtractor("https://www.youtube.com/channel/UCPWXIOPK-9myzek6jHR5yrg");
|
||||||
|
|
||||||
AccountTerminatedException ex =
|
final AccountTerminatedException ex =
|
||||||
assertThrows(AccountTerminatedException.class, extractor::fetchPage);
|
assertThrows(AccountTerminatedException.class, extractor::fetchPage);
|
||||||
assertEquals(AccountTerminatedException.Reason.VIOLATION, ex.getReason());
|
assertEquals(AccountTerminatedException.Reason.VIOLATION, ex.getReason());
|
||||||
}
|
}
|
||||||
@ -105,7 +103,7 @@ public class YoutubeChannelExtractorTest {
|
|||||||
final ChannelExtractor extractor =
|
final ChannelExtractor extractor =
|
||||||
YouTube.getChannelExtractor("https://youtube.com/channel/UCB1o7_gbFp2PLsamWxFenBg");
|
YouTube.getChannelExtractor("https://youtube.com/channel/UCB1o7_gbFp2PLsamWxFenBg");
|
||||||
|
|
||||||
AccountTerminatedException ex =
|
final AccountTerminatedException ex =
|
||||||
assertThrows(AccountTerminatedException.class, extractor::fetchPage);
|
assertThrows(AccountTerminatedException.class, extractor::fetchPage);
|
||||||
assertEquals(AccountTerminatedException.Reason.VIOLATION, ex.getReason());
|
assertEquals(AccountTerminatedException.Reason.VIOLATION, ex.getReason());
|
||||||
}
|
}
|
||||||
@ -118,7 +116,7 @@ public class YoutubeChannelExtractorTest {
|
|||||||
final ChannelExtractor extractor =
|
final ChannelExtractor extractor =
|
||||||
YouTube.getChannelExtractor("https://www.youtube.com/channel/UCoaO4U_p7G7AwalqSbGCZOA");
|
YouTube.getChannelExtractor("https://www.youtube.com/channel/UCoaO4U_p7G7AwalqSbGCZOA");
|
||||||
|
|
||||||
AccountTerminatedException ex =
|
final AccountTerminatedException ex =
|
||||||
assertThrows(AccountTerminatedException.class, extractor::fetchPage);
|
assertThrows(AccountTerminatedException.class, extractor::fetchPage);
|
||||||
assertEquals(AccountTerminatedException.Reason.VIOLATION, ex.getReason());
|
assertEquals(AccountTerminatedException.Reason.VIOLATION, ex.getReason());
|
||||||
}
|
}
|
||||||
@ -130,7 +128,7 @@ public class YoutubeChannelExtractorTest {
|
|||||||
final ChannelExtractor extractor =
|
final ChannelExtractor extractor =
|
||||||
YouTube.getChannelExtractor("https://www.youtube.com/channel/UCI4i4RgFT5ilfMpna4Z_Y8w");
|
YouTube.getChannelExtractor("https://www.youtube.com/channel/UCI4i4RgFT5ilfMpna4Z_Y8w");
|
||||||
|
|
||||||
AccountTerminatedException ex =
|
final AccountTerminatedException ex =
|
||||||
assertThrows(AccountTerminatedException.class, extractor::fetchPage);
|
assertThrows(AccountTerminatedException.class, extractor::fetchPage);
|
||||||
assertEquals(AccountTerminatedException.Reason.VIOLATION, ex.getReason());
|
assertEquals(AccountTerminatedException.Reason.VIOLATION, ex.getReason());
|
||||||
}
|
}
|
||||||
@ -169,26 +167,31 @@ public class YoutubeChannelExtractorTest {
|
|||||||
// Extractor
|
// Extractor
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testServiceId() {
|
public void testServiceId() {
|
||||||
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testName() throws Exception {
|
public void testName() throws Exception {
|
||||||
assertEquals("Gronkh", extractor.getName());
|
assertEquals("Gronkh", extractor.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testId() throws Exception {
|
public void testId() throws Exception {
|
||||||
assertEquals("UCYJ61XIK64sp6ZFFS8sctxw", extractor.getId());
|
assertEquals("UCYJ61XIK64sp6ZFFS8sctxw", extractor.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testUrl() throws ParsingException {
|
public void testUrl() throws ParsingException {
|
||||||
assertEquals("https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw", extractor.getUrl());
|
assertEquals("https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw", extractor.getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testOriginalUrl() throws ParsingException {
|
public void testOriginalUrl() throws ParsingException {
|
||||||
assertEquals("http://www.youtube.com/@Gronkh", extractor.getOriginalUrl());
|
assertEquals("http://www.youtube.com/@Gronkh", extractor.getOriginalUrl());
|
||||||
@ -198,26 +201,31 @@ public class YoutubeChannelExtractorTest {
|
|||||||
// ChannelExtractor
|
// ChannelExtractor
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testDescription() throws Exception {
|
public void testDescription() throws Exception {
|
||||||
assertContains("Ungebremster Spieltrieb seit 1896.", extractor.getDescription());
|
assertContains("Ungebremster Spieltrieb seit 1896.", extractor.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testAvatars() throws Exception {
|
public void testAvatars() throws Exception {
|
||||||
YoutubeTestsUtils.testImages(extractor.getAvatars());
|
YoutubeTestsUtils.testImages(extractor.getAvatars());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testBanners() throws Exception {
|
public void testBanners() throws Exception {
|
||||||
YoutubeTestsUtils.testImages(extractor.getBanners());
|
YoutubeTestsUtils.testImages(extractor.getBanners());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testFeedUrl() throws Exception {
|
public void testFeedUrl() throws Exception {
|
||||||
assertEquals("https://www.youtube.com/feeds/videos.xml?channel_id=UCYJ61XIK64sp6ZFFS8sctxw", extractor.getFeedUrl());
|
assertEquals("https://www.youtube.com/feeds/videos.xml?channel_id=UCYJ61XIK64sp6ZFFS8sctxw", extractor.getFeedUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testSubscriberCount() throws Exception {
|
public void testSubscriberCount() throws Exception {
|
||||||
ExtractorAsserts.assertGreaterOrEqual(4_900_000, extractor.getSubscriberCount());
|
ExtractorAsserts.assertGreaterOrEqual(4_900_000, extractor.getSubscriberCount());
|
||||||
@ -262,26 +270,31 @@ public class YoutubeChannelExtractorTest {
|
|||||||
// Extractor
|
// Extractor
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testServiceId() {
|
public void testServiceId() {
|
||||||
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testName() throws Exception {
|
public void testName() throws Exception {
|
||||||
assertEquals("Vsauce", extractor.getName());
|
assertEquals("Vsauce", extractor.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testId() throws Exception {
|
public void testId() throws Exception {
|
||||||
assertEquals("UC6nSFpj9HTCZ5t-N3Rm3-HA", extractor.getId());
|
assertEquals("UC6nSFpj9HTCZ5t-N3Rm3-HA", extractor.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testUrl() throws ParsingException {
|
public void testUrl() throws ParsingException {
|
||||||
assertEquals("https://www.youtube.com/channel/UC6nSFpj9HTCZ5t-N3Rm3-HA", extractor.getUrl());
|
assertEquals("https://www.youtube.com/channel/UC6nSFpj9HTCZ5t-N3Rm3-HA", extractor.getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testOriginalUrl() throws ParsingException {
|
public void testOriginalUrl() throws ParsingException {
|
||||||
assertEquals("https://www.youtube.com/user/Vsauce", extractor.getOriginalUrl());
|
assertEquals("https://www.youtube.com/user/Vsauce", extractor.getOriginalUrl());
|
||||||
@ -291,31 +304,37 @@ public class YoutubeChannelExtractorTest {
|
|||||||
// ChannelExtractor
|
// ChannelExtractor
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testDescription() throws Exception {
|
public void testDescription() throws Exception {
|
||||||
assertContains("Our World is Amazing", extractor.getDescription());
|
assertContains("Our World is Amazing", extractor.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testAvatars() throws Exception {
|
public void testAvatars() throws Exception {
|
||||||
YoutubeTestsUtils.testImages(extractor.getAvatars());
|
YoutubeTestsUtils.testImages(extractor.getAvatars());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testBanners() throws Exception {
|
public void testBanners() throws Exception {
|
||||||
YoutubeTestsUtils.testImages(extractor.getBanners());
|
YoutubeTestsUtils.testImages(extractor.getBanners());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testFeedUrl() throws Exception {
|
public void testFeedUrl() throws Exception {
|
||||||
assertEquals("https://www.youtube.com/feeds/videos.xml?channel_id=UC6nSFpj9HTCZ5t-N3Rm3-HA", extractor.getFeedUrl());
|
assertEquals("https://www.youtube.com/feeds/videos.xml?channel_id=UC6nSFpj9HTCZ5t-N3Rm3-HA", extractor.getFeedUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testSubscriberCount() throws Exception {
|
public void testSubscriberCount() throws Exception {
|
||||||
ExtractorAsserts.assertGreaterOrEqual(17_000_000, extractor.getSubscriberCount());
|
ExtractorAsserts.assertGreaterOrEqual(17_000_000, extractor.getSubscriberCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testVerified() throws Exception {
|
public void testVerified() throws Exception {
|
||||||
assertTrue(extractor.isVerified());
|
assertTrue(extractor.isVerified());
|
||||||
@ -355,26 +374,31 @@ public class YoutubeChannelExtractorTest {
|
|||||||
// Extractor
|
// Extractor
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testServiceId() {
|
public void testServiceId() {
|
||||||
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testName() throws Exception {
|
public void testName() throws Exception {
|
||||||
assertTrue(extractor.getName().startsWith("Kurzgesagt"));
|
assertTrue(extractor.getName().startsWith("Kurzgesagt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testId() throws Exception {
|
public void testId() throws Exception {
|
||||||
assertEquals("UCsXVk37bltHxD1rDPwtNM8Q", extractor.getId());
|
assertEquals("UCsXVk37bltHxD1rDPwtNM8Q", extractor.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testUrl() throws ParsingException {
|
public void testUrl() throws ParsingException {
|
||||||
assertEquals("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q", extractor.getUrl());
|
assertEquals("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q", extractor.getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testOriginalUrl() throws ParsingException {
|
public void testOriginalUrl() throws ParsingException {
|
||||||
assertEquals("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q", extractor.getOriginalUrl());
|
assertEquals("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q", extractor.getOriginalUrl());
|
||||||
@ -384,6 +408,7 @@ public class YoutubeChannelExtractorTest {
|
|||||||
// ChannelExtractor
|
// ChannelExtractor
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testDescription() throws Exception {
|
public void testDescription() throws Exception {
|
||||||
ExtractorAsserts.assertContains("science", extractor.getDescription());
|
ExtractorAsserts.assertContains("science", extractor.getDescription());
|
||||||
@ -392,26 +417,31 @@ public class YoutubeChannelExtractorTest {
|
|||||||
//assertTrue(description, description.contains("Currently we make one animation video per month"));
|
//assertTrue(description, description.contains("Currently we make one animation video per month"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testAvatars() throws Exception {
|
public void testAvatars() throws Exception {
|
||||||
YoutubeTestsUtils.testImages(extractor.getAvatars());
|
YoutubeTestsUtils.testImages(extractor.getAvatars());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testBanners() throws Exception {
|
public void testBanners() throws Exception {
|
||||||
YoutubeTestsUtils.testImages(extractor.getBanners());
|
YoutubeTestsUtils.testImages(extractor.getBanners());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testFeedUrl() throws Exception {
|
public void testFeedUrl() throws Exception {
|
||||||
assertEquals("https://www.youtube.com/feeds/videos.xml?channel_id=UCsXVk37bltHxD1rDPwtNM8Q", extractor.getFeedUrl());
|
assertEquals("https://www.youtube.com/feeds/videos.xml?channel_id=UCsXVk37bltHxD1rDPwtNM8Q", extractor.getFeedUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testSubscriberCount() throws Exception {
|
public void testSubscriberCount() throws Exception {
|
||||||
ExtractorAsserts.assertGreaterOrEqual(17_000_000, extractor.getSubscriberCount());
|
ExtractorAsserts.assertGreaterOrEqual(17_000_000, extractor.getSubscriberCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testVerified() throws Exception {
|
public void testVerified() throws Exception {
|
||||||
assertTrue(extractor.isVerified());
|
assertTrue(extractor.isVerified());
|
||||||
@ -442,8 +472,8 @@ public class YoutubeChannelExtractorTest {
|
|||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
// Test is not deterministic, mocks can't be used
|
YoutubeTestsUtils.ensureStateless();
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "kurzgesagtAdditional"));
|
||||||
extractor = (YoutubeChannelExtractor) YouTube.getChannelExtractor(
|
extractor = (YoutubeChannelExtractor) YouTube.getChannelExtractor(
|
||||||
"https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q");
|
"https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
@ -478,26 +508,31 @@ public class YoutubeChannelExtractorTest {
|
|||||||
// Extractor
|
// Extractor
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testServiceId() {
|
public void testServiceId() {
|
||||||
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testName() throws Exception {
|
public void testName() throws Exception {
|
||||||
assertEquals("Captain Disillusion", extractor.getName());
|
assertEquals("Captain Disillusion", extractor.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testId() throws Exception {
|
public void testId() throws Exception {
|
||||||
assertEquals("UCEOXxzW2vU0P-0THehuIIeg", extractor.getId());
|
assertEquals("UCEOXxzW2vU0P-0THehuIIeg", extractor.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testUrl() throws ParsingException {
|
public void testUrl() throws ParsingException {
|
||||||
assertEquals("https://www.youtube.com/channel/UCEOXxzW2vU0P-0THehuIIeg", extractor.getUrl());
|
assertEquals("https://www.youtube.com/channel/UCEOXxzW2vU0P-0THehuIIeg", extractor.getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testOriginalUrl() throws ParsingException {
|
public void testOriginalUrl() throws ParsingException {
|
||||||
assertEquals("https://www.youtube.com/user/CaptainDisillusion/videos", extractor.getOriginalUrl());
|
assertEquals("https://www.youtube.com/user/CaptainDisillusion/videos", extractor.getOriginalUrl());
|
||||||
@ -507,31 +542,37 @@ public class YoutubeChannelExtractorTest {
|
|||||||
// ChannelExtractor
|
// ChannelExtractor
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testDescription() throws Exception {
|
public void testDescription() throws Exception {
|
||||||
assertContains("In a world where", extractor.getDescription());
|
assertContains("In a world where", extractor.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testAvatars() throws Exception {
|
public void testAvatars() throws Exception {
|
||||||
YoutubeTestsUtils.testImages(extractor.getAvatars());
|
YoutubeTestsUtils.testImages(extractor.getAvatars());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testBanners() throws Exception {
|
public void testBanners() throws Exception {
|
||||||
YoutubeTestsUtils.testImages(extractor.getBanners());
|
YoutubeTestsUtils.testImages(extractor.getBanners());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testFeedUrl() throws Exception {
|
public void testFeedUrl() throws Exception {
|
||||||
assertEquals("https://www.youtube.com/feeds/videos.xml?channel_id=UCEOXxzW2vU0P-0THehuIIeg", extractor.getFeedUrl());
|
assertEquals("https://www.youtube.com/feeds/videos.xml?channel_id=UCEOXxzW2vU0P-0THehuIIeg", extractor.getFeedUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testSubscriberCount() throws Exception {
|
public void testSubscriberCount() throws Exception {
|
||||||
ExtractorAsserts.assertGreaterOrEqual(2_000_000, extractor.getSubscriberCount());
|
ExtractorAsserts.assertGreaterOrEqual(2_000_000, extractor.getSubscriberCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testVerified() throws Exception {
|
public void testVerified() throws Exception {
|
||||||
assertTrue(extractor.isVerified());
|
assertTrue(extractor.isVerified());
|
||||||
@ -571,26 +612,31 @@ public class YoutubeChannelExtractorTest {
|
|||||||
// Extractor
|
// Extractor
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testServiceId() {
|
public void testServiceId() {
|
||||||
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testName() throws Exception {
|
public void testName() throws Exception {
|
||||||
assertEquals("random channel", extractor.getName());
|
assertEquals("random channel", extractor.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testId() throws Exception {
|
public void testId() throws Exception {
|
||||||
assertEquals("UCUaQMQS9lY5lit3vurpXQ6w", extractor.getId());
|
assertEquals("UCUaQMQS9lY5lit3vurpXQ6w", extractor.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testUrl() throws ParsingException {
|
public void testUrl() throws ParsingException {
|
||||||
assertEquals("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w", extractor.getUrl());
|
assertEquals("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w", extractor.getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testOriginalUrl() throws ParsingException {
|
public void testOriginalUrl() throws ParsingException {
|
||||||
assertEquals("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w", extractor.getOriginalUrl());
|
assertEquals("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w", extractor.getOriginalUrl());
|
||||||
@ -600,31 +646,37 @@ public class YoutubeChannelExtractorTest {
|
|||||||
// ChannelExtractor
|
// ChannelExtractor
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testDescription() throws Exception {
|
public void testDescription() throws Exception {
|
||||||
assertContains("Hey there iu will upoload a load of pranks onto this channel", extractor.getDescription());
|
assertContains("Hey there iu will upoload a load of pranks onto this channel", extractor.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testAvatars() throws Exception {
|
public void testAvatars() throws Exception {
|
||||||
YoutubeTestsUtils.testImages(extractor.getAvatars());
|
YoutubeTestsUtils.testImages(extractor.getAvatars());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testBanners() throws Exception {
|
public void testBanners() throws Exception {
|
||||||
YoutubeTestsUtils.testImages(extractor.getBanners());
|
YoutubeTestsUtils.testImages(extractor.getBanners());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testFeedUrl() throws Exception {
|
public void testFeedUrl() throws Exception {
|
||||||
assertEquals("https://www.youtube.com/feeds/videos.xml?channel_id=UCUaQMQS9lY5lit3vurpXQ6w", extractor.getFeedUrl());
|
assertEquals("https://www.youtube.com/feeds/videos.xml?channel_id=UCUaQMQS9lY5lit3vurpXQ6w", extractor.getFeedUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testSubscriberCount() throws Exception {
|
public void testSubscriberCount() throws Exception {
|
||||||
ExtractorAsserts.assertGreaterOrEqual(50, extractor.getSubscriberCount());
|
ExtractorAsserts.assertGreaterOrEqual(50, extractor.getSubscriberCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testVerified() throws Exception {
|
public void testVerified() throws Exception {
|
||||||
assertFalse(extractor.isVerified());
|
assertFalse(extractor.isVerified());
|
||||||
@ -662,26 +714,31 @@ public class YoutubeChannelExtractorTest {
|
|||||||
// Extractor
|
// Extractor
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testServiceId() {
|
public void testServiceId() {
|
||||||
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testName() throws Exception {
|
public void testName() throws Exception {
|
||||||
assertEquals("Sports", extractor.getName());
|
assertEquals("Sports", extractor.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testId() throws Exception {
|
public void testId() throws Exception {
|
||||||
assertEquals("UCEgdi0XIXXZ-qJOFPf4JSKw", extractor.getId());
|
assertEquals("UCEgdi0XIXXZ-qJOFPf4JSKw", extractor.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testUrl() throws ParsingException {
|
public void testUrl() throws ParsingException {
|
||||||
assertEquals("https://www.youtube.com/channel/UCEgdi0XIXXZ-qJOFPf4JSKw", extractor.getUrl());
|
assertEquals("https://www.youtube.com/channel/UCEgdi0XIXXZ-qJOFPf4JSKw", extractor.getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testOriginalUrl() throws ParsingException {
|
public void testOriginalUrl() throws ParsingException {
|
||||||
assertEquals("https://www.youtube.com/channel/UCEgdi0XIXXZ-qJOFPf4JSKw", extractor.getOriginalUrl());
|
assertEquals("https://www.youtube.com/channel/UCEgdi0XIXXZ-qJOFPf4JSKw", extractor.getOriginalUrl());
|
||||||
@ -697,27 +754,32 @@ public class YoutubeChannelExtractorTest {
|
|||||||
assertNull(extractor.getDescription());
|
assertNull(extractor.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testAvatars() throws Exception {
|
public void testAvatars() throws Exception {
|
||||||
YoutubeTestsUtils.testImages(extractor.getAvatars());
|
YoutubeTestsUtils.testImages(extractor.getAvatars());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testBanners() {
|
public void testBanners() {
|
||||||
// A CarouselHeaderRenderer doesn't contain a banner
|
// A CarouselHeaderRenderer doesn't contain a banner
|
||||||
assertEmpty(extractor.getBanners());
|
assertEmpty(extractor.getBanners());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testFeedUrl() throws Exception {
|
public void testFeedUrl() throws Exception {
|
||||||
assertEquals("https://www.youtube.com/feeds/videos.xml?channel_id=UCEgdi0XIXXZ-qJOFPf4JSKw", extractor.getFeedUrl());
|
assertEquals("https://www.youtube.com/feeds/videos.xml?channel_id=UCEgdi0XIXXZ-qJOFPf4JSKw", extractor.getFeedUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testSubscriberCount() throws Exception {
|
public void testSubscriberCount() throws Exception {
|
||||||
ExtractorAsserts.assertGreaterOrEqual(70_000_000, extractor.getSubscriberCount());
|
ExtractorAsserts.assertGreaterOrEqual(70_000_000, extractor.getSubscriberCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void testVerified() throws Exception {
|
public void testVerified() throws Exception {
|
||||||
assertTrue(extractor.isVerified());
|
assertTrue(extractor.isVerified());
|
||||||
|
@ -1,31 +1,5 @@
|
|||||||
package org.schabi.newpipe.extractor.services.youtube;
|
package org.schabi.newpipe.extractor.services.youtube;
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
|
||||||
import org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.CreationException;
|
|
||||||
import org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeOtfDashManifestCreator;
|
|
||||||
import org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeProgressiveDashManifestCreator;
|
|
||||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor;
|
|
||||||
import org.schabi.newpipe.extractor.stream.DeliveryMethod;
|
|
||||||
import org.schabi.newpipe.extractor.stream.Stream;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
import org.xml.sax.InputSource;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
import java.io.StringReader;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.IntStream;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertAll;
|
import static org.junit.jupiter.api.Assertions.assertAll;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
@ -50,6 +24,33 @@ import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators
|
|||||||
import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.SEGMENT_TIMELINE;
|
import static org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeDashManifestCreatorsUtils.SEGMENT_TIMELINE;
|
||||||
import static org.schabi.newpipe.extractor.utils.Utils.isBlank;
|
import static org.schabi.newpipe.extractor.utils.Utils.isBlank;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.schabi.newpipe.downloader.DownloaderFactory;
|
||||||
|
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
||||||
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
|
import org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.CreationException;
|
||||||
|
import org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeOtfDashManifestCreator;
|
||||||
|
import org.schabi.newpipe.extractor.services.youtube.dashmanifestcreators.YoutubeProgressiveDashManifestCreator;
|
||||||
|
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor;
|
||||||
|
import org.schabi.newpipe.extractor.stream.DeliveryMethod;
|
||||||
|
import org.schabi.newpipe.extractor.stream.Stream;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for YouTube DASH manifest creators.
|
* Test for YouTube DASH manifest creators.
|
||||||
*
|
*
|
||||||
@ -80,19 +81,22 @@ import static org.schabi.newpipe.extractor.utils.Utils.isBlank;
|
|||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
class YoutubeDashManifestCreatorsTest {
|
class YoutubeDashManifestCreatorsTest {
|
||||||
|
private static final String RESOURCE_PATH =
|
||||||
|
DownloaderFactory.RESOURCE_PATH + "services/youtube/extractor/dash_manifest";
|
||||||
|
|
||||||
// Setting a higher number may let Google video servers return 403s
|
// Setting a higher number may let Google video servers return 403s
|
||||||
private static final int MAX_STREAMS_TO_TEST_PER_METHOD = 3;
|
private static final int MAX_STREAMS_TO_TEST_PER_METHOD = 3;
|
||||||
private static final String url = "https://www.youtube.com/watch?v=DJ8GQUNUXGM";
|
private static final String URL = "https://www.youtube.com/watch?v=DJ8GQUNUXGM";
|
||||||
private static YoutubeStreamExtractor extractor;
|
private static YoutubeStreamExtractor extractor;
|
||||||
private static long videoLength;
|
private static long videoLength;
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
YoutubeParsingHelper.resetClientVersion();
|
YoutubeTestsUtils.ensureStateless();
|
||||||
YoutubeParsingHelper.setNumberGenerator(new Random(1));
|
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||||
|
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH));
|
||||||
|
|
||||||
extractor = (YoutubeStreamExtractor) YouTube.getStreamExtractor(url);
|
extractor = (YoutubeStreamExtractor) YouTube.getStreamExtractor(URL);
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
videoLength = extractor.getLength();
|
videoLength = extractor.getLength();
|
||||||
}
|
}
|
||||||
|
@ -4,40 +4,43 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||||||
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
import org.schabi.newpipe.downloader.DownloaderFactory;
|
||||||
import org.schabi.newpipe.extractor.ExtractorAsserts;
|
import org.schabi.newpipe.extractor.ExtractorAsserts;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class YoutubeJavaScriptExtractorTest {
|
class YoutubeJavaScriptExtractorTest {
|
||||||
|
private static final String RESOURCE_PATH =
|
||||||
|
DownloaderFactory.RESOURCE_PATH + "services/youtube/extractor/js_extractor";
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setup() throws IOException {
|
public void setup() throws IOException {
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
YoutubeTestsUtils.ensureStateless();
|
||||||
|
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExtractJavaScriptUrlIframe() throws ParsingException {
|
void testExtractJavaScriptUrlIframe() throws ParsingException {
|
||||||
assertTrue(YoutubeJavaScriptExtractor.extractJavaScriptUrlWithIframeResource()
|
assertTrue(YoutubeJavaScriptExtractor.extractJavaScriptUrlWithIframeResource()
|
||||||
.endsWith("base.js"));
|
.endsWith("base.js"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExtractJavaScriptUrlEmbed() throws ParsingException {
|
void testExtractJavaScriptUrlEmbed() throws ParsingException {
|
||||||
assertTrue(YoutubeJavaScriptExtractor.extractJavaScriptUrlWithEmbedWatchPage("d4IGg5dqeO8")
|
assertTrue(YoutubeJavaScriptExtractor.extractJavaScriptUrlWithEmbedWatchPage("d4IGg5dqeO8")
|
||||||
.endsWith("base.js"));
|
.endsWith("base.js"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExtractJavaScript__success() throws ParsingException {
|
void testExtractJavaScript__success() throws ParsingException {
|
||||||
String playerJsCode = YoutubeJavaScriptExtractor.extractJavaScriptPlayerCode("d4IGg5dqeO8");
|
final String playerJsCode = YoutubeJavaScriptExtractor.extractJavaScriptPlayerCode("d4IGg5dqeO8");
|
||||||
assertPlayerJsCode(playerJsCode);
|
assertPlayerJsCode(playerJsCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExtractJavaScript__invalidVideoId__success() throws ParsingException {
|
void testExtractJavaScript__invalidVideoId__success() throws ParsingException {
|
||||||
String playerJsCode = YoutubeJavaScriptExtractor.extractJavaScriptPlayerCode("not_a_video_id");
|
String playerJsCode = YoutubeJavaScriptExtractor.extractJavaScriptPlayerCode("not_a_video_id");
|
||||||
assertPlayerJsCode(playerJsCode);
|
assertPlayerJsCode(playerJsCode);
|
||||||
|
|
||||||
|
@ -1,24 +1,27 @@
|
|||||||
package org.schabi.newpipe.extractor.services.youtube;
|
package org.schabi.newpipe.extractor.services.youtube;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.CsvSource;
|
import org.junit.jupiter.params.provider.CsvSource;
|
||||||
import org.junit.jupiter.params.provider.ValueSource;
|
import org.junit.jupiter.params.provider.ValueSource;
|
||||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
import org.schabi.newpipe.downloader.DownloaderFactory;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
import javax.annotation.Nonnull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
class YoutubeSignaturesTest {
|
class YoutubeSignaturesTest {
|
||||||
|
private static final String RESOURCE_PATH =
|
||||||
|
DownloaderFactory.RESOURCE_PATH + "services/youtube/extractor/signatures";
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp() throws IOException {
|
void setUp() throws IOException {
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
|
||||||
YoutubeTestsUtils.ensureStateless();
|
YoutubeTestsUtils.ensureStateless();
|
||||||
|
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ValueSource(strings = {
|
@ValueSource(strings = {
|
||||||
|
@ -6,18 +6,20 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||||||
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
import org.schabi.newpipe.downloader.DownloaderFactory;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
class YoutubeThrottlingParameterDeobfuscationTest {
|
class YoutubeThrottlingParameterDeobfuscationTest {
|
||||||
|
private static final String RESOURCE_PATH =
|
||||||
|
DownloaderFactory.RESOURCE_PATH + "services/youtube/extractor/parameter_deobf";
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setup() throws IOException {
|
void setup() throws IOException {
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
|
||||||
YoutubeTestsUtils.ensureStateless();
|
YoutubeTestsUtils.ensureStateless();
|
||||||
|
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -4,27 +4,34 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
|||||||
import static java.util.Collections.singletonList;
|
import static java.util.Collections.singletonList;
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.schabi.newpipe.downloader.DownloaderTestImpl;
|
import org.schabi.newpipe.downloader.DownloaderFactory;
|
||||||
import org.schabi.newpipe.extractor.InfoItem;
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.search.SearchExtractor;
|
import org.schabi.newpipe.extractor.search.SearchExtractor;
|
||||||
import org.schabi.newpipe.extractor.services.DefaultSearchExtractorTest;
|
import org.schabi.newpipe.extractor.services.DefaultSearchExtractorTest;
|
||||||
|
import org.schabi.newpipe.extractor.services.youtube.YoutubeTestsUtils;
|
||||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory;
|
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory;
|
||||||
|
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
// Doesn't work with mocks. Makes request with different `dataToSend` I think
|
// Doesn't work with mocks. Makes request with different `dataToSend` I think
|
||||||
public class YoutubeMusicSearchExtractorTest {
|
public class YoutubeMusicSearchExtractorTest {
|
||||||
|
private static final String RESOURCE_PATH = DownloaderFactory.RESOURCE_PATH + "services/youtube/extractor/music_search/";
|
||||||
|
private static final String BASE_SEARCH_URL = "music.youtube.com/search?q=";
|
||||||
|
|
||||||
public static class MusicSongs extends DefaultSearchExtractorTest {
|
public static class MusicSongs extends DefaultSearchExtractorTest {
|
||||||
private static SearchExtractor extractor;
|
private static SearchExtractor extractor;
|
||||||
private static final String QUERY = "mocromaniac";
|
private static final String QUERY = "mocromaniac";
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
YoutubeTestsUtils.ensureStateless();
|
||||||
|
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "music_songs"));
|
||||||
|
|
||||||
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_SONGS), "");
|
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_SONGS), "");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
}
|
}
|
||||||
@ -33,8 +40,8 @@ public class YoutubeMusicSearchExtractorTest {
|
|||||||
@Override public StreamingService expectedService() { return YouTube; }
|
@Override public StreamingService expectedService() { return YouTube; }
|
||||||
@Override public String expectedName() { return QUERY; }
|
@Override public String expectedName() { return QUERY; }
|
||||||
@Override public String expectedId() { return QUERY; }
|
@Override public String expectedId() { return QUERY; }
|
||||||
@Override public String expectedUrlContains() { return "music.youtube.com/search?q=" + QUERY; }
|
@Override public String expectedUrlContains() { return BASE_SEARCH_URL + QUERY; }
|
||||||
@Override public String expectedOriginalUrlContains() { return "music.youtube.com/search?q=" + QUERY; }
|
@Override public String expectedOriginalUrlContains() { return BASE_SEARCH_URL + QUERY; }
|
||||||
@Override public String expectedSearchString() { return QUERY; }
|
@Override public String expectedSearchString() { return QUERY; }
|
||||||
@Nullable @Override public String expectedSearchSuggestion() { return null; }
|
@Nullable @Override public String expectedSearchSuggestion() { return null; }
|
||||||
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.STREAM; }
|
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.STREAM; }
|
||||||
@ -46,7 +53,9 @@ public class YoutubeMusicSearchExtractorTest {
|
|||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
YoutubeTestsUtils.ensureStateless();
|
||||||
|
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "music_videos"));
|
||||||
|
|
||||||
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_VIDEOS), "");
|
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_VIDEOS), "");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
}
|
}
|
||||||
@ -55,8 +64,8 @@ public class YoutubeMusicSearchExtractorTest {
|
|||||||
@Override public StreamingService expectedService() { return YouTube; }
|
@Override public StreamingService expectedService() { return YouTube; }
|
||||||
@Override public String expectedName() { return QUERY; }
|
@Override public String expectedName() { return QUERY; }
|
||||||
@Override public String expectedId() { return QUERY; }
|
@Override public String expectedId() { return QUERY; }
|
||||||
@Override public String expectedUrlContains() { return "music.youtube.com/search?q=" + QUERY; }
|
@Override public String expectedUrlContains() { return BASE_SEARCH_URL + QUERY; }
|
||||||
@Override public String expectedOriginalUrlContains() { return "music.youtube.com/search?q=" + QUERY; }
|
@Override public String expectedOriginalUrlContains() { return BASE_SEARCH_URL + QUERY; }
|
||||||
@Override public String expectedSearchString() { return QUERY; }
|
@Override public String expectedSearchString() { return QUERY; }
|
||||||
@Nullable @Override public String expectedSearchSuggestion() { return null; }
|
@Nullable @Override public String expectedSearchSuggestion() { return null; }
|
||||||
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.STREAM; }
|
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.STREAM; }
|
||||||
@ -68,7 +77,9 @@ public class YoutubeMusicSearchExtractorTest {
|
|||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
YoutubeTestsUtils.ensureStateless();
|
||||||
|
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "music_albums"));
|
||||||
|
|
||||||
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_ALBUMS), "");
|
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_ALBUMS), "");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
}
|
}
|
||||||
@ -77,8 +88,8 @@ public class YoutubeMusicSearchExtractorTest {
|
|||||||
@Override public StreamingService expectedService() { return YouTube; }
|
@Override public StreamingService expectedService() { return YouTube; }
|
||||||
@Override public String expectedName() { return QUERY; }
|
@Override public String expectedName() { return QUERY; }
|
||||||
@Override public String expectedId() { return QUERY; }
|
@Override public String expectedId() { return QUERY; }
|
||||||
@Override public String expectedUrlContains() { return "music.youtube.com/search?q=" + URLEncoder.encode(QUERY); }
|
@Override public String expectedUrlContains() { return BASE_SEARCH_URL + URLEncoder.encode(QUERY, StandardCharsets.UTF_8); }
|
||||||
@Override public String expectedOriginalUrlContains() { return "music.youtube.com/search?q=" + URLEncoder.encode(QUERY); }
|
@Override public String expectedOriginalUrlContains() { return BASE_SEARCH_URL + URLEncoder.encode(QUERY, StandardCharsets.UTF_8); }
|
||||||
@Override public String expectedSearchString() { return QUERY; }
|
@Override public String expectedSearchString() { return QUERY; }
|
||||||
@Nullable @Override public String expectedSearchSuggestion() { return null; }
|
@Nullable @Override public String expectedSearchSuggestion() { return null; }
|
||||||
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.PLAYLIST; }
|
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.PLAYLIST; }
|
||||||
@ -90,7 +101,9 @@ public class YoutubeMusicSearchExtractorTest {
|
|||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
YoutubeTestsUtils.ensureStateless();
|
||||||
|
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "music_playlists"));
|
||||||
|
|
||||||
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_PLAYLISTS), "");
|
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_PLAYLISTS), "");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
}
|
}
|
||||||
@ -99,8 +112,8 @@ public class YoutubeMusicSearchExtractorTest {
|
|||||||
@Override public StreamingService expectedService() { return YouTube; }
|
@Override public StreamingService expectedService() { return YouTube; }
|
||||||
@Override public String expectedName() { return QUERY; }
|
@Override public String expectedName() { return QUERY; }
|
||||||
@Override public String expectedId() { return QUERY; }
|
@Override public String expectedId() { return QUERY; }
|
||||||
@Override public String expectedUrlContains() { return "music.youtube.com/search?q=" + QUERY; }
|
@Override public String expectedUrlContains() { return BASE_SEARCH_URL + QUERY; }
|
||||||
@Override public String expectedOriginalUrlContains() { return "music.youtube.com/search?q=" + QUERY; }
|
@Override public String expectedOriginalUrlContains() { return BASE_SEARCH_URL + QUERY; }
|
||||||
@Override public String expectedSearchString() { return QUERY; }
|
@Override public String expectedSearchString() { return QUERY; }
|
||||||
@Nullable @Override public String expectedSearchSuggestion() { return null; }
|
@Nullable @Override public String expectedSearchSuggestion() { return null; }
|
||||||
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.PLAYLIST; }
|
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.PLAYLIST; }
|
||||||
@ -112,7 +125,9 @@ public class YoutubeMusicSearchExtractorTest {
|
|||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
YoutubeTestsUtils.ensureStateless();
|
||||||
|
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "music_artists"));
|
||||||
|
|
||||||
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_ARTISTS), "");
|
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_ARTISTS), "");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
}
|
}
|
||||||
@ -121,8 +136,8 @@ public class YoutubeMusicSearchExtractorTest {
|
|||||||
@Override public StreamingService expectedService() { return YouTube; }
|
@Override public StreamingService expectedService() { return YouTube; }
|
||||||
@Override public String expectedName() { return QUERY; }
|
@Override public String expectedName() { return QUERY; }
|
||||||
@Override public String expectedId() { return QUERY; }
|
@Override public String expectedId() { return QUERY; }
|
||||||
@Override public String expectedUrlContains() { return "music.youtube.com/search?q=" + QUERY; }
|
@Override public String expectedUrlContains() { return BASE_SEARCH_URL + QUERY; }
|
||||||
@Override public String expectedOriginalUrlContains() { return "music.youtube.com/search?q=" + QUERY; }
|
@Override public String expectedOriginalUrlContains() { return BASE_SEARCH_URL + QUERY; }
|
||||||
@Override public String expectedSearchString() { return QUERY; }
|
@Override public String expectedSearchString() { return QUERY; }
|
||||||
@Nullable @Override public String expectedSearchSuggestion() { return null; }
|
@Nullable @Override public String expectedSearchSuggestion() { return null; }
|
||||||
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.CHANNEL; }
|
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.CHANNEL; }
|
||||||
@ -134,7 +149,9 @@ public class YoutubeMusicSearchExtractorTest {
|
|||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
YoutubeTestsUtils.ensureStateless();
|
||||||
|
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "suggestion"));
|
||||||
|
|
||||||
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_SONGS), "");
|
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_SONGS), "");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
}
|
}
|
||||||
@ -143,8 +160,8 @@ public class YoutubeMusicSearchExtractorTest {
|
|||||||
@Override public StreamingService expectedService() { return YouTube; }
|
@Override public StreamingService expectedService() { return YouTube; }
|
||||||
@Override public String expectedName() { return QUERY; }
|
@Override public String expectedName() { return QUERY; }
|
||||||
@Override public String expectedId() { return QUERY; }
|
@Override public String expectedId() { return QUERY; }
|
||||||
@Override public String expectedUrlContains() { return "music.youtube.com/search?q=" + URLEncoder.encode(QUERY); }
|
@Override public String expectedUrlContains() { return BASE_SEARCH_URL + URLEncoder.encode(QUERY, StandardCharsets.UTF_8); }
|
||||||
@Override public String expectedOriginalUrlContains() { return "music.youtube.com/search?q=" + URLEncoder.encode(QUERY); }
|
@Override public String expectedOriginalUrlContains() { return BASE_SEARCH_URL + URLEncoder.encode(QUERY, StandardCharsets.UTF_8); }
|
||||||
@Override public String expectedSearchString() { return QUERY; }
|
@Override public String expectedSearchString() { return QUERY; }
|
||||||
@Nullable @Override public String expectedSearchSuggestion() { return "mega man x3"; }
|
@Nullable @Override public String expectedSearchSuggestion() { return "mega man x3"; }
|
||||||
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.STREAM; }
|
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.STREAM; }
|
||||||
@ -157,7 +174,9 @@ public class YoutubeMusicSearchExtractorTest {
|
|||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
YoutubeTestsUtils.ensureStateless();
|
||||||
|
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "corrected"));
|
||||||
|
|
||||||
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_SONGS), "");
|
extractor = YouTube.getSearchExtractor(QUERY, singletonList(YoutubeSearchQueryHandlerFactory.MUSIC_SONGS), "");
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
}
|
}
|
||||||
@ -166,8 +185,8 @@ public class YoutubeMusicSearchExtractorTest {
|
|||||||
@Override public StreamingService expectedService() { return YouTube; }
|
@Override public StreamingService expectedService() { return YouTube; }
|
||||||
@Override public String expectedName() { return QUERY; }
|
@Override public String expectedName() { return QUERY; }
|
||||||
@Override public String expectedId() { return QUERY; }
|
@Override public String expectedId() { return QUERY; }
|
||||||
@Override public String expectedUrlContains() { return "music.youtube.com/search?q=" + URLEncoder.encode(QUERY); }
|
@Override public String expectedUrlContains() { return BASE_SEARCH_URL + URLEncoder.encode(QUERY, StandardCharsets.UTF_8); }
|
||||||
@Override public String expectedOriginalUrlContains() { return "music.youtube.com/search?q=" + URLEncoder.encode(QUERY); }
|
@Override public String expectedOriginalUrlContains() { return BASE_SEARCH_URL + URLEncoder.encode(QUERY, StandardCharsets.UTF_8); }
|
||||||
@Override public String expectedSearchString() { return QUERY; }
|
@Override public String expectedSearchString() { return QUERY; }
|
||||||
@Nullable @Override public String expectedSearchSuggestion() { return EXPECTED_SUGGESTION; }
|
@Nullable @Override public String expectedSearchSuggestion() { return EXPECTED_SUGGESTION; }
|
||||||
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.STREAM; }
|
@Override public InfoItem.InfoType expectedInfoItemType() { return InfoItem.InfoType.STREAM; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user