diff --git a/extractor/src/test/java/org/schabi/newpipe/downloader/DownloaderFactory.java b/extractor/src/test/java/org/schabi/newpipe/downloader/DownloaderFactory.java index 6799a915..ee207c41 100644 --- a/extractor/src/test/java/org/schabi/newpipe/downloader/DownloaderFactory.java +++ b/extractor/src/test/java/org/schabi/newpipe/downloader/DownloaderFactory.java @@ -6,9 +6,17 @@ import java.io.IOException; public class DownloaderFactory { - public final static String RESOURCE_PATH = "src/test/resources/org/schabi/newpipe/extractor/"; + public static final String RESOURCE_PATH = "src/test/resources/org/schabi/newpipe/extractor/"; - private final static DownloaderType DEFAULT_DOWNLOADER = DownloaderType.REAL; + private static final DownloaderType DEFAULT_DOWNLOADER = DownloaderType.REAL; + + public static DownloaderType getDownloaderType() { + try { + return DownloaderType.valueOf(System.getProperty("downloader")); + } catch (final Exception e) { + return DEFAULT_DOWNLOADER; + } + } /** *
@@ -28,14 +36,8 @@ public class DownloaderFactory { * @param path The path to the folder where mocks are saved/retrieved. * Preferably starting with {@link DownloaderFactory#RESOURCE_PATH} */ - public Downloader getDownloader(String path) throws IOException { - DownloaderType type; - try { - type = DownloaderType.valueOf(System.getProperty("downloader")); - } catch (Exception e) { - type = DEFAULT_DOWNLOADER; - } - + public static Downloader getDownloader(final String path) throws IOException { + final DownloaderType type = getDownloaderType(); switch (type) { case REAL: return DownloaderTestImpl.getInstance(); @@ -44,7 +46,7 @@ public class DownloaderFactory { case RECORDING: return new RecordingDownloader(path); default: - throw new UnsupportedOperationException("Unknown downloader type: " + type.toString()); + throw new UnsupportedOperationException("Unknown downloader type: " + type); } } } diff --git a/extractor/src/test/java/org/schabi/newpipe/downloader/MockOnly.java b/extractor/src/test/java/org/schabi/newpipe/downloader/MockOnly.java new file mode 100644 index 00000000..d6ca1712 --- /dev/null +++ b/extractor/src/test/java/org/schabi/newpipe/downloader/MockOnly.java @@ -0,0 +1,20 @@ +package org.schabi.newpipe.downloader; + +import org.junit.jupiter.api.extension.ExtendWith; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * Use this to annotate tests methods/classes that should only be run when the downloader is of type + * {@link DownloaderType#MOCK} or {@link DownloaderType#RECORDING}. This should be used when e.g. an + * extractor returns different results each time because the underlying service web page does so. In + * that case it makes sense to only run the tests with the mock downloader, since the real web page + * is not reliable, but we still want to make sure that the code correctly interprets the stored and + * mocked web page data. + * @see MockOnlyCondition + */ +@Retention(RetentionPolicy.RUNTIME) +@ExtendWith(MockOnlyCondition.class) +public @interface MockOnly { +} diff --git a/extractor/src/test/java/org/schabi/newpipe/downloader/MockOnlyCondition.java b/extractor/src/test/java/org/schabi/newpipe/downloader/MockOnlyCondition.java new file mode 100644 index 00000000..82f57fa6 --- /dev/null +++ b/extractor/src/test/java/org/schabi/newpipe/downloader/MockOnlyCondition.java @@ -0,0 +1,21 @@ +package org.schabi.newpipe.downloader; + +import org.junit.jupiter.api.extension.ConditionEvaluationResult; +import org.junit.jupiter.api.extension.ExecutionCondition; +import org.junit.jupiter.api.extension.ExtensionContext; + +/** + * @see MockOnly + */ +public class MockOnlyCondition implements ExecutionCondition { + private static final String MOCK_ONLY_REASON = "Mock only"; + + @Override + public ConditionEvaluationResult evaluateExecutionCondition(final ExtensionContext context) { + if (DownloaderFactory.getDownloaderType() == DownloaderType.REAL) { + return ConditionEvaluationResult.disabled(MOCK_ONLY_REASON); + } else { + return ConditionEvaluationResult.enabled(MOCK_ONLY_REASON); + } + } +} diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java index 98283068..94966913 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java @@ -35,7 +35,7 @@ public class YoutubeChannelExtractorTest { public static void setUp() throws IOException { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "notAvailable")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "notAvailable")); } @Test @@ -132,7 +132,7 @@ public class YoutubeChannelExtractorTest { public static void setUp() throws IOException { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "notSupported")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "notSupported")); } @Test @@ -151,7 +151,7 @@ public class YoutubeChannelExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "gronkh")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "gronkh")); extractor = (YoutubeChannelExtractor) YouTube .getChannelExtractor("http://www.youtube.com/user/Gronkh"); extractor.fetchPage(); @@ -248,7 +248,7 @@ public class YoutubeChannelExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "VSauce")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "VSauce")); extractor = (YoutubeChannelExtractor) YouTube .getChannelExtractor("https://www.youtube.com/user/Vsauce"); extractor.fetchPage(); @@ -344,7 +344,7 @@ public class YoutubeChannelExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "kurzgesagt")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "kurzgesagt")); extractor = (YoutubeChannelExtractor) YouTube .getChannelExtractor("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q"); extractor.fetchPage(); @@ -461,7 +461,7 @@ public class YoutubeChannelExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "captainDisillusion")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "captainDisillusion")); extractor = (YoutubeChannelExtractor) YouTube .getChannelExtractor("https://www.youtube.com/user/CaptainDisillusion/videos"); extractor.fetchPage(); @@ -556,7 +556,7 @@ public class YoutubeChannelExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "random")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "random")); extractor = (YoutubeChannelExtractor) YouTube .getChannelExtractor("https://www.youtube.com/channel/UCUaQMQS9lY5lit3vurpXQ6w"); extractor.fetchPage(); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelLocalizationTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelLocalizationTest.java index 0c64b0b7..5cf41a76 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelLocalizationTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelLocalizationTest.java @@ -32,7 +32,7 @@ public class YoutubeChannelLocalizationTest { public void testAllSupportedLocalizations() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "localization")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "localization")); testLocalizationsFor("https://www.youtube.com/user/NBCNews"); testLocalizationsFor("https://www.youtube.com/channel/UCcmpeVbSSQlZRvHfdC-CRwg/videos"); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java index 6ea11a4d..2c5119d5 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java @@ -40,7 +40,7 @@ public class YoutubeCommentsExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "thomas")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "thomas")); extractor = (YoutubeCommentsExtractor) YouTube .getCommentsExtractor(url); extractor.fetchPage(); @@ -129,7 +129,7 @@ public class YoutubeCommentsExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "empty")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "empty")); extractor = (YoutubeCommentsExtractor) YouTube .getCommentsExtractor(url); extractor.fetchPage(); @@ -169,7 +169,7 @@ public class YoutubeCommentsExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "hearted")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "hearted")); extractor = (YoutubeCommentsExtractor) YouTube .getCommentsExtractor(url); extractor.fetchPage(); @@ -212,7 +212,7 @@ public class YoutubeCommentsExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "pinned")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "pinned")); extractor = (YoutubeCommentsExtractor) YouTube .getCommentsExtractor(url); extractor.fetchPage(); @@ -254,7 +254,7 @@ public class YoutubeCommentsExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "likes")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "likes")); extractor = (YoutubeCommentsExtractor) YouTube .getCommentsExtractor(url); extractor.fetchPage(); @@ -286,7 +286,7 @@ public class YoutubeCommentsExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "localized_vote_count")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "localized_vote_count")); extractor = (YoutubeCommentsExtractor) YouTube .getCommentsExtractor(url); // Force non english local here @@ -315,7 +315,7 @@ public class YoutubeCommentsExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "replies")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "replies")); extractor = (YoutubeCommentsExtractor) YouTube .getCommentsExtractor(url); extractor.fetchPage(); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeFeedExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeFeedExtractorTest.java index 2ee116b2..ef160564 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeFeedExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeFeedExtractorTest.java @@ -30,7 +30,7 @@ public class YoutubeFeedExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH)); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH)); extractor = (YoutubeFeedExtractor) YouTube .getFeedExtractor("https://www.youtube.com/user/Kurzgesagt"); extractor.fetchPage(); @@ -84,7 +84,7 @@ public class YoutubeFeedExtractorTest { @BeforeAll public static void setUp() throws IOException { - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "notAvailable/")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "notAvailable/")); } @Test diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeKioskExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeKioskExtractorTest.java index f247566e..23db8a58 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeKioskExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeKioskExtractorTest.java @@ -26,7 +26,7 @@ public class YoutubeKioskExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "trending")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "trending")); extractor = (YoutubeTrendingExtractor) YouTube.getKioskList().getDefaultKioskExtractor(); extractor.fetchPage(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeMixPlaylistExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeMixPlaylistExtractorTest.java index ff415b92..ceb5852c 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeMixPlaylistExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeMixPlaylistExtractorTest.java @@ -41,7 +41,7 @@ public class YoutubeMixPlaylistExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "mix")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "mix")); dummyCookie.put(YoutubeMixPlaylistExtractor.COOKIE_NAME, "whatever"); extractor = (YoutubeMixPlaylistExtractor) YouTube .getPlaylistExtractor("https://www.youtube.com/watch?v=" + VIDEO_ID @@ -131,7 +131,7 @@ public class YoutubeMixPlaylistExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "mixWithIndex")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "mixWithIndex")); dummyCookie.put(YoutubeMixPlaylistExtractor.COOKIE_NAME, "whatever"); extractor = (YoutubeMixPlaylistExtractor) YouTube .getPlaylistExtractor("https://www.youtube.com/watch?v=" + VIDEO_ID_NUMBER_4 @@ -212,7 +212,7 @@ public class YoutubeMixPlaylistExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "myMix")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "myMix")); dummyCookie.put(YoutubeMixPlaylistExtractor.COOKIE_NAME, "whatever"); extractor = (YoutubeMixPlaylistExtractor) YouTube .getPlaylistExtractor("https://www.youtube.com/watch?v=" + VIDEO_ID @@ -297,7 +297,7 @@ public class YoutubeMixPlaylistExtractorTest { public static void setUp() throws IOException { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "invalid")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "invalid")); dummyCookie.put(YoutubeMixPlaylistExtractor.COOKIE_NAME, "whatever"); } @@ -332,7 +332,7 @@ public class YoutubeMixPlaylistExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "channelMix")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "channelMix")); dummyCookie.put(YoutubeMixPlaylistExtractor.COOKIE_NAME, "whatever"); extractor = (YoutubeMixPlaylistExtractor) YouTube .getPlaylistExtractor("https://www.youtube.com/watch?v=" + VIDEO_ID_OF_CHANNEL diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelperTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelperTest.java index 7ae7d4d1..45643ec0 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelperTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelperTest.java @@ -21,7 +21,7 @@ public class YoutubeParsingHelperTest { public static void setUp() throws IOException { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "youtubeParsingHelper")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "youtubeParsingHelper")); } @Test diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java index 3f076312..80fb2c36 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java @@ -43,7 +43,7 @@ public class YoutubePlaylistExtractorTest { public static void setUp() throws IOException { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "notAvailable")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "notAvailable")); } @Test @@ -68,7 +68,7 @@ public class YoutubePlaylistExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "TimelessPopHits")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "TimelessPopHits")); extractor = (YoutubePlaylistExtractor) YouTube .getPlaylistExtractor("http://www.youtube.com/watch?v=lp-EO5I60KA&list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj"); extractor.fetchPage(); @@ -171,7 +171,7 @@ public class YoutubePlaylistExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "huge")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "huge")); extractor = (YoutubePlaylistExtractor) YouTube .getPlaylistExtractor("https://www.youtube.com/watch?v=8SbUC-UaAxE&list=PLWwAypAcFRgKAIIFqBr9oy-ZYZnixa_Fj"); extractor.fetchPage(); @@ -290,7 +290,7 @@ public class YoutubePlaylistExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "learning")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "learning")); extractor = (YoutubePlaylistExtractor) YouTube .getPlaylistExtractor("https://www.youtube.com/playlist?list=PL8dPuuaLjXtOAKed_MxxWBNaPno5h3Zs8"); extractor.fetchPage(); @@ -394,7 +394,7 @@ public class YoutubePlaylistExtractorTest { public static void setUp() throws IOException { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "continuations")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "continuations")); } @Test diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSuggestionExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSuggestionExtractorTest.java index dd9d5b17..1855f8a0 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSuggestionExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSuggestionExtractorTest.java @@ -47,7 +47,7 @@ public class YoutubeSuggestionExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + ""), new Localization("de", "DE")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + ""), new Localization("de", "DE")); suggestionExtractor = YouTube.getSuggestionExtractor(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingKioskInfoTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingKioskInfoTest.java index b11a2f06..164ffc8f 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingKioskInfoTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingKioskInfoTest.java @@ -48,7 +48,7 @@ public class YoutubeTrendingKioskInfoTest { throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH)); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH)); LinkHandlerFactory LinkHandlerFactory = ((StreamingService) YouTube).getKioskList().getListLinkHandlerFactoryByType("Trending"); kioskInfo = KioskInfo.getInfo(YouTube, LinkHandlerFactory.fromId("Trending").getUrl()); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorTest.java index 3a1de7eb..8b5aaf65 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorTest.java @@ -41,7 +41,7 @@ public class YoutubeSearchExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "all")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "all")); extractor = YouTube.getSearchExtractor(QUERY); extractor.fetchPage(); } @@ -64,7 +64,7 @@ public class YoutubeSearchExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "channel")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "channel")); extractor = YouTube.getSearchExtractor(QUERY, singletonList(CHANNELS), ""); extractor.fetchPage(); } @@ -89,7 +89,7 @@ public class YoutubeSearchExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "playlist")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "playlist")); extractor = YouTube.getSearchExtractor(QUERY, singletonList(PLAYLISTS), ""); extractor.fetchPage(); } @@ -114,7 +114,7 @@ public class YoutubeSearchExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "videos")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "videos")); extractor = YouTube.getSearchExtractor(QUERY, singletonList(VIDEOS), ""); extractor.fetchPage(); } @@ -140,7 +140,7 @@ public class YoutubeSearchExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "suggestions")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "suggestions")); extractor = YouTube.getSearchExtractor(QUERY, singletonList(VIDEOS), ""); extractor.fetchPage(); } @@ -165,7 +165,7 @@ public class YoutubeSearchExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "corrected")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "corrected")); extractor = YouTube.getSearchExtractor(QUERY, singletonList(VIDEOS), ""); extractor.fetchPage(); } @@ -190,7 +190,7 @@ public class YoutubeSearchExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "random")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "random")); extractor = YouTube.getSearchExtractor(QUERY); extractor.fetchPage(); } @@ -226,7 +226,7 @@ public class YoutubeSearchExtractorTest { public void duplicatedItemsCheck() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "paging")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "paging")); final SearchExtractor extractor = YouTube.getSearchExtractor("cirque du soleil", singletonList(VIDEOS), ""); extractor.fetchPage(); @@ -245,7 +245,7 @@ public class YoutubeSearchExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "metaInfo")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "metaInfo")); extractor = YouTube.getSearchExtractor(QUERY, singletonList(VIDEOS), ""); extractor.fetchPage(); } @@ -282,7 +282,7 @@ public class YoutubeSearchExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "verified")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "verified")); extractor = YouTube.getSearchExtractor(QUERY, singletonList(CHANNELS), ""); extractor.fetchPage(); } @@ -320,7 +320,7 @@ public class YoutubeSearchExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "video_uploader_avatar")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "video_uploader_avatar")); extractor = YouTube.getSearchExtractor(QUERY, singletonList(VIDEOS), ""); extractor.fetchPage(); } @@ -352,7 +352,7 @@ public class YoutubeSearchExtractorTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "video_description")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "video_description")); extractor = YouTube.getSearchExtractor(QUERY, singletonList(VIDEOS), ""); extractor.fetchPage(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorAgeRestrictedTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorAgeRestrictedTest.java index 1ac7b5c1..b907bcec 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorAgeRestrictedTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorAgeRestrictedTest.java @@ -30,7 +30,7 @@ public class YoutubeStreamExtractorAgeRestrictedTest extends DefaultStreamExtrac YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeStreamExtractor.resetDeobfuscationCode(); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "ageRestricted")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "ageRestricted")); extractor = YouTube.getStreamExtractor(URL); extractor.fetchPage(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorControversialTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorControversialTest.java index 73d7648a..51bbbecd 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorControversialTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorControversialTest.java @@ -34,7 +34,7 @@ public class YoutubeStreamExtractorControversialTest extends DefaultStreamExtrac YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeStreamExtractor.resetDeobfuscationCode(); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "controversial")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "controversial")); extractor = YouTube.getStreamExtractor(URL); extractor.fetchPage(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorDefaultTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorDefaultTest.java index 67e80c29..e8681e5b 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorDefaultTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorDefaultTest.java @@ -65,7 +65,7 @@ public class YoutubeStreamExtractorDefaultTest { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeStreamExtractor.resetDeobfuscationCode(); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "notAvailable")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "notAvailable")); } @Test @@ -122,7 +122,7 @@ public class YoutubeStreamExtractorDefaultTest { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeStreamExtractor.resetDeobfuscationCode(); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "pewdiwpie")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "pewdiwpie")); extractor = YouTube.getStreamExtractor(URL); extractor.fetchPage(); } @@ -167,7 +167,7 @@ public class YoutubeStreamExtractorDefaultTest { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeStreamExtractor.resetDeobfuscationCode(); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "unboxing")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "unboxing")); extractor = YouTube.getStreamExtractor(URL); extractor.fetchPage(); } @@ -222,7 +222,7 @@ public class YoutubeStreamExtractorDefaultTest { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeStreamExtractor.resetDeobfuscationCode(); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "ratingsDisabled")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "ratingsDisabled")); extractor = YouTube.getStreamExtractor(URL); extractor.fetchPage(); } @@ -260,7 +260,7 @@ public class YoutubeStreamExtractorDefaultTest { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeStreamExtractor.resetDeobfuscationCode(); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "streamSegmentsTagesschau")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "streamSegmentsTagesschau")); extractor = YouTube.getStreamExtractor(URL); extractor.fetchPage(); } @@ -323,7 +323,7 @@ public class YoutubeStreamExtractorDefaultTest { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeStreamExtractor.resetDeobfuscationCode(); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "streamSegmentsMaiLab")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "streamSegmentsMaiLab")); extractor = YouTube.getStreamExtractor(URL); extractor.fetchPage(); } @@ -392,7 +392,7 @@ public class YoutubeStreamExtractorDefaultTest { public static void setUp() throws Exception { YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "publicBroadcast")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "publicBroadcast")); extractor = YouTube.getStreamExtractor(URL); YoutubeStreamExtractor.resetDeobfuscationCode(); extractor.fetchPage(); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorLivestreamTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorLivestreamTest.java index 3a3e7f0b..2ec36582 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorLivestreamTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorLivestreamTest.java @@ -31,7 +31,7 @@ public class YoutubeStreamExtractorLivestreamTest extends DefaultStreamExtractor YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeStreamExtractor.resetDeobfuscationCode(); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "live")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "live")); extractor = YouTube.getStreamExtractor(URL); extractor.fetchPage(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorUnlistedTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorUnlistedTest.java index a3f2b0b2..634391d0 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorUnlistedTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/stream/YoutubeStreamExtractorUnlistedTest.java @@ -30,7 +30,7 @@ public class YoutubeStreamExtractorUnlistedTest extends DefaultStreamExtractorTe YoutubeParsingHelper.resetClientVersionAndKey(); YoutubeParsingHelper.setNumberGenerator(new Random(1)); YoutubeStreamExtractor.resetDeobfuscationCode(); - NewPipe.init(new DownloaderFactory().getDownloader(RESOURCE_PATH + "unlisted")); + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "unlisted")); extractor = YouTube.getStreamExtractor(URL); extractor.fetchPage(); }