From dc0d0bda244d8decf448a62c2d42ea965646bed8 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sat, 15 Sep 2018 20:12:52 +0200 Subject: [PATCH 1/5] replace uiHandler name with linkhandler --- .../schabi/newpipe/extractor/Extractor.java | 18 +++++++++--------- .../newpipe/extractor/ListExtractor.java | 8 ++++---- .../extractor/channel/ChannelInfo.java | 2 +- .../newpipe/extractor/kiosk/KioskInfo.java | 2 +- .../extractor/playlist/PlaylistInfo.java | 2 +- .../extractor/search/SearchExtractor.java | 8 ++++---- .../newpipe/extractor/search/SearchInfo.java | 2 +- .../SoundcloudChannelExtractor.java | 2 +- .../SoundcloudPlaylistExtractor.java | 2 +- .../soundcloud/SoundcloudStreamExtractor.java | 4 ++-- .../newpipe/extractor/utils/Localization.java | 19 +++++++++++++++++++ .../search/YoutubeSearchCountTest.java | 4 +--- 12 files changed, 45 insertions(+), 28 deletions(-) create mode 100644 extractor/src/main/java/org/schabi/newpipe/extractor/utils/Localization.java diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java index ac2d7ca3e..02999dc9f 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java @@ -15,17 +15,17 @@ public abstract class Extractor { */ private final StreamingService service; - private final LinkHandler uIHandler; + private final LinkHandler linkHandler; @Nullable private boolean pageFetched = false; private final Downloader downloader; - public Extractor(final StreamingService service, final LinkHandler uIHandler) { + public Extractor(final StreamingService service, final LinkHandler linkHandler) { if(service == null) throw new NullPointerException("service is null"); - if(uIHandler == null) throw new NullPointerException("LinkHandler is null"); + if(linkHandler == null) throw new NullPointerException("LinkHandler is null"); this.service = service; - this.uIHandler = uIHandler; + this.linkHandler = linkHandler; this.downloader = NewPipe.getDownloader(); if(downloader == null) throw new NullPointerException("downloader is null"); } @@ -34,8 +34,8 @@ public abstract class Extractor { * @return The {@link LinkHandler} of the current extractor object (e.g. a ChannelExtractor should return a channel url handler). */ @Nonnull - public LinkHandler getUIHandler() { - return uIHandler; + public LinkHandler getLinkHandler() { + return linkHandler; } /** @@ -67,7 +67,7 @@ public abstract class Extractor { @Nonnull public String getId() throws ParsingException { - return uIHandler.getId(); + return linkHandler.getId(); } /** @@ -80,12 +80,12 @@ public abstract class Extractor { @Nonnull public String getOriginalUrl() throws ParsingException { - return uIHandler.getOriginalUrl(); + return linkHandler.getOriginalUrl(); } @Nonnull public String getUrl() throws ParsingException { - return uIHandler.getUrl(); + return linkHandler.getUrl(); } @Nonnull diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java index 51cabe92f..b254adbd8 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java @@ -13,8 +13,8 @@ import java.util.List; */ public abstract class ListExtractor extends Extractor { - public ListExtractor(StreamingService service, ListLinkHandler uiHandler) { - super(service, uiHandler); + public ListExtractor(StreamingService service, ListLinkHandler linkHandler) { + super(service, linkHandler); } /** @@ -51,8 +51,8 @@ public abstract class ListExtractor extends Extractor { } @Override - public ListLinkHandler getUIHandler() { - return (ListLinkHandler) super.getUIHandler(); + public ListLinkHandler getLinkHandler() { + return (ListLinkHandler) super.getLinkHandler(); } /*////////////////////////////////////////////////////////////////////////// diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java index 297b689e4..11c80c86e 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java @@ -55,7 +55,7 @@ public class ChannelInfo extends ListInfo { public static ChannelInfo getInfo(ChannelExtractor extractor) throws IOException, ExtractionException { ChannelInfo info = new ChannelInfo(extractor.getServiceId(), - extractor.getUIHandler(), + extractor.getLinkHandler(), extractor.getName()); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java index 6c357bd19..95f0ed0e8 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java @@ -68,7 +68,7 @@ public class KioskInfo extends ListInfo { public static KioskInfo getInfo(KioskExtractor extractor) throws ExtractionException { final KioskInfo info = new KioskInfo(extractor.getServiceId(), - extractor.getUIHandler(), + extractor.getLinkHandler(), extractor.getName()); final ListExtractor.InfoItemsPage itemsPage = ExtractorHelper.getItemsPageOrLogError(info, extractor); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java index 1eb35723d..f55662a26 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java @@ -41,7 +41,7 @@ public class PlaylistInfo extends ListInfo { final PlaylistInfo info = new PlaylistInfo( extractor.getServiceId(), - extractor.getUIHandler(), + extractor.getLinkHandler(), extractor.getName()); try { diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchExtractor.java index ebbf76a66..f94c1325b 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchExtractor.java @@ -25,7 +25,7 @@ public abstract class SearchExtractor extends ListExtractor { } public String getSearchString() { - return getUIHandler().getSearchString(); + return getLinkHandler().getSearchString(); } public abstract String getSearchSuggestion() throws ParsingException; @@ -35,13 +35,13 @@ public abstract class SearchExtractor extends ListExtractor { } @Override - public SearchQueryHandler getUIHandler() { - return (SearchQueryHandler) super.getUIHandler(); + public SearchQueryHandler getLinkHandler() { + return (SearchQueryHandler) super.getLinkHandler(); } @Override public String getName() { - return getUIHandler().getSearchString(); + return getLinkHandler().getSearchString(); } protected String getContentCountry() { diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java index 27b622332..1ec1d7946 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java @@ -33,7 +33,7 @@ public class SearchInfo extends ListInfo { public static SearchInfo getInfo(SearchExtractor extractor) throws ExtractionException, IOException { final SearchInfo info = new SearchInfo( extractor.getServiceId(), - extractor.getUIHandler(), + extractor.getLinkHandler(), extractor.getSearchString()); try { diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractor.java index 1b6778698..f2d6a0268 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractor.java @@ -31,7 +31,7 @@ public class SoundcloudChannelExtractor extends ChannelExtractor { @Override public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException { - userId = getUIHandler().getId(); + userId = getLinkHandler().getId(); String apiUrl = "https://api-v2.soundcloud.com/users/" + userId + "?client_id=" + SoundcloudParsingHelper.clientId(); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java index 20c454d6e..9a3846e6b 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java @@ -30,7 +30,7 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor { @Override public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException { - playlistId = getUIHandler().getId(); + playlistId = getLinkHandler().getId(); String apiUrl = "https://api.soundcloud.com/playlists/" + playlistId + "?client_id=" + SoundcloudParsingHelper.clientId() + "&representation=compact"; diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java index dbd9971c9..eaddc1149 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java @@ -21,8 +21,8 @@ import java.util.List; public class SoundcloudStreamExtractor extends StreamExtractor { private JsonObject track; - public SoundcloudStreamExtractor(StreamingService service, LinkHandler uIHandler) { - super(service, uIHandler); + public SoundcloudStreamExtractor(StreamingService service, LinkHandler linkHandler) { + super(service, linkHandler); } @Override diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/utils/Localization.java b/extractor/src/main/java/org/schabi/newpipe/extractor/utils/Localization.java new file mode 100644 index 000000000..d4f5ddbc0 --- /dev/null +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/utils/Localization.java @@ -0,0 +1,19 @@ +package org.schabi.newpipe.extractor.utils; + +public class Localization { + private final String country; + private final String language; + + public Localization(String country, String language) { + this.country = country; + this.language = language; + } + + public String getCountry() { + return country; + } + + public String getLanguage() { + return language; + } +} diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchCountTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchCountTest.java index 745b6a0a1..aa79893fe 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchCountTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchCountTest.java @@ -3,7 +3,6 @@ package org.schabi.newpipe.extractor.services.youtube.search; import org.junit.BeforeClass; import org.junit.Test; import org.schabi.newpipe.Downloader; -import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.channel.ChannelInfoItem; import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor; @@ -25,8 +24,7 @@ public class YoutubeSearchCountTest { } @Test - public void testViewCount() throws Exception { - boolean foundKnownChannel = false; + public void testViewCount() { ChannelInfoItem ci = (ChannelInfoItem) itemsPage.getItems().get(0); assertTrue("Count does not fit: " + Long.toString(ci.getSubscriberCount()), 65043316 < ci.getSubscriberCount() && ci.getSubscriberCount() < 68043316); From ce2bbee1e950000cabae490bfb457eab228eee0b Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sat, 15 Sep 2018 21:47:53 +0200 Subject: [PATCH 2/5] add propper localization --- .../schabi/newpipe/extractor/Downloader.java | 5 +- .../schabi/newpipe/extractor/Extractor.java | 10 +- .../newpipe/extractor/ListExtractor.java | 5 +- .../org/schabi/newpipe/extractor/NewPipe.java | 13 +- .../newpipe/extractor/StreamingService.java | 91 +++++++++++--- .../extractor/SuggestionExtractor.java | 11 +- .../extractor/channel/ChannelExtractor.java | 5 +- .../extractor/channel/ChannelInfo.java | 10 +- .../extractor/kiosk/KioskExtractor.java | 8 +- .../newpipe/extractor/kiosk/KioskInfo.java | 4 +- .../newpipe/extractor/kiosk/KioskList.java | 12 +- .../extractor/playlist/PlaylistExtractor.java | 5 +- .../extractor/playlist/PlaylistInfo.java | 9 +- .../extractor/search/SearchExtractor.java | 13 +- .../newpipe/extractor/search/SearchInfo.java | 8 +- .../SoundcloudChannelExtractor.java | 5 +- .../soundcloud/SoundcloudChartsExtractor.java | 8 +- .../SoundcloudPlaylistExtractor.java | 5 +- .../soundcloud/SoundcloudSearchExtractor.java | 9 +- .../soundcloud/SoundcloudService.java | 30 ++--- .../soundcloud/SoundcloudStreamExtractor.java | 5 +- .../SoundcloudSuggestionExtractor.java | 7 +- .../services/youtube/YoutubeService.java | 32 ++--- .../extractors/YoutubeChannelExtractor.java | 5 +- .../extractors/YoutubePlaylistExtractor.java | 5 +- .../extractors/YoutubeSearchExtractor.java | 11 +- .../extractors/YoutubeStreamExtractor.java | 5 +- .../YoutubeSuggestionExtractor.java | 9 +- .../extractors/YoutubeTrendingExtractor.java | 8 +- .../extractor/stream/StreamExtractor.java | 5 +- .../newpipe/extractor/stream/StreamInfo.java | 1 + .../java/org/schabi/newpipe/Downloader.java | 7 +- .../SoundcloudChannelExtractorTest.java | 5 +- .../SoundcloudChartsExtractorTest.java | 3 +- ...oundcloudChartsLinkHandlerFactoryTest.java | 35 +++--- .../SoundcloudParsingHelperTest.java | 3 +- .../SoundcloudPlaylistExtractorTest.java | 7 +- .../SoundcloudStreamExtractorDefaultTest.java | 3 +- ...oundcloudStreamLinkHandlerFactoryTest.java | 51 ++++---- .../SoundcloudSubscriptionExtractorTest.java | 3 +- .../SoundcloudSuggestionExtractorTest.java | 7 +- ...ndcloudSearchExtractorChannelOnlyTest.java | 7 +- .../SoundcloudSearchExtractorDefaultTest.java | 8 +- .../search/SoundcloudSearchQHTest.java | 3 +- .../youtube/YoutubeChannelExtractorTest.java | 11 +- .../YoutubeChannelLinkHandlerFactoryTest.java | 39 +++--- .../youtube/YoutubePlaylistExtractorTest.java | 5 +- .../services/youtube/YoutubeServiceTest.java | 3 +- ...utubeStreamExtractorAgeRestrictedTest.java | 3 +- ...utubeStreamExtractorControversialTest.java | 3 +- .../YoutubeStreamExtractorDASHTest.java | 3 +- .../YoutubeStreamExtractorDefaultTest.java | 5 +- .../YoutubeStreamLinkHandlerFactoryTest.java | 111 +++++++++--------- .../YoutubeSubscriptionExtractorTest.java | 3 +- .../YoutubeSuggestionExtractorTest.java | 5 +- .../youtube/YoutubeTrendingExtractorTest.java | 3 +- .../youtube/YoutubeTrendingKioskInfoTest.java | 3 +- ...YoutubeTrendingLinkHandlerFactoryTest.java | 3 +- .../search/YoutubeSearchCountTest.java | 5 +- ...YoutubeSearchExtractorChannelOnlyTest.java | 7 +- .../YoutubeSearchExtractorDefaultTest.java | 7 +- 61 files changed, 435 insertions(+), 285 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/Downloader.java b/extractor/src/main/java/org/schabi/newpipe/extractor/Downloader.java index fde90a2b5..d750bc2c5 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/Downloader.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/Downloader.java @@ -1,6 +1,7 @@ package org.schabi.newpipe.extractor; import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; +import org.schabi.newpipe.extractor.utils.Localization; import java.io.IOException; import java.util.Map; @@ -32,11 +33,11 @@ public interface Downloader { * but set the HTTP header field "Accept-Language" to the supplied string. * * @param siteUrl the URL of the text file to return the contents of - * @param language the language (usually a 2-character code) to set as the preferred language + * @param localization the language and country (usually a 2-character code for each) * @return the contents of the specified text file * @throws IOException */ - String download(String siteUrl, String language) throws IOException, ReCaptchaException; + String download(String siteUrl, Localization localization) throws IOException, ReCaptchaException; /** * Download the text file at the supplied URL as in download(String), diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java index 02999dc9f..ac96a37de 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java @@ -3,6 +3,7 @@ package org.schabi.newpipe.extractor; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.linkhandler.LinkHandler; +import org.schabi.newpipe.extractor.utils.Localization; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -16,17 +17,19 @@ public abstract class Extractor { private final StreamingService service; private final LinkHandler linkHandler; + private final Localization localization; @Nullable private boolean pageFetched = false; private final Downloader downloader; - public Extractor(final StreamingService service, final LinkHandler linkHandler) { + public Extractor(final StreamingService service, final LinkHandler linkHandler, final Localization localization) { if(service == null) throw new NullPointerException("service is null"); if(linkHandler == null) throw new NullPointerException("LinkHandler is null"); this.service = service; this.linkHandler = linkHandler; this.downloader = NewPipe.getDownloader(); + this.localization = localization; if(downloader == null) throw new NullPointerException("downloader is null"); } @@ -100,4 +103,9 @@ public abstract class Extractor { public Downloader getDownloader() { return downloader; } + + @Nonnull + public Localization getLocalization() { + return localization; + } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java index b254adbd8..ba3eb0a83 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java @@ -2,6 +2,7 @@ package org.schabi.newpipe.extractor; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; +import org.schabi.newpipe.extractor.utils.Localization; import javax.annotation.Nonnull; import java.io.IOException; @@ -13,8 +14,8 @@ import java.util.List; */ public abstract class ListExtractor extends Extractor { - public ListExtractor(StreamingService service, ListLinkHandler linkHandler) { - super(service, linkHandler); + public ListExtractor(StreamingService service, ListLinkHandler linkHandler, Localization localization) { + super(service, linkHandler, localization); } /** diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/NewPipe.java b/extractor/src/main/java/org/schabi/newpipe/extractor/NewPipe.java index a12f38219..fcbde0f9e 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/NewPipe.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/NewPipe.java @@ -21,6 +21,7 @@ package org.schabi.newpipe.extractor; */ import org.schabi.newpipe.extractor.exceptions.ExtractionException; +import org.schabi.newpipe.extractor.utils.Localization; import java.util.List; @@ -29,12 +30,14 @@ import java.util.List; */ public class NewPipe { private static Downloader downloader = null; + private static Localization localization = null; private NewPipe() { } - public static void init(Downloader d) { + public static void init(Downloader d, Localization l) { downloader = d; + localization = l; } public static Downloader getDownloader() { @@ -95,4 +98,12 @@ public class NewPipe { return ""; } } + + public static void setLocalization(Localization localization) { + NewPipe.localization = localization; + } + + public static Localization getLocalization() { + return localization; + } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/StreamingService.java b/extractor/src/main/java/org/schabi/newpipe/extractor/StreamingService.java index 03e465b6c..55efd1f57 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/StreamingService.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/StreamingService.java @@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.search.SearchExtractor; import org.schabi.newpipe.extractor.linkhandler.*; import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor; +import org.schabi.newpipe.extractor.utils.Localization; import java.util.Collections; import java.util.List; @@ -76,45 +77,99 @@ public abstract class StreamingService { //////////////////////////////////////////// // Extractor //////////////////////////////////////////// - public abstract SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler, String contentCountry); - public abstract SuggestionExtractor getSuggestionExtractor(); + public abstract SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler, Localization localization); + public abstract SuggestionExtractor getSuggestionExtractor(Localization localization); public abstract SubscriptionExtractor getSubscriptionExtractor(); - public abstract KioskList getKioskList() throws ExtractionException; + public abstract KioskList getKioskList(Localization localization) throws ExtractionException; - public abstract ChannelExtractor getChannelExtractor(ListLinkHandler urlIdHandler) throws ExtractionException; - public abstract PlaylistExtractor getPlaylistExtractor(ListLinkHandler urlIdHandler) throws ExtractionException; - public abstract StreamExtractor getStreamExtractor(LinkHandler UIHFactory) throws ExtractionException; + public abstract ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler, + Localization localization) throws ExtractionException; + public abstract PlaylistExtractor getPlaylistExtractor(ListLinkHandler linkHandler, + Localization localization) throws ExtractionException; + public abstract StreamExtractor getStreamExtractor(LinkHandler linkHandler, + Localization localization) throws ExtractionException; + //////////////////////////////////////////// + // Extractor with default localization + //////////////////////////////////////////// - public SearchExtractor getSearchExtractor(String query, List contentFilter, String sortFilter, String contentCountry) throws ExtractionException { - return getSearchExtractor(getSearchQHFactory().fromQuery(query, contentFilter, sortFilter), contentCountry); + public SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler) { + return getSearchExtractor(queryHandler, NewPipe.getLocalization()); } - public ChannelExtractor getChannelExtractor(String id, List contentFilter, String sortFilter) throws ExtractionException { - return getChannelExtractor(getChannelLHFactory().fromQuery(id, contentFilter, sortFilter)); + public SuggestionExtractor getSuggestionExtractor() { + return getSuggestionExtractor(NewPipe.getLocalization()); } - public PlaylistExtractor getPlaylistExtractor(String id, List contentFilter, String sortFilter) throws ExtractionException { - return getPlaylistExtractor(getPlaylistLHFactory().fromQuery(id, contentFilter, sortFilter)); + public KioskList getKioskList() throws ExtractionException { + return getKioskList(NewPipe.getLocalization()); } - public SearchExtractor getSearchExtractor(String query, String contentCountry) throws ExtractionException { - return getSearchExtractor(getSearchQHFactory().fromQuery(query), contentCountry); + public ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler) throws ExtractionException { + return getChannelExtractor(linkHandler, NewPipe.getLocalization()); + } + + public PlaylistExtractor getPlaylistExtractor(ListLinkHandler linkHandler) throws ExtractionException { + return getPlaylistExtractor(linkHandler, NewPipe.getLocalization()); + } + + public StreamExtractor getStreamExtractor(LinkHandler linkHandler) throws ExtractionException { + return getStreamExtractor(linkHandler, NewPipe.getLocalization()); + } + + //////////////////////////////////////////// + // Extractor without link handler + //////////////////////////////////////////// + + public SearchExtractor getSearchExtractor(String query, + List contentFilter, + String sortFilter, + Localization localization) throws ExtractionException { + return getSearchExtractor(getSearchQHFactory() + .fromQuery(query, + contentFilter, + sortFilter), + localization); + } + + public ChannelExtractor getChannelExtractor(String id, + List contentFilter, + String sortFilter, + Localization localization) throws ExtractionException { + return getChannelExtractor(getChannelLHFactory().fromQuery(id, contentFilter, sortFilter), localization); + } + + public PlaylistExtractor getPlaylistExtractor(String id, + List contentFilter, + String sortFilter, + Localization localization) throws ExtractionException { + return getPlaylistExtractor(getPlaylistLHFactory() + .fromQuery(id, + contentFilter, + sortFilter), + localization); + } + + //////////////////////////////////////////// + // Short extractor without localization + //////////////////////////////////////////// + + public SearchExtractor getSearchExtractor(String query) throws ExtractionException { + return getSearchExtractor(getSearchQHFactory().fromQuery(query), NewPipe.getLocalization()); } public ChannelExtractor getChannelExtractor(String url) throws ExtractionException { - return getChannelExtractor(getChannelLHFactory().fromUrl(url)); + return getChannelExtractor(getChannelLHFactory().fromUrl(url), NewPipe.getLocalization()); } public PlaylistExtractor getPlaylistExtractor(String url) throws ExtractionException { - return getPlaylistExtractor(getPlaylistLHFactory().fromUrl(url)); + return getPlaylistExtractor(getPlaylistLHFactory().fromUrl(url), NewPipe.getLocalization()); } public StreamExtractor getStreamExtractor(String url) throws ExtractionException { - return getStreamExtractor(getStreamLHFactory().fromUrl(url)); + return getStreamExtractor(getStreamLHFactory().fromUrl(url), NewPipe.getLocalization()); } - /** * figure out where the link is pointing to (a channel, video, playlist, etc.) */ diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/SuggestionExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/SuggestionExtractor.java index d7c9cdca7..10147ea16 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/SuggestionExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/SuggestionExtractor.java @@ -1,6 +1,7 @@ package org.schabi.newpipe.extractor; import org.schabi.newpipe.extractor.exceptions.ExtractionException; +import org.schabi.newpipe.extractor.utils.Localization; import java.io.IOException; import java.util.List; @@ -28,14 +29,20 @@ import java.util.List; public abstract class SuggestionExtractor { private final int serviceId; + private final Localization localization; - public SuggestionExtractor(int serviceId) { + public SuggestionExtractor(int serviceId, Localization localization) { this.serviceId = serviceId; + this.localization = localization; } - public abstract List suggestionList(String query, String contentCountry) throws IOException, ExtractionException; + public abstract List suggestionList(String query) throws IOException, ExtractionException; public int getServiceId() { return serviceId; } + + protected Localization getLocalization() { + return localization; + } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java index a5895c19c..5b74826e6 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java @@ -5,6 +5,7 @@ import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; +import org.schabi.newpipe.extractor.utils.Localization; /* * Created by Christian Schabesberger on 25.07.16. @@ -28,8 +29,8 @@ import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; public abstract class ChannelExtractor extends ListExtractor { - public ChannelExtractor(StreamingService service, ListLinkHandler urlIdHandler) { - super(service, urlIdHandler); + public ChannelExtractor(StreamingService service, ListLinkHandler linkHandler, Localization localization) { + super(service, linkHandler, localization); } public abstract String getAvatarUrl() throws ParsingException; diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java index 11c80c86e..0aed6e118 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java @@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.utils.ExtractorHelper; +import org.schabi.newpipe.extractor.utils.Localization; import java.io.IOException; @@ -34,8 +35,8 @@ import java.io.IOException; public class ChannelInfo extends ListInfo { - public ChannelInfo(int serviceId, ListLinkHandler urlIdHandler, String name) throws ParsingException { - super(serviceId, urlIdHandler, name); + public ChannelInfo(int serviceId, ListLinkHandler linkHandler, String name) throws ParsingException { + super(serviceId, linkHandler, name); } public static ChannelInfo getInfo(String url) throws IOException, ExtractionException { @@ -48,7 +49,10 @@ public class ChannelInfo extends ListInfo { return getInfo(extractor); } - public static InfoItemsPage getMoreItems(StreamingService service, String url, String pageUrl) throws IOException, ExtractionException { + public static InfoItemsPage getMoreItems(StreamingService service, + String url, + String pageUrl, + Localization localization) throws IOException, ExtractionException { return service.getChannelExtractor(url).getPage(pageUrl); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskExtractor.java index c7c14dbf3..8c003b015 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskExtractor.java @@ -25,6 +25,7 @@ import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; +import org.schabi.newpipe.extractor.utils.Localization; import javax.annotation.Nonnull; @@ -33,9 +34,10 @@ public abstract class KioskExtractor extends ListExtractor { private final String id; public KioskExtractor(StreamingService streamingService, - ListLinkHandler urlIdHandler, - String kioskId) { - super(streamingService, urlIdHandler); + ListLinkHandler linkHandler, + String kioskId, + Localization localization) { + super(streamingService, linkHandler, localization); this.id = kioskId; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java index 95f0ed0e8..141b480cd 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskInfo.java @@ -31,8 +31,8 @@ import java.io.IOException; public class KioskInfo extends ListInfo { - private KioskInfo(int serviceId, ListLinkHandler urlIdHandler, String name) throws ParsingException { - super(serviceId, urlIdHandler, name); + private KioskInfo(int serviceId, ListLinkHandler linkHandler, String name) throws ParsingException { + super(serviceId, linkHandler, name); } public static ListExtractor.InfoItemsPage getMoreItems(StreamingService service, diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskList.java b/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskList.java index 83d60adc5..b37b7c04f 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskList.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskList.java @@ -4,6 +4,7 @@ import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory; import org.schabi.newpipe.extractor.exceptions.ExtractionException; +import org.schabi.newpipe.extractor.utils.Localization; import java.io.IOException; import java.util.HashMap; @@ -13,14 +14,16 @@ import java.util.Set; public class KioskList { public interface KioskExtractorFactory { KioskExtractor createNewKiosk(final StreamingService streamingService, - final String url, - final String kioskId) + final String url, + final String kioskId, + final Localization localization) throws ExtractionException, IOException; } private final int service_id; private final HashMap kioskList = new HashMap<>(); private String defaultKiosk = null; + private final Localization localization; private class KioskEntry { public KioskEntry(KioskExtractorFactory ef, ListLinkHandlerFactory h) { @@ -31,8 +34,9 @@ public class KioskList { final ListLinkHandlerFactory handlerFactory; } - public KioskList(int service_id) { + public KioskList(int service_id, Localization localization) { this.service_id = service_id; + this.localization = localization; } public void addKioskEntry(KioskExtractorFactory extractorFactory, ListLinkHandlerFactory handlerFactory, String id) @@ -73,7 +77,7 @@ public class KioskList { throw new ExtractionException("No kiosk found with the type: " + kioskId); } else { return ke.extractorFactory.createNewKiosk(NewPipe.getService(service_id), - ke.handlerFactory.fromId(kioskId).getUrl(), kioskId); + ke.handlerFactory.fromId(kioskId).getUrl(), kioskId, localization); } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java index cc511bc8e..cc3ae94c3 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java @@ -5,11 +5,12 @@ import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.stream.StreamInfoItem; +import org.schabi.newpipe.extractor.utils.Localization; public abstract class PlaylistExtractor extends ListExtractor { - public PlaylistExtractor(StreamingService service, ListLinkHandler urlIdHandler) { - super(service, urlIdHandler); + public PlaylistExtractor(StreamingService service, ListLinkHandler linkHandler, Localization localization) { + super(service, linkHandler, localization); } public abstract String getThumbnailUrl() throws ParsingException; diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java index f55662a26..e613c888b 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java @@ -9,13 +9,14 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.utils.ExtractorHelper; +import org.schabi.newpipe.extractor.utils.Localization; import java.io.IOException; public class PlaylistInfo extends ListInfo { - private PlaylistInfo(int serviceId, ListLinkHandler urlIdHandler, String name) throws ParsingException { - super(serviceId, urlIdHandler, name); + private PlaylistInfo(int serviceId, ListLinkHandler linkHandler, String name) throws ParsingException { + super(serviceId, linkHandler, name); } public static PlaylistInfo getInfo(String url) throws IOException, ExtractionException { @@ -28,7 +29,9 @@ public class PlaylistInfo extends ListInfo { return getInfo(extractor); } - public static InfoItemsPage getMoreItems(StreamingService service, String url, String pageUrl) throws IOException, ExtractionException { + public static InfoItemsPage getMoreItems(StreamingService service, + String url, + String pageUrl) throws IOException, ExtractionException { return service.getPlaylistExtractor(url).getPage(pageUrl); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchExtractor.java index f94c1325b..fce602a90 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchExtractor.java @@ -6,6 +6,7 @@ import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler; +import org.schabi.newpipe.extractor.utils.Localization; public abstract class SearchExtractor extends ListExtractor { @@ -16,12 +17,12 @@ public abstract class SearchExtractor extends ListExtractor { } private final InfoItemsSearchCollector collector; - private final String contentCountry; - public SearchExtractor(StreamingService service, SearchQueryHandler urlIdHandler, String contentCountry) { - super(service, urlIdHandler); + public SearchExtractor(StreamingService service, + SearchQueryHandler linkHandler, + Localization localization) { + super(service, linkHandler, localization); collector = new InfoItemsSearchCollector(service.getServiceId()); - this.contentCountry = contentCountry; } public String getSearchString() { @@ -43,8 +44,4 @@ public abstract class SearchExtractor extends ListExtractor { public String getName() { return getLinkHandler().getSearchString(); } - - protected String getContentCountry() { - return contentCountry; - } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java index 1ec1d7946..474c61090 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java @@ -7,6 +7,7 @@ import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler; import org.schabi.newpipe.extractor.utils.ExtractorHelper; +import org.schabi.newpipe.extractor.utils.Localization; import java.io.IOException; @@ -24,8 +25,8 @@ public class SearchInfo extends ListInfo { } - public static SearchInfo getInfo(StreamingService service, SearchQueryHandler searchQuery, String contentCountry) throws ExtractionException, IOException { - SearchExtractor extractor = service.getSearchExtractor(searchQuery, contentCountry); + public static SearchInfo getInfo(StreamingService service, SearchQueryHandler searchQuery) throws ExtractionException, IOException { + SearchExtractor extractor = service.getSearchExtractor(searchQuery); extractor.fetchPage(); return getInfo(extractor); } @@ -52,10 +53,9 @@ public class SearchInfo extends ListInfo { public static ListExtractor.InfoItemsPage getMoreItems(StreamingService service, SearchQueryHandler query, - String contentCountry, String pageUrl) throws IOException, ExtractionException { - return service.getSearchExtractor(query, contentCountry).getPage(pageUrl); + return service.getSearchExtractor(query).getPage(pageUrl); } // Getter diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractor.java index f2d6a0268..888432ef5 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractor.java @@ -12,6 +12,7 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; +import org.schabi.newpipe.extractor.utils.Localization; import javax.annotation.Nonnull; import java.io.IOException; @@ -24,8 +25,8 @@ public class SoundcloudChannelExtractor extends ChannelExtractor { private StreamInfoItemsCollector streamInfoItemsCollector = null; private String nextPageUrl = null; - public SoundcloudChannelExtractor(StreamingService service, ListLinkHandler urlIdHandler) { - super(service, urlIdHandler); + public SoundcloudChannelExtractor(StreamingService service, ListLinkHandler linkHandler, Localization localization) { + super(service, linkHandler, localization); } @Override diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractor.java index 93f043a62..8f02b1c68 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractor.java @@ -7,6 +7,7 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.kiosk.KioskExtractor; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; +import org.schabi.newpipe.extractor.utils.Localization; import javax.annotation.Nonnull; import java.io.IOException; @@ -17,8 +18,11 @@ public class SoundcloudChartsExtractor extends KioskExtractor { private StreamInfoItemsCollector collector = null; private String nextPageUrl = null; - public SoundcloudChartsExtractor(StreamingService service, ListLinkHandler urlIdHandler, String kioskId) { - super(service, urlIdHandler, kioskId); + public SoundcloudChartsExtractor(StreamingService service, + ListLinkHandler linkHandler, + String kioskId, + Localization localization) { + super(service, linkHandler, kioskId, localization); } @Override diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java index 9a3846e6b..e6d74b200 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java @@ -11,6 +11,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.playlist.PlaylistExtractor; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; +import org.schabi.newpipe.extractor.utils.Localization; import javax.annotation.Nonnull; import java.io.IOException; @@ -23,8 +24,8 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor { private StreamInfoItemsCollector streamInfoItemsCollector = null; private String nextPageUrl = null; - public SoundcloudPlaylistExtractor(StreamingService service, ListLinkHandler urlIdHandler) { - super(service, urlIdHandler); + public SoundcloudPlaylistExtractor(StreamingService service, ListLinkHandler linkHandler, Localization localization) { + super(service, linkHandler, localization); } @Override diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchExtractor.java index b2f4c8ad3..65d32ad29 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSearchExtractor.java @@ -10,6 +10,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.search.InfoItemsSearchCollector; import org.schabi.newpipe.extractor.search.SearchExtractor; import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler; +import org.schabi.newpipe.extractor.utils.Localization; import org.schabi.newpipe.extractor.utils.Parser; import javax.annotation.Nonnull; @@ -25,13 +26,13 @@ public class SoundcloudSearchExtractor extends SearchExtractor { private JsonArray searchCollection; public SoundcloudSearchExtractor(StreamingService service, - SearchQueryHandler urlIdHandler, - String contentCountry) { - super(service, urlIdHandler, contentCountry); + SearchQueryHandler linkHandler, + Localization localization) { + super(service, linkHandler, localization); } @Override - public String getSearchSuggestion() throws ParsingException { + public String getSearchSuggestion() { return null; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudService.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudService.java index c533b951e..c43d34ce2 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudService.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudService.java @@ -10,6 +10,7 @@ import org.schabi.newpipe.extractor.playlist.PlaylistExtractor; import org.schabi.newpipe.extractor.search.SearchExtractor; import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor; +import org.schabi.newpipe.extractor.utils.Localization; import static java.util.Collections.singletonList; import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.AUDIO; @@ -21,8 +22,8 @@ public class SoundcloudService extends StreamingService { } @Override - public SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler, String contentCountry) { - return new SoundcloudSearchExtractor(this, queryHandler, contentCountry); + public SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler, Localization localization) { + return new SoundcloudSearchExtractor(this, queryHandler, localization); } @Override @@ -47,39 +48,40 @@ public class SoundcloudService extends StreamingService { @Override - public StreamExtractor getStreamExtractor(LinkHandler LinkHandler) { - return new SoundcloudStreamExtractor(this, LinkHandler); + public StreamExtractor getStreamExtractor(LinkHandler LinkHandler, Localization localization) { + return new SoundcloudStreamExtractor(this, LinkHandler, localization); } @Override - public ChannelExtractor getChannelExtractor(ListLinkHandler urlIdHandler) { - return new SoundcloudChannelExtractor(this, urlIdHandler); + public ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler, Localization localization) { + return new SoundcloudChannelExtractor(this, linkHandler, localization); } @Override - public PlaylistExtractor getPlaylistExtractor(ListLinkHandler urlIdHandler) { - return new SoundcloudPlaylistExtractor(this, urlIdHandler); + public PlaylistExtractor getPlaylistExtractor(ListLinkHandler linkHandler, Localization localization) { + return new SoundcloudPlaylistExtractor(this, linkHandler, localization); } @Override - public SuggestionExtractor getSuggestionExtractor() { - return new SoundcloudSuggestionExtractor(getServiceId()); + public SuggestionExtractor getSuggestionExtractor(Localization localization) { + return new SoundcloudSuggestionExtractor(getServiceId(), localization); } @Override - public KioskList getKioskList() throws ExtractionException { + public KioskList getKioskList(Localization localization) throws ExtractionException { KioskList.KioskExtractorFactory chartsFactory = new KioskList.KioskExtractorFactory() { @Override public KioskExtractor createNewKiosk(StreamingService streamingService, String url, - String id) + String id, + Localization local) throws ExtractionException { return new SoundcloudChartsExtractor(SoundcloudService.this, - new SoundcloudChartsLinkHandlerFactory().fromUrl(url), id); + new SoundcloudChartsLinkHandlerFactory().fromUrl(url), id, local); } }; - KioskList list = new KioskList(getServiceId()); + KioskList list = new KioskList(getServiceId(), localization); // add kiosks here e.g.: final SoundcloudChartsLinkHandlerFactory h = new SoundcloudChartsLinkHandlerFactory(); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java index eaddc1149..f19f46c33 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java @@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.linkhandler.LinkHandler; import org.schabi.newpipe.extractor.stream.*; +import org.schabi.newpipe.extractor.utils.Localization; import javax.annotation.Nonnull; import java.io.IOException; @@ -21,8 +22,8 @@ import java.util.List; public class SoundcloudStreamExtractor extends StreamExtractor { private JsonObject track; - public SoundcloudStreamExtractor(StreamingService service, LinkHandler linkHandler) { - super(service, linkHandler); + public SoundcloudStreamExtractor(StreamingService service, LinkHandler linkHandler, Localization localization) { + super(service, linkHandler, localization); } @Override diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSuggestionExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSuggestionExtractor.java index 2a35b54d0..f982ae9a2 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSuggestionExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSuggestionExtractor.java @@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.SuggestionExtractor; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; +import org.schabi.newpipe.extractor.utils.Localization; import java.io.IOException; import java.net.URLEncoder; @@ -19,12 +20,12 @@ public class SoundcloudSuggestionExtractor extends SuggestionExtractor { public static final String CHARSET_UTF_8 = "UTF-8"; - public SoundcloudSuggestionExtractor(int serviceId) { - super(serviceId); + public SoundcloudSuggestionExtractor(int serviceId, Localization localization) { + super(serviceId, localization); } @Override - public List suggestionList(String query, String contentCountry) throws IOException, ExtractionException { + public List suggestionList(String query) throws IOException, ExtractionException { List suggestions = new ArrayList<>(); Downloader dl = NewPipe.getDownloader(); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java index 51a68f0b1..d9187ca4c 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java @@ -12,6 +12,7 @@ import org.schabi.newpipe.extractor.services.youtube.extractors.*; import org.schabi.newpipe.extractor.services.youtube.linkHandler.*; import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor; +import org.schabi.newpipe.extractor.utils.Localization; import static java.util.Arrays.asList; import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.*; @@ -44,8 +45,8 @@ public class YoutubeService extends StreamingService { } @Override - public SearchExtractor getSearchExtractor(SearchQueryHandler query, String contentCountry) { - return new YoutubeSearchExtractor(this, query, contentCountry); + public SearchExtractor getSearchExtractor(SearchQueryHandler query, Localization localization) { + return new YoutubeSearchExtractor(this, query, localization); } @Override @@ -69,37 +70,40 @@ public class YoutubeService extends StreamingService { } @Override - public StreamExtractor getStreamExtractor(LinkHandler linkHandler) throws ExtractionException { - return new YoutubeStreamExtractor(this, linkHandler); + public StreamExtractor getStreamExtractor(LinkHandler linkHandler, Localization localization) { + return new YoutubeStreamExtractor(this, linkHandler, localization); } @Override - public ChannelExtractor getChannelExtractor(ListLinkHandler urlIdHandler) throws ExtractionException { - return new YoutubeChannelExtractor(this, urlIdHandler); + public ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler, Localization localization) { + return new YoutubeChannelExtractor(this, linkHandler, localization); } @Override - public PlaylistExtractor getPlaylistExtractor(ListLinkHandler urlIdHandler) throws ExtractionException { - return new YoutubePlaylistExtractor(this, urlIdHandler); + public PlaylistExtractor getPlaylistExtractor(ListLinkHandler linkHandler, Localization localization) { + return new YoutubePlaylistExtractor(this, linkHandler, localization); } @Override - public SuggestionExtractor getSuggestionExtractor() { - return new YoutubeSuggestionExtractor(getServiceId()); + public SuggestionExtractor getSuggestionExtractor(Localization localization) { + return new YoutubeSuggestionExtractor(getServiceId(), localization); } @Override - public KioskList getKioskList() throws ExtractionException { - KioskList list = new KioskList(getServiceId()); + public KioskList getKioskList(final Localization localization) throws ExtractionException { + KioskList list = new KioskList(getServiceId(), localization); // add kiosks here e.g.: try { list.addKioskEntry(new KioskList.KioskExtractorFactory() { @Override - public KioskExtractor createNewKiosk(StreamingService streamingService, String url, String id) + public KioskExtractor createNewKiosk(StreamingService streamingService, + String url, + String id, + Localization local) throws ExtractionException { return new YoutubeTrendingExtractor(YoutubeService.this, - new YoutubeTrendingLinkHandlerFactory().fromUrl(url), id); + new YoutubeTrendingLinkHandlerFactory().fromUrl(url), id, local); } }, new YoutubeTrendingLinkHandlerFactory(), "Trending"); list.setDefaultKiosk("Trending"); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java index 9f9fc549b..b8a8c7bda 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java @@ -17,6 +17,7 @@ import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import org.schabi.newpipe.extractor.utils.DonationLinkHelper; +import org.schabi.newpipe.extractor.utils.Localization; import org.schabi.newpipe.extractor.utils.Parser; import org.schabi.newpipe.extractor.utils.Utils; @@ -51,8 +52,8 @@ public class YoutubeChannelExtractor extends ChannelExtractor { private Document doc; - public YoutubeChannelExtractor(StreamingService service, ListLinkHandler urlIdHandler) { - super(service, urlIdHandler); + public YoutubeChannelExtractor(StreamingService service, ListLinkHandler linkHandler, Localization localization) { + super(service, linkHandler, localization); } @Override diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubePlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubePlaylistExtractor.java index d20c39652..64517f907 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubePlaylistExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubePlaylistExtractor.java @@ -17,6 +17,7 @@ import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeParsingH import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import org.schabi.newpipe.extractor.stream.StreamType; +import org.schabi.newpipe.extractor.utils.Localization; import org.schabi.newpipe.extractor.utils.Utils; import javax.annotation.Nonnull; @@ -28,8 +29,8 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor { private Document doc; - public YoutubePlaylistExtractor(StreamingService service, ListLinkHandler urlIdHandler) throws ExtractionException { - super(service, urlIdHandler); + public YoutubePlaylistExtractor(StreamingService service, ListLinkHandler linkHandler, Localization localization) { + super(service, linkHandler, localization); } @Override diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSearchExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSearchExtractor.java index b74c948fc..1c1bad6b2 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSearchExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSearchExtractor.java @@ -11,6 +11,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.search.InfoItemsSearchCollector; import org.schabi.newpipe.extractor.search.SearchExtractor; import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler; +import org.schabi.newpipe.extractor.utils.Localization; import org.schabi.newpipe.extractor.utils.Parser; import javax.annotation.Nonnull; @@ -44,21 +45,21 @@ public class YoutubeSearchExtractor extends SearchExtractor { private Document doc; public YoutubeSearchExtractor(StreamingService service, - SearchQueryHandler urlIdHandler, - String contentCountry) { - super(service, urlIdHandler, contentCountry); + SearchQueryHandler linkHandler, + Localization localization) { + super(service, linkHandler, localization); } @Override public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException { final String site; final String url = getUrl(); - final String contentCountry = getContentCountry(); + final String contentCountry = getLocalization().getCountry(); //String url = builder.build().toString(); //if we've been passed a valid language code, append it to the URL if (!contentCountry.isEmpty()) { //assert Pattern.matches("[a-z]{2}(-([A-Z]{2}|[0-9]{1,3}))?", languageCode); - site = downloader.download(url, contentCountry); + site = downloader.download(url, getLocalization()); } else { site = downloader.download(url); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java index 28af223e8..cd67740aa 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java @@ -18,6 +18,7 @@ import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; import org.schabi.newpipe.extractor.linkhandler.LinkHandler; import org.schabi.newpipe.extractor.services.youtube.ItagItem; import org.schabi.newpipe.extractor.stream.*; +import org.schabi.newpipe.extractor.utils.Localization; import org.schabi.newpipe.extractor.utils.Parser; import org.schabi.newpipe.extractor.utils.Utils; @@ -87,8 +88,8 @@ public class YoutubeStreamExtractor extends StreamExtractor { private boolean isAgeRestricted; - public YoutubeStreamExtractor(StreamingService service, LinkHandler linkHandler) { - super(service, linkHandler); + public YoutubeStreamExtractor(StreamingService service, LinkHandler linkHandler, Localization localization) { + super(service, linkHandler, localization); } /*////////////////////////////////////////////////////////////////////////// diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSuggestionExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSuggestionExtractor.java index 5d77ab0c3..77a85c72a 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSuggestionExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSuggestionExtractor.java @@ -8,6 +8,7 @@ import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.SuggestionExtractor; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; +import org.schabi.newpipe.extractor.utils.Localization; import java.io.IOException; import java.net.URLEncoder; @@ -38,12 +39,12 @@ public class YoutubeSuggestionExtractor extends SuggestionExtractor { public static final String CHARSET_UTF_8 = "UTF-8"; - public YoutubeSuggestionExtractor(int serviceId) { - super(serviceId); + public YoutubeSuggestionExtractor(int serviceId, Localization localization) { + super(serviceId, localization); } @Override - public List suggestionList(String query, String contentCountry) throws IOException, ExtractionException { + public List suggestionList(String query) throws IOException, ExtractionException { Downloader dl = NewPipe.getDownloader(); List suggestions = new ArrayList<>(); @@ -51,7 +52,7 @@ public class YoutubeSuggestionExtractor extends SuggestionExtractor { + "?client=" + "youtube" //"firefox" for JSON, 'toolbar' for xml + "&jsonp=" + "JP" + "&ds=" + "yt" - + "&hl=" + URLEncoder.encode(contentCountry, CHARSET_UTF_8) + + "&hl=" + URLEncoder.encode(getLocalization().getCountry(), CHARSET_UTF_8) + "&q=" + URLEncoder.encode(query, CHARSET_UTF_8); String response = dl.download(url); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeTrendingExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeTrendingExtractor.java index b9cc118b1..9dd0a6371 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeTrendingExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeTrendingExtractor.java @@ -32,6 +32,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.kiosk.KioskExtractor; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; +import org.schabi.newpipe.extractor.utils.Localization; import javax.annotation.Nonnull; import java.io.IOException; @@ -41,9 +42,10 @@ public class YoutubeTrendingExtractor extends KioskExtractor { private Document doc; public YoutubeTrendingExtractor(StreamingService service, - ListLinkHandler urlIdHandler, - String kioskId) { - super(service, urlIdHandler, kioskId); + ListLinkHandler linkHandler, + String kioskId, + Localization localization) { + super(service, linkHandler, kioskId, localization); } @Override diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java index 765a9fae4..6071b2dc6 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java @@ -26,6 +26,7 @@ import org.schabi.newpipe.extractor.Subtitles; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.linkhandler.LinkHandler; +import org.schabi.newpipe.extractor.utils.Localization; import org.schabi.newpipe.extractor.utils.Parser; import javax.annotation.Nonnull; @@ -39,8 +40,8 @@ public abstract class StreamExtractor extends Extractor { public static final int NO_AGE_LIMIT = 0; - public StreamExtractor(StreamingService service, LinkHandler linkHandler) { - super(service, linkHandler); + public StreamExtractor(StreamingService service, LinkHandler linkHandler, Localization localization) { + super(service, linkHandler, localization); } @Nonnull diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java index b6da4076d..5ab2c2e83 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java @@ -5,6 +5,7 @@ import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.utils.DashMpdParser; import org.schabi.newpipe.extractor.utils.ExtractorHelper; +import org.schabi.newpipe.extractor.utils.Localization; import java.io.IOException; import java.util.ArrayList; diff --git a/extractor/src/test/java/org/schabi/newpipe/Downloader.java b/extractor/src/test/java/org/schabi/newpipe/Downloader.java index e3bb6f68c..f9f35c21a 100644 --- a/extractor/src/test/java/org/schabi/newpipe/Downloader.java +++ b/extractor/src/test/java/org/schabi/newpipe/Downloader.java @@ -1,6 +1,7 @@ package org.schabi.newpipe; import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; +import org.schabi.newpipe.extractor.utils.Localization; import javax.net.ssl.HttpsURLConnection; import java.io.BufferedReader; @@ -66,12 +67,12 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader { * but set the HTTP header field "Accept-Language" to the supplied string. * * @param siteUrl the URL of the text file to return the contents of - * @param language the language (usually a 2-character code) to set as the preferred language + * @param localization the language and country (usually a 2-character code for both values) * @return the contents of the specified text file */ - public String download(String siteUrl, String language) throws IOException, ReCaptchaException { + public String download(String siteUrl, Localization localization) throws IOException, ReCaptchaException { Map requestProperties = new HashMap<>(); - requestProperties.put("Accept-Language", language); + requestProperties.put("Accept-Language", localization.getLanguage()); return download(siteUrl, requestProperties); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java index 30884adcb..a5884de91 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelExtractorTest.java @@ -7,6 +7,7 @@ import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.channel.ChannelExtractor; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest; +import org.schabi.newpipe.extractor.utils.Localization; import static org.junit.Assert.*; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty; @@ -23,7 +24,7 @@ public class SoundcloudChannelExtractorTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (SoundcloudChannelExtractor) SoundCloud .getChannelExtractor("http://soundcloud.com/liluzivert/sets"); extractor.fetchPage(); @@ -107,7 +108,7 @@ public class SoundcloudChannelExtractorTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (SoundcloudChannelExtractor) SoundCloud .getChannelExtractor("https://soundcloud.com/dubmatix"); extractor.fetchPage(); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractorTest.java index b7c640f50..8e93f5241 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsExtractorTest.java @@ -8,6 +8,7 @@ import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.kiosk.KioskExtractor; import org.schabi.newpipe.extractor.stream.StreamInfoItem; +import org.schabi.newpipe.extractor.utils.Localization; import java.util.List; @@ -23,7 +24,7 @@ public class SoundcloudChartsExtractorTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = SoundCloud .getKioskList() .getExtractorById("Top 50", null); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsLinkHandlerFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsLinkHandlerFactoryTest.java index 10066d597..99c473bcc 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsLinkHandlerFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChartsLinkHandlerFactoryTest.java @@ -5,6 +5,7 @@ import org.junit.Test; import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ParsingException; +import org.schabi.newpipe.extractor.utils.Localization; import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertEquals; @@ -14,37 +15,37 @@ import static org.junit.Assert.assertTrue; * Test for {@link SoundcloudChartsLinkHandlerFactory} */ public class SoundcloudChartsLinkHandlerFactoryTest { - private static SoundcloudChartsLinkHandlerFactory urlIdHandler; + private static SoundcloudChartsLinkHandlerFactory linkHandler; @BeforeClass - public static void setUp() throws Exception { - urlIdHandler = new SoundcloudChartsLinkHandlerFactory(); - NewPipe.init(Downloader.getInstance()); + public static void setUp() { + linkHandler = new SoundcloudChartsLinkHandlerFactory(); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); } @Test public void getUrl() throws Exception { - assertEquals(urlIdHandler.fromId("Top 50").getUrl(), "https://soundcloud.com/charts/top"); - assertEquals(urlIdHandler.fromId("New & hot").getUrl(), "https://soundcloud.com/charts/new"); + assertEquals(linkHandler.fromId("Top 50").getUrl(), "https://soundcloud.com/charts/top"); + assertEquals(linkHandler.fromId("New & hot").getUrl(), "https://soundcloud.com/charts/new"); } @Test public void getId() throws ParsingException { - assertEquals(urlIdHandler.fromUrl("http://soundcloud.com/charts/top?genre=all-music").getId(), "Top 50"); - assertEquals(urlIdHandler.fromUrl("HTTP://www.soundcloud.com/charts/new/?genre=all-music&country=all-countries").getId(), "New & hot"); + assertEquals(linkHandler.fromUrl("http://soundcloud.com/charts/top?genre=all-music").getId(), "Top 50"); + assertEquals(linkHandler.fromUrl("HTTP://www.soundcloud.com/charts/new/?genre=all-music&country=all-countries").getId(), "New & hot"); } @Test public void acceptUrl() throws ParsingException { - assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/charts")); - assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/charts/")); - assertTrue(urlIdHandler.acceptUrl("https://www.soundcloud.com/charts/new")); - assertTrue(urlIdHandler.acceptUrl("http://soundcloud.com/charts/top?genre=all-music")); - assertTrue(urlIdHandler.acceptUrl("HTTP://www.soundcloud.com/charts/new/?genre=all-music&country=all-countries")); + assertTrue(linkHandler.acceptUrl("https://soundcloud.com/charts")); + assertTrue(linkHandler.acceptUrl("https://soundcloud.com/charts/")); + assertTrue(linkHandler.acceptUrl("https://www.soundcloud.com/charts/new")); + assertTrue(linkHandler.acceptUrl("http://soundcloud.com/charts/top?genre=all-music")); + assertTrue(linkHandler.acceptUrl("HTTP://www.soundcloud.com/charts/new/?genre=all-music&country=all-countries")); - assertFalse(urlIdHandler.acceptUrl("kdskjfiiejfia")); - assertFalse(urlIdHandler.acceptUrl("soundcloud.com/charts askjkf")); - assertFalse(urlIdHandler.acceptUrl(" soundcloud.com/charts")); - assertFalse(urlIdHandler.acceptUrl("")); + assertFalse(linkHandler.acceptUrl("kdskjfiiejfia")); + assertFalse(linkHandler.acceptUrl("soundcloud.com/charts askjkf")); + assertFalse(linkHandler.acceptUrl(" soundcloud.com/charts")); + assertFalse(linkHandler.acceptUrl("")); } } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelperTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelperTest.java index 1e38d2acf..b1771f068 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelperTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelperTest.java @@ -5,11 +5,12 @@ import org.junit.BeforeClass; import org.junit.Test; import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.NewPipe; +import org.schabi.newpipe.extractor.utils.Localization; public class SoundcloudParsingHelperTest { @BeforeClass public static void setUp() { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); } @Test diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractorTest.java index 29bf4d177..c014b3417 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractorTest.java @@ -10,6 +10,7 @@ import org.schabi.newpipe.extractor.ServiceList; import org.schabi.newpipe.extractor.playlist.PlaylistExtractor; import org.schabi.newpipe.extractor.services.BasePlaylistExtractorTest; import org.schabi.newpipe.extractor.stream.StreamInfoItem; +import org.schabi.newpipe.extractor.utils.Localization; import static org.junit.Assert.*; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl; @@ -25,7 +26,7 @@ public class SoundcloudPlaylistExtractorTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (SoundcloudPlaylistExtractor) SoundCloud .getPlaylistExtractor("https://soundcloud.com/liluzivert/sets/the-perfect-luv-tape-r?test=123"); extractor.fetchPage(); @@ -123,7 +124,7 @@ public class SoundcloudPlaylistExtractorTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (SoundcloudPlaylistExtractor) SoundCloud .getPlaylistExtractor("https://soundcloud.com/hunter-leader/sets/house-electro-dance-music-2"); extractor.fetchPage(); @@ -215,7 +216,7 @@ public class SoundcloudPlaylistExtractorTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (SoundcloudPlaylistExtractor) SoundCloud .getPlaylistExtractor("https://soundcloud.com/user350509423/sets/edm-xxx"); extractor.fetchPage(); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorDefaultTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorDefaultTest.java index a637d3803..b6c5b3a2b 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorDefaultTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorDefaultTest.java @@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; import org.schabi.newpipe.extractor.stream.StreamType; +import org.schabi.newpipe.extractor.utils.Localization; import java.io.IOException; @@ -24,7 +25,7 @@ public class SoundcloudStreamExtractorDefaultTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (SoundcloudStreamExtractor) SoundCloud.getStreamExtractor("https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon"); extractor.fetchPage(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamLinkHandlerFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamLinkHandlerFactoryTest.java index c2acd423b..65b09e9b0 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamLinkHandlerFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamLinkHandlerFactoryTest.java @@ -5,6 +5,7 @@ import org.junit.Test; import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ParsingException; +import org.schabi.newpipe.extractor.utils.Localization; import java.util.ArrayList; import java.util.List; @@ -15,17 +16,17 @@ import static org.junit.Assert.*; * Test for {@link SoundcloudStreamLinkHandlerFactory} */ public class SoundcloudStreamLinkHandlerFactoryTest { - private static SoundcloudStreamLinkHandlerFactory urlIdHandler; + private static SoundcloudStreamLinkHandlerFactory linkHandler; @BeforeClass public static void setUp() throws Exception { - urlIdHandler = SoundcloudStreamLinkHandlerFactory.getInstance(); - NewPipe.init(Downloader.getInstance()); + linkHandler = SoundcloudStreamLinkHandlerFactory.getInstance(); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); } @Test(expected = IllegalArgumentException.class) public void getIdWithNullAsUrl() throws ParsingException { - urlIdHandler.fromUrl(null).getId(); + linkHandler.fromUrl(null).getId(); } @Test @@ -37,7 +38,7 @@ public class SoundcloudStreamLinkHandlerFactoryTest { for (String invalidUrl : invalidUrls) { Throwable exception = null; try { - urlIdHandler.fromUrl(invalidUrl).getId(); + linkHandler.fromUrl(invalidUrl).getId(); } catch (ParsingException e) { exception = e; } @@ -49,30 +50,30 @@ public class SoundcloudStreamLinkHandlerFactoryTest { @Test public void getId() throws Exception { - assertEquals("309689103", urlIdHandler.fromUrl("https://soundcloud.com/liluzivert/15-ysl").getId()); - assertEquals("309689082", urlIdHandler.fromUrl("https://www.soundcloud.com/liluzivert/15-luv-scars-ko").getId()); - assertEquals("309689035", urlIdHandler.fromUrl("http://soundcloud.com/liluzivert/15-boring-shit").getId()); - assertEquals("294488599", urlIdHandler.fromUrl("http://www.soundcloud.com/liluzivert/secure-the-bag-produced-by-glohan-beats").getId()); - assertEquals("294488438", urlIdHandler.fromUrl("HtTpS://sOuNdClOuD.cOm/LiLuZiVeRt/In-O4-pRoDuCeD-bY-dP-bEaTz").getId()); - assertEquals("294488147", urlIdHandler.fromUrl("https://soundcloud.com/liluzivert/fresh-produced-by-zaytoven#t=69").getId()); - assertEquals("294487876", urlIdHandler.fromUrl("https://soundcloud.com/liluzivert/threesome-produced-by-zaytoven#t=1:09").getId()); - assertEquals("294487684", urlIdHandler.fromUrl("https://soundcloud.com/liluzivert/blonde-brigitte-produced-manny-fresh#t=1:9").getId()); - assertEquals("294487428", urlIdHandler.fromUrl("https://soundcloud.com/liluzivert/today-produced-by-c-note#t=1m9s").getId()); - assertEquals("294487157", urlIdHandler.fromUrl("https://soundcloud.com/liluzivert/changed-my-phone-produced-by-c-note#t=1m09s").getId()); + assertEquals("309689103", linkHandler.fromUrl("https://soundcloud.com/liluzivert/15-ysl").getId()); + assertEquals("309689082", linkHandler.fromUrl("https://www.soundcloud.com/liluzivert/15-luv-scars-ko").getId()); + assertEquals("309689035", linkHandler.fromUrl("http://soundcloud.com/liluzivert/15-boring-shit").getId()); + assertEquals("294488599", linkHandler.fromUrl("http://www.soundcloud.com/liluzivert/secure-the-bag-produced-by-glohan-beats").getId()); + assertEquals("294488438", linkHandler.fromUrl("HtTpS://sOuNdClOuD.cOm/LiLuZiVeRt/In-O4-pRoDuCeD-bY-dP-bEaTz").getId()); + assertEquals("294488147", linkHandler.fromUrl("https://soundcloud.com/liluzivert/fresh-produced-by-zaytoven#t=69").getId()); + assertEquals("294487876", linkHandler.fromUrl("https://soundcloud.com/liluzivert/threesome-produced-by-zaytoven#t=1:09").getId()); + assertEquals("294487684", linkHandler.fromUrl("https://soundcloud.com/liluzivert/blonde-brigitte-produced-manny-fresh#t=1:9").getId()); + assertEquals("294487428", linkHandler.fromUrl("https://soundcloud.com/liluzivert/today-produced-by-c-note#t=1m9s").getId()); + assertEquals("294487157", linkHandler.fromUrl("https://soundcloud.com/liluzivert/changed-my-phone-produced-by-c-note#t=1m09s").getId()); } @Test public void testAcceptUrl() throws ParsingException { - assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/liluzivert/15-ysl")); - assertTrue(urlIdHandler.acceptUrl("https://www.soundcloud.com/liluzivert/15-luv-scars-ko")); - assertTrue(urlIdHandler.acceptUrl("http://soundcloud.com/liluzivert/15-boring-shit")); - assertTrue(urlIdHandler.acceptUrl("http://www.soundcloud.com/liluzivert/secure-the-bag-produced-by-glohan-beats")); - assertTrue(urlIdHandler.acceptUrl("HtTpS://sOuNdClOuD.cOm/LiLuZiVeRt/In-O4-pRoDuCeD-bY-dP-bEaTz")); - assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/liluzivert/fresh-produced-by-zaytoven#t=69")); - assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/liluzivert/threesome-produced-by-zaytoven#t=1:09")); - assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/liluzivert/blonde-brigitte-produced-manny-fresh#t=1:9")); - assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/liluzivert/today-produced-by-c-note#t=1m9s")); - assertTrue(urlIdHandler.acceptUrl("https://soundcloud.com/liluzivert/changed-my-phone-produced-by-c-note#t=1m09s")); + assertTrue(linkHandler.acceptUrl("https://soundcloud.com/liluzivert/15-ysl")); + assertTrue(linkHandler.acceptUrl("https://www.soundcloud.com/liluzivert/15-luv-scars-ko")); + assertTrue(linkHandler.acceptUrl("http://soundcloud.com/liluzivert/15-boring-shit")); + assertTrue(linkHandler.acceptUrl("http://www.soundcloud.com/liluzivert/secure-the-bag-produced-by-glohan-beats")); + assertTrue(linkHandler.acceptUrl("HtTpS://sOuNdClOuD.cOm/LiLuZiVeRt/In-O4-pRoDuCeD-bY-dP-bEaTz")); + assertTrue(linkHandler.acceptUrl("https://soundcloud.com/liluzivert/fresh-produced-by-zaytoven#t=69")); + assertTrue(linkHandler.acceptUrl("https://soundcloud.com/liluzivert/threesome-produced-by-zaytoven#t=1:09")); + assertTrue(linkHandler.acceptUrl("https://soundcloud.com/liluzivert/blonde-brigitte-produced-manny-fresh#t=1:9")); + assertTrue(linkHandler.acceptUrl("https://soundcloud.com/liluzivert/today-produced-by-c-note#t=1m9s")); + assertTrue(linkHandler.acceptUrl("https://soundcloud.com/liluzivert/changed-my-phone-produced-by-c-note#t=1m09s")); } } \ No newline at end of file diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSubscriptionExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSubscriptionExtractorTest.java index d0000a559..ec5f84edb 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSubscriptionExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSubscriptionExtractorTest.java @@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor; import org.schabi.newpipe.extractor.subscription.SubscriptionItem; +import org.schabi.newpipe.extractor.utils.Localization; import java.io.IOException; import java.util.Arrays; @@ -25,7 +26,7 @@ public class SoundcloudSubscriptionExtractorTest { @BeforeClass public static void setupClass() { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); subscriptionExtractor = new SoundcloudSubscriptionExtractor(ServiceList.SoundCloud); urlHandler = ServiceList.SoundCloud.getChannelLHFactory(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSuggestionExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSuggestionExtractorTest.java index b4ab8dbcb..e1505917d 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSuggestionExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudSuggestionExtractorTest.java @@ -6,6 +6,7 @@ import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.SuggestionExtractor; import org.schabi.newpipe.extractor.exceptions.ExtractionException; +import org.schabi.newpipe.extractor.utils.Localization; import java.io.IOException; @@ -19,13 +20,13 @@ public class SoundcloudSuggestionExtractorTest { private static SuggestionExtractor suggestionExtractor; @BeforeClass - public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + public static void setUp() { + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); suggestionExtractor = SoundCloud.getSuggestionExtractor(); } @Test public void testIfSuggestions() throws IOException, ExtractionException { - assertFalse(suggestionExtractor.suggestionList("lil uzi vert", "de").isEmpty()); + assertFalse(suggestionExtractor.suggestionList("lil uzi vert").isEmpty()); } } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/search/SoundcloudSearchExtractorChannelOnlyTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/search/SoundcloudSearchExtractorChannelOnlyTest.java index 3dc1e4835..386fa9160 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/search/SoundcloudSearchExtractorChannelOnlyTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/search/SoundcloudSearchExtractorChannelOnlyTest.java @@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.channel.ChannelInfoItem; import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchExtractor; import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchQueryHandlerFactory; +import org.schabi.newpipe.extractor.utils.Localization; import static java.util.Arrays.asList; import static org.junit.Assert.*; @@ -18,9 +19,9 @@ public class SoundcloudSearchExtractorChannelOnlyTest extends SoundcloudSearchEx @BeforeClass public static void setUpClass() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("DE", "de")); extractor = (SoundcloudSearchExtractor) SoundCloud.getSearchExtractor("lill uzi vert", - asList(SoundcloudSearchQueryHandlerFactory.USERS), null, "de"); + asList(SoundcloudSearchQueryHandlerFactory.USERS), null, new Localization("DE", "de")); extractor.fetchPage(); itemsPage = extractor.getInitialPage(); } @@ -28,7 +29,7 @@ public class SoundcloudSearchExtractorChannelOnlyTest extends SoundcloudSearchEx @Test public void testGetSecondPage() throws Exception { SoundcloudSearchExtractor secondExtractor = (SoundcloudSearchExtractor) SoundCloud.getSearchExtractor("lill uzi vert", - asList(SoundcloudSearchQueryHandlerFactory.USERS), null, "de"); + asList(SoundcloudSearchQueryHandlerFactory.USERS), null, new Localization("DE", "de")); ListExtractor.InfoItemsPage secondPage = secondExtractor.getPage(itemsPage.getNextPageUrl()); assertTrue(Integer.toString(secondPage.getItems().size()), secondPage.getItems().size() >= 3); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/search/SoundcloudSearchExtractorDefaultTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/search/SoundcloudSearchExtractorDefaultTest.java index 81329bd0a..683a15c55 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/search/SoundcloudSearchExtractorDefaultTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/search/SoundcloudSearchExtractorDefaultTest.java @@ -10,6 +10,7 @@ import org.schabi.newpipe.extractor.channel.ChannelInfoItem; import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudSearchExtractor; import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor; import org.schabi.newpipe.extractor.stream.StreamInfoItem; +import org.schabi.newpipe.extractor.utils.Localization; import static org.junit.Assert.*; import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; @@ -42,8 +43,8 @@ public class SoundcloudSearchExtractorDefaultTest extends SoundcloudSearchExtrac @BeforeClass public static void setUpClass() throws Exception { - NewPipe.init(Downloader.getInstance()); - extractor = (SoundcloudSearchExtractor) SoundCloud.getSearchExtractor("lill uzi vert", "de"); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); + extractor = (SoundcloudSearchExtractor) SoundCloud.getSearchExtractor("lill uzi vert"); extractor.fetchPage(); itemsPage = extractor.getInitialPage(); } @@ -76,7 +77,8 @@ public class SoundcloudSearchExtractorDefaultTest extends SoundcloudSearchExtrac @Test public void testGetSecondPage() throws Exception { - SoundcloudSearchExtractor secondExtractor = (SoundcloudSearchExtractor) SoundCloud.getSearchExtractor("lill uzi vert", "de"); + SoundcloudSearchExtractor secondExtractor = + (SoundcloudSearchExtractor) SoundCloud.getSearchExtractor("lill uzi vert"); ListExtractor.InfoItemsPage secondPage = secondExtractor.getPage(itemsPage.getNextPageUrl()); assertTrue(Integer.toString(secondPage.getItems().size()), secondPage.getItems().size() >= 10); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/search/SoundcloudSearchQHTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/search/SoundcloudSearchQHTest.java index 5282ccad6..b0f02b5b7 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/search/SoundcloudSearchQHTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/search/SoundcloudSearchQHTest.java @@ -4,6 +4,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.NewPipe; +import org.schabi.newpipe.extractor.utils.Localization; import static java.util.Arrays.asList; import static org.junit.Assert.assertEquals; @@ -16,7 +17,7 @@ public class SoundcloudSearchQHTest { @BeforeClass public static void setUpClass() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); } private static String removeClientId(String url) { 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 22ec1dd04..622514416 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 @@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.channel.ChannelExtractor; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest; import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelExtractor; +import org.schabi.newpipe.extractor.utils.Localization; import static org.junit.Assert.*; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl; @@ -24,7 +25,7 @@ public class YoutubeChannelExtractorTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (YoutubeChannelExtractor) YouTube .getChannelExtractor("http://www.youtube.com/user/Gronkh"); extractor.fetchPage(); @@ -120,7 +121,7 @@ public class YoutubeChannelExtractorTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (YoutubeChannelExtractor) YouTube .getChannelExtractor("https://www.youtube.com/user/Vsauce"); extractor.fetchPage(); @@ -216,7 +217,7 @@ public class YoutubeChannelExtractorTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (YoutubeChannelExtractor) YouTube .getChannelExtractor("https://www.youtube.com/channel/UCsXVk37bltHxD1rDPwtNM8Q"); extractor.fetchPage(); @@ -323,7 +324,7 @@ public class YoutubeChannelExtractorTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (YoutubeChannelExtractor) YouTube .getChannelExtractor("https://www.youtube.com/user/CaptainDisillusion/videos"); extractor.fetchPage(); @@ -412,7 +413,7 @@ public class YoutubeChannelExtractorTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); 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/YoutubeChannelLinkHandlerFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelLinkHandlerFactoryTest.java index ccb8b4256..ba858bbc1 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelLinkHandlerFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelLinkHandlerFactoryTest.java @@ -6,6 +6,7 @@ import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelLinkHandlerFactory; +import org.schabi.newpipe.extractor.utils.Localization; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -15,42 +16,42 @@ import static org.junit.Assert.assertTrue; */ public class YoutubeChannelLinkHandlerFactoryTest { - private static YoutubeChannelLinkHandlerFactory urlIdHandler; + private static YoutubeChannelLinkHandlerFactory linkHandler; @BeforeClass public static void setUp() { - urlIdHandler = YoutubeChannelLinkHandlerFactory.getInstance(); - NewPipe.init(Downloader.getInstance()); + linkHandler = YoutubeChannelLinkHandlerFactory.getInstance(); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); } @Test public void acceptrUrlTest() throws ParsingException { - assertTrue(urlIdHandler.acceptUrl("https://www.youtube.com/user/Gronkh")); - assertTrue(urlIdHandler.acceptUrl("https://www.youtube.com/user/Netzkino/videos")); + assertTrue(linkHandler.acceptUrl("https://www.youtube.com/user/Gronkh")); + assertTrue(linkHandler.acceptUrl("https://www.youtube.com/user/Netzkino/videos")); - assertTrue(urlIdHandler.acceptUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA")); - assertTrue(urlIdHandler.acceptUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1")); + assertTrue(linkHandler.acceptUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA")); + assertTrue(linkHandler.acceptUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1")); - assertTrue(urlIdHandler.acceptUrl("https://hooktube.com/user/Gronkh")); - assertTrue(urlIdHandler.acceptUrl("https://hooktube.com/user/Netzkino/videos")); + assertTrue(linkHandler.acceptUrl("https://hooktube.com/user/Gronkh")); + assertTrue(linkHandler.acceptUrl("https://hooktube.com/user/Netzkino/videos")); - assertTrue(urlIdHandler.acceptUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA")); - assertTrue(urlIdHandler.acceptUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1")); + assertTrue(linkHandler.acceptUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA")); + assertTrue(linkHandler.acceptUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1")); } @Test public void getIdFromUrl() throws ParsingException { - assertEquals("user/Gronkh", urlIdHandler.fromUrl("https://www.youtube.com/user/Gronkh").getId()); - assertEquals("user/Netzkino", urlIdHandler.fromUrl("https://www.youtube.com/user/Netzkino/videos").getId()); + assertEquals("user/Gronkh", linkHandler.fromUrl("https://www.youtube.com/user/Gronkh").getId()); + assertEquals("user/Netzkino", linkHandler.fromUrl("https://www.youtube.com/user/Netzkino/videos").getId()); - assertEquals("channel/UClq42foiSgl7sSpLupnugGA", urlIdHandler.fromUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA").getId()); - assertEquals("channel/UClq42foiSgl7sSpLupnugGA", urlIdHandler.fromUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1").getId()); + assertEquals("channel/UClq42foiSgl7sSpLupnugGA", linkHandler.fromUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA").getId()); + assertEquals("channel/UClq42foiSgl7sSpLupnugGA", linkHandler.fromUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1").getId()); - assertEquals("user/Gronkh", urlIdHandler.fromUrl("https://hooktube.com/user/Gronkh").getId()); - assertEquals("user/Netzkino", urlIdHandler.fromUrl("https://hooktube.com/user/Netzkino/videos").getId()); + assertEquals("user/Gronkh", linkHandler.fromUrl("https://hooktube.com/user/Gronkh").getId()); + assertEquals("user/Netzkino", linkHandler.fromUrl("https://hooktube.com/user/Netzkino/videos").getId()); - assertEquals("channel/UClq42foiSgl7sSpLupnugGA", urlIdHandler.fromUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA").getId()); - assertEquals("channel/UClq42foiSgl7sSpLupnugGA", urlIdHandler.fromUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1").getId()); + assertEquals("channel/UClq42foiSgl7sSpLupnugGA", linkHandler.fromUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA").getId()); + assertEquals("channel/UClq42foiSgl7sSpLupnugGA", linkHandler.fromUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1").getId()); } } 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 e89db1ffc..1cb6388a2 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 @@ -12,6 +12,7 @@ import org.schabi.newpipe.extractor.playlist.PlaylistExtractor; import org.schabi.newpipe.extractor.services.BasePlaylistExtractorTest; import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubePlaylistExtractor; import org.schabi.newpipe.extractor.stream.StreamInfoItem; +import org.schabi.newpipe.extractor.utils.Localization; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -28,7 +29,7 @@ public class YoutubePlaylistExtractorTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (YoutubePlaylistExtractor) YouTube .getPlaylistExtractor("http://www.youtube.com/watch?v=lp-EO5I60KA&list=PLMC9KNkIncKtPzgY-5rmhvj7fax8fdxoj"); extractor.fetchPage(); @@ -125,7 +126,7 @@ public class YoutubePlaylistExtractorTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (YoutubePlaylistExtractor) YouTube .getPlaylistExtractor("https://www.youtube.com/watch?v=8SbUC-UaAxE&list=PLWwAypAcFRgKAIIFqBr9oy-ZYZnixa_Fj"); extractor.fetchPage(); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeServiceTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeServiceTest.java index eef37f485..d90a351c3 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeServiceTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeServiceTest.java @@ -26,6 +26,7 @@ import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.kiosk.KioskList; +import org.schabi.newpipe.extractor.utils.Localization; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -40,7 +41,7 @@ public class YoutubeServiceTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); service = YouTube; kioskList = service.getKioskList(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorAgeRestrictedTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorAgeRestrictedTest.java index 50e1fba56..ec8b495ff 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorAgeRestrictedTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorAgeRestrictedTest.java @@ -12,6 +12,7 @@ import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLi import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.stream.SubtitlesFormat; import org.schabi.newpipe.extractor.stream.VideoStream; +import org.schabi.newpipe.extractor.utils.Localization; import java.io.IOException; import java.util.ArrayList; @@ -30,7 +31,7 @@ public class YoutubeStreamExtractorAgeRestrictedTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (YoutubeStreamExtractor) YouTube .getStreamExtractor("https://www.youtube.com/watch?v=MmBeUZqv1QA"); extractor.fetchPage(); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorControversialTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorControversialTest.java index 42ca746fc..a5ac490e0 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorControversialTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorControversialTest.java @@ -12,6 +12,7 @@ import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLi import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.stream.SubtitlesFormat; import org.schabi.newpipe.extractor.stream.VideoStream; +import org.schabi.newpipe.extractor.utils.Localization; import java.io.IOException; import java.util.ArrayList; @@ -29,7 +30,7 @@ public class YoutubeStreamExtractorControversialTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (YoutubeStreamExtractor) YouTube .getStreamExtractor("https://www.youtube.com/watch?v=T4XJQO3qol8"); extractor.fetchPage(); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDASHTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDASHTest.java index 073df2a3d..0d4013e9b 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDASHTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDASHTest.java @@ -27,6 +27,7 @@ import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.stream.StreamExtractor; import org.schabi.newpipe.extractor.stream.StreamInfo; +import org.schabi.newpipe.extractor.utils.Localization; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -40,7 +41,7 @@ public class YoutubeStreamExtractorDASHTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); info = StreamInfo.getInfo(YouTube, "https://www.youtube.com/watch?v=00Q4SUnVQK4"); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java index 2b5f6058c..65a787361 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java @@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor; import org.schabi.newpipe.extractor.stream.*; import org.schabi.newpipe.extractor.utils.DashMpdParser; +import org.schabi.newpipe.extractor.utils.Localization; import org.schabi.newpipe.extractor.utils.Utils; import java.io.IOException; @@ -48,7 +49,7 @@ public class YoutubeStreamExtractorDefaultTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (YoutubeStreamExtractor) YouTube .getStreamExtractor("https://www.youtube.com/watch?v=rYEDA3JcQqw"); extractor.fetchPage(); @@ -174,7 +175,7 @@ public class YoutubeStreamExtractorDefaultTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (YoutubeStreamExtractor) YouTube .getStreamExtractor("https://www.youtube.com/watch?v=dJY8iT341F4"); extractor.fetchPage(); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamLinkHandlerFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamLinkHandlerFactoryTest.java index fdcbeca0e..519eb0efb 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamLinkHandlerFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamLinkHandlerFactoryTest.java @@ -7,6 +7,7 @@ import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.FoundAdException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLinkHandlerFactory; +import org.schabi.newpipe.extractor.utils.Localization; import java.util.ArrayList; import java.util.List; @@ -18,22 +19,22 @@ import static org.junit.Assert.*; */ public class YoutubeStreamLinkHandlerFactoryTest { private static String AD_URL = "https://googleads.g.doubleclick.net/aclk?sa=l&ai=C-2IPgeVTWPf4GcOStgfOnIOADf78n61GvKmmobYDrgIQASDj-5MDKAJg9ZXOgeAEoAGgy_T-A8gBAakC2gkpmquIsT6oAwGqBJMBT9BgD5kVgbN0dX602bFFaDw9vsxq-We-S8VkrXVBi6W_e7brZ36GCz1WO3EPEeklYuJjXLUowwCOKsd-8xr1UlS_tusuFJv9iX35xoBHKTRvs8-0aDbfEIm6in37QDfFuZjqgEMB8-tg0Jn_Pf1RU5OzbuU40B4Gy25NUTnOxhDKthOhKBUSZEksCEerUV8GMu10iAXCxquwApIFBggDEAEYAaAGGsgGlIjthrUDgAfItIsBqAemvhvYBwHSCAUIgGEQAbgT6AE&num=1&sig=AOD64_1DybDd4qAm5O7o9UAbTNRdqXXHFQ&ctype=21&video_id=dMO_IXYPZew&client=ca-pub-6219811747049371&adurl=http://www.youtube.com/watch%3Fv%3DdMO_IXYPZew"; - private static YoutubeStreamLinkHandlerFactory urlIdHandler; + private static YoutubeStreamLinkHandlerFactory linkHandler; @BeforeClass public static void setUp() { - urlIdHandler = YoutubeStreamLinkHandlerFactory.getInstance(); - NewPipe.init(Downloader.getInstance()); + linkHandler = YoutubeStreamLinkHandlerFactory.getInstance(); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); } @Test(expected = IllegalArgumentException.class) public void getIdWithNullAsUrl() throws ParsingException { - urlIdHandler.fromId(null); + linkHandler.fromId(null); } @Test(expected = FoundAdException.class) public void getIdForAd() throws ParsingException { - urlIdHandler.fromUrl(AD_URL).getId(); + linkHandler.fromUrl(AD_URL).getId(); } @Test @@ -45,7 +46,7 @@ public class YoutubeStreamLinkHandlerFactoryTest { for (String invalidUrl : invalidUrls) { Throwable exception = null; try { - urlIdHandler.fromUrl(invalidUrl).getId(); + linkHandler.fromUrl(invalidUrl).getId(); } catch (ParsingException e) { exception = e; } @@ -57,67 +58,67 @@ public class YoutubeStreamLinkHandlerFactoryTest { @Test public void getIdfromYt() throws Exception { - assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("https://www.youtube.com/watch?v=jZViOEv90dI").getId()); - assertEquals("W-fFHeTX70Q", urlIdHandler.fromUrl("https://www.youtube.com/watch?v=W-fFHeTX70Q").getId()); - assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("https://www.youtube.com/watch?v=jZViOEv90dI?t=100").getId()); - assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("https://WWW.YouTube.com/watch?v=jZViOEv90dI?t=100").getId()); - assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("HTTPS://www.youtube.com/watch?v=jZViOEv90dI?t=100").getId()); - assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("https://youtu.be/jZViOEv90dI?t=9s").getId()); - assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("HTTPS://Youtu.be/jZViOEv90dI?t=9s").getId()); - assertEquals("uEJuoEs1UxY", urlIdHandler.fromUrl("http://www.youtube.com/watch_popup?v=uEJuoEs1UxY").getId()); - assertEquals("uEJuoEs1UxY", urlIdHandler.fromUrl("http://www.Youtube.com/watch_popup?v=uEJuoEs1UxY").getId()); - assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("https://www.youtube.com/embed/jZViOEv90dI").getId()); - assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("https://www.youtube-nocookie.com/embed/jZViOEv90dI").getId()); - assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("http://www.youtube.com/watch?v=jZViOEv90dI").getId()); - assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("http://youtube.com/watch?v=jZViOEv90dI").getId()); - assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("http://youtu.be/jZViOEv90dI?t=9s").getId()); - assertEquals("7_WWz2DSnT8", urlIdHandler.fromUrl("https://youtu.be/7_WWz2DSnT8").getId()); - assertEquals("oy6NvWeVruY", urlIdHandler.fromUrl("https://m.youtube.com/watch?v=oy6NvWeVruY").getId()); - assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("http://www.youtube.com/embed/jZViOEv90dI").getId()); - assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("http://www.Youtube.com/embed/jZViOEv90dI").getId()); - assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("http://www.youtube-nocookie.com/embed/jZViOEv90dI").getId()); - assertEquals("EhxJLojIE_o", urlIdHandler.fromUrl("http://www.youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare").getId()); - assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("vnd.youtube://www.youtube.com/watch?v=jZViOEv90dI").getId()); - assertEquals("jZViOEv90dI", urlIdHandler.fromUrl("vnd.youtube:jZViOEv90dI").getId()); + assertEquals("jZViOEv90dI", linkHandler.fromUrl("https://www.youtube.com/watch?v=jZViOEv90dI").getId()); + assertEquals("W-fFHeTX70Q", linkHandler.fromUrl("https://www.youtube.com/watch?v=W-fFHeTX70Q").getId()); + assertEquals("jZViOEv90dI", linkHandler.fromUrl("https://www.youtube.com/watch?v=jZViOEv90dI?t=100").getId()); + assertEquals("jZViOEv90dI", linkHandler.fromUrl("https://WWW.YouTube.com/watch?v=jZViOEv90dI?t=100").getId()); + assertEquals("jZViOEv90dI", linkHandler.fromUrl("HTTPS://www.youtube.com/watch?v=jZViOEv90dI?t=100").getId()); + assertEquals("jZViOEv90dI", linkHandler.fromUrl("https://youtu.be/jZViOEv90dI?t=9s").getId()); + assertEquals("jZViOEv90dI", linkHandler.fromUrl("HTTPS://Youtu.be/jZViOEv90dI?t=9s").getId()); + assertEquals("uEJuoEs1UxY", linkHandler.fromUrl("http://www.youtube.com/watch_popup?v=uEJuoEs1UxY").getId()); + assertEquals("uEJuoEs1UxY", linkHandler.fromUrl("http://www.Youtube.com/watch_popup?v=uEJuoEs1UxY").getId()); + assertEquals("jZViOEv90dI", linkHandler.fromUrl("https://www.youtube.com/embed/jZViOEv90dI").getId()); + assertEquals("jZViOEv90dI", linkHandler.fromUrl("https://www.youtube-nocookie.com/embed/jZViOEv90dI").getId()); + assertEquals("jZViOEv90dI", linkHandler.fromUrl("http://www.youtube.com/watch?v=jZViOEv90dI").getId()); + assertEquals("jZViOEv90dI", linkHandler.fromUrl("http://youtube.com/watch?v=jZViOEv90dI").getId()); + assertEquals("jZViOEv90dI", linkHandler.fromUrl("http://youtu.be/jZViOEv90dI?t=9s").getId()); + assertEquals("7_WWz2DSnT8", linkHandler.fromUrl("https://youtu.be/7_WWz2DSnT8").getId()); + assertEquals("oy6NvWeVruY", linkHandler.fromUrl("https://m.youtube.com/watch?v=oy6NvWeVruY").getId()); + assertEquals("jZViOEv90dI", linkHandler.fromUrl("http://www.youtube.com/embed/jZViOEv90dI").getId()); + assertEquals("jZViOEv90dI", linkHandler.fromUrl("http://www.Youtube.com/embed/jZViOEv90dI").getId()); + assertEquals("jZViOEv90dI", linkHandler.fromUrl("http://www.youtube-nocookie.com/embed/jZViOEv90dI").getId()); + assertEquals("EhxJLojIE_o", linkHandler.fromUrl("http://www.youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare").getId()); + assertEquals("jZViOEv90dI", linkHandler.fromUrl("vnd.youtube://www.youtube.com/watch?v=jZViOEv90dI").getId()); + assertEquals("jZViOEv90dI", linkHandler.fromUrl("vnd.youtube:jZViOEv90dI").getId()); } @Test public void testAcceptYtUrl() throws ParsingException { - assertTrue(urlIdHandler.acceptUrl("https://www.youtube.com/watch?v=jZViOEv90dI")); - assertTrue(urlIdHandler.acceptUrl("https://www.youtube.com/watch?v=jZViOEv90dI?t=100")); - assertTrue(urlIdHandler.acceptUrl("https://WWW.YouTube.com/watch?v=jZViOEv90dI?t=100")); - assertTrue(urlIdHandler.acceptUrl("HTTPS://www.youtube.com/watch?v=jZViOEv90dI?t=100")); - assertTrue(urlIdHandler.acceptUrl("https://youtu.be/jZViOEv90dI?t=9s")); - assertTrue(urlIdHandler.acceptUrl("https://www.youtube.com/embed/jZViOEv90dI")); - assertTrue(urlIdHandler.acceptUrl("https://www.youtube-nocookie.com/embed/jZViOEv90dI")); - assertTrue(urlIdHandler.acceptUrl("http://www.youtube.com/watch?v=jZViOEv90dI")); - assertTrue(urlIdHandler.acceptUrl("http://youtu.be/jZViOEv90dI?t=9s")); - assertTrue(urlIdHandler.acceptUrl("http://www.youtube.com/embed/jZViOEv90dI")); - assertTrue(urlIdHandler.acceptUrl("http://www.youtube-nocookie.com/embed/jZViOEv90dI")); - assertTrue(urlIdHandler.acceptUrl("http://www.youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare")); - assertTrue(urlIdHandler.acceptUrl("vnd.youtube://www.youtube.com/watch?v=jZViOEv90dI")); - assertTrue(urlIdHandler.acceptUrl("vnd.youtube:jZViOEv90dI")); + assertTrue(linkHandler.acceptUrl("https://www.youtube.com/watch?v=jZViOEv90dI")); + assertTrue(linkHandler.acceptUrl("https://www.youtube.com/watch?v=jZViOEv90dI?t=100")); + assertTrue(linkHandler.acceptUrl("https://WWW.YouTube.com/watch?v=jZViOEv90dI?t=100")); + assertTrue(linkHandler.acceptUrl("HTTPS://www.youtube.com/watch?v=jZViOEv90dI?t=100")); + assertTrue(linkHandler.acceptUrl("https://youtu.be/jZViOEv90dI?t=9s")); + assertTrue(linkHandler.acceptUrl("https://www.youtube.com/embed/jZViOEv90dI")); + assertTrue(linkHandler.acceptUrl("https://www.youtube-nocookie.com/embed/jZViOEv90dI")); + assertTrue(linkHandler.acceptUrl("http://www.youtube.com/watch?v=jZViOEv90dI")); + assertTrue(linkHandler.acceptUrl("http://youtu.be/jZViOEv90dI?t=9s")); + assertTrue(linkHandler.acceptUrl("http://www.youtube.com/embed/jZViOEv90dI")); + assertTrue(linkHandler.acceptUrl("http://www.youtube-nocookie.com/embed/jZViOEv90dI")); + assertTrue(linkHandler.acceptUrl("http://www.youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare")); + assertTrue(linkHandler.acceptUrl("vnd.youtube://www.youtube.com/watch?v=jZViOEv90dI")); + assertTrue(linkHandler.acceptUrl("vnd.youtube:jZViOEv90dI")); - assertTrue(urlIdHandler.acceptUrl("vnd.youtube:jZViOEv90dI")); + assertTrue(linkHandler.acceptUrl("vnd.youtube:jZViOEv90dI")); } @Test public void testAcceptHookUrl() throws ParsingException { - assertTrue(urlIdHandler.acceptUrl("https://hooktube.com/watch?v=TglNG-yjabU")); - assertTrue(urlIdHandler.acceptUrl("hooktube.com/watch?v=3msbfr6pBNE")); - assertTrue(urlIdHandler.acceptUrl("https://hooktube.com/watch?v=ocH3oSnZG3c&list=PLS2VU1j4vzuZwooPjV26XM9UEBY2CPNn2")); - assertTrue(urlIdHandler.acceptUrl("hooktube.com/watch/3msbfr6pBNE")); - assertTrue(urlIdHandler.acceptUrl("hooktube.com/v/3msbfr6pBNE")); - assertTrue(urlIdHandler.acceptUrl("hooktube.com/embed/3msbfr6pBNE")); + assertTrue(linkHandler.acceptUrl("https://hooktube.com/watch?v=TglNG-yjabU")); + assertTrue(linkHandler.acceptUrl("hooktube.com/watch?v=3msbfr6pBNE")); + assertTrue(linkHandler.acceptUrl("https://hooktube.com/watch?v=ocH3oSnZG3c&list=PLS2VU1j4vzuZwooPjV26XM9UEBY2CPNn2")); + assertTrue(linkHandler.acceptUrl("hooktube.com/watch/3msbfr6pBNE")); + assertTrue(linkHandler.acceptUrl("hooktube.com/v/3msbfr6pBNE")); + assertTrue(linkHandler.acceptUrl("hooktube.com/embed/3msbfr6pBNE")); } @Test public void testGetHookIdfromUrl() throws ParsingException { - assertEquals("TglNG-yjabU", urlIdHandler.fromUrl("https://hooktube.com/watch?v=TglNG-yjabU").getId()); - assertEquals("3msbfr6pBNE", urlIdHandler.fromUrl("hooktube.com/watch?v=3msbfr6pBNE").getId()); - assertEquals("ocH3oSnZG3c", urlIdHandler.fromUrl("https://hooktube.com/watch?v=ocH3oSnZG3c&list=PLS2VU1j4vzuZwooPjV26XM9UEBY2CPNn2").getId()); - assertEquals("3msbfr6pBNE", urlIdHandler.fromUrl("hooktube.com/watch/3msbfr6pBNE").getId()); - assertEquals("3msbfr6pBNE", urlIdHandler.fromUrl("hooktube.com/v/3msbfr6pBNE").getId()); - assertEquals("3msbfr6pBNE", urlIdHandler.fromUrl("hooktube.com/embed/3msbfr6pBNE").getId()); + assertEquals("TglNG-yjabU", linkHandler.fromUrl("https://hooktube.com/watch?v=TglNG-yjabU").getId()); + assertEquals("3msbfr6pBNE", linkHandler.fromUrl("hooktube.com/watch?v=3msbfr6pBNE").getId()); + assertEquals("ocH3oSnZG3c", linkHandler.fromUrl("https://hooktube.com/watch?v=ocH3oSnZG3c&list=PLS2VU1j4vzuZwooPjV26XM9UEBY2CPNn2").getId()); + assertEquals("3msbfr6pBNE", linkHandler.fromUrl("hooktube.com/watch/3msbfr6pBNE").getId()); + assertEquals("3msbfr6pBNE", linkHandler.fromUrl("hooktube.com/v/3msbfr6pBNE").getId()); + assertEquals("3msbfr6pBNE", linkHandler.fromUrl("hooktube.com/embed/3msbfr6pBNE").getId()); } } \ No newline at end of file diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSubscriptionExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSubscriptionExtractorTest.java index 57b493b04..8d2e6cfae 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSubscriptionExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSubscriptionExtractorTest.java @@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory; import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSubscriptionExtractor; import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor; import org.schabi.newpipe.extractor.subscription.SubscriptionItem; +import org.schabi.newpipe.extractor.utils.Localization; import java.io.ByteArrayInputStream; import java.io.File; @@ -27,7 +28,7 @@ public class YoutubeSubscriptionExtractorTest { @BeforeClass public static void setupClass() { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); subscriptionExtractor = new YoutubeSubscriptionExtractor(ServiceList.YouTube); urlHandler = ServiceList.YouTube.getChannelLHFactory(); } 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 3e72ec34a..25d368888 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 @@ -26,6 +26,7 @@ import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.SuggestionExtractor; import org.schabi.newpipe.extractor.exceptions.ExtractionException; +import org.schabi.newpipe.extractor.utils.Localization; import java.io.IOException; @@ -40,12 +41,12 @@ public class YoutubeSuggestionExtractorTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("DE", "de")); suggestionExtractor = YouTube.getSuggestionExtractor(); } @Test public void testIfSuggestions() throws IOException, ExtractionException { - assertFalse(suggestionExtractor.suggestionList("hello", "de").isEmpty()); + assertFalse(suggestionExtractor.suggestionList("hello").isEmpty()); } } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java index bf1ae8bb7..fb61797bf 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingExtractorTest.java @@ -28,6 +28,7 @@ import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeTrendingExtractor; import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeTrendingLinkHandlerFactory; import org.schabi.newpipe.extractor.stream.StreamInfoItem; +import org.schabi.newpipe.extractor.utils.Localization; import org.schabi.newpipe.extractor.utils.Utils; import static junit.framework.TestCase.assertFalse; @@ -45,7 +46,7 @@ public class YoutubeTrendingExtractorTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (YoutubeTrendingExtractor) YouTube .getKioskList() .getExtractorById("Trending", null); 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 66369170a..85480eaf6 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 @@ -27,6 +27,7 @@ import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory; import org.schabi.newpipe.extractor.kiosk.KioskInfo; +import org.schabi.newpipe.extractor.utils.Localization; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -41,7 +42,7 @@ public class YoutubeTrendingKioskInfoTest { @BeforeClass public static void setUp() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); StreamingService service = YouTube; LinkHandlerFactory LinkHandlerFactory = service.getKioskList().getListLinkHandlerFactoryByType("Trending"); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingLinkHandlerFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingLinkHandlerFactoryTest.java index ed3f0a011..46095b4da 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingLinkHandlerFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeTrendingLinkHandlerFactoryTest.java @@ -27,6 +27,7 @@ import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory; import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeTrendingLinkHandlerFactory; +import org.schabi.newpipe.extractor.utils.Localization; import static junit.framework.TestCase.assertFalse; import static org.junit.Assert.assertEquals; @@ -42,7 +43,7 @@ public class YoutubeTrendingLinkHandlerFactoryTest { @BeforeClass public static void setUp() throws Exception { LinkHandlerFactory = YouTube.getKioskList().getListLinkHandlerFactoryByType("Trending"); - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); } @Test diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchCountTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchCountTest.java index aa79893fe..af314e632 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchCountTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchCountTest.java @@ -7,6 +7,7 @@ import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.channel.ChannelInfoItem; import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor; import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory; +import org.schabi.newpipe.extractor.utils.Localization; import static java.util.Collections.singletonList; import static junit.framework.TestCase.assertTrue; @@ -16,9 +17,9 @@ public class YoutubeSearchCountTest { public static class YoutubeChannelViewCountTest extends YoutubeSearchExtractorBaseTest { @BeforeClass public static void setUpClass() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie", - singletonList(YoutubeSearchQueryHandlerFactory.CHANNELS), null,"de"); + singletonList(YoutubeSearchQueryHandlerFactory.CHANNELS), null, new Localization("GB", "en")); extractor.fetchPage(); itemsPage = extractor.getInitialPage(); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorChannelOnlyTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorChannelOnlyTest.java index b0c53a1f1..3b86042d8 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorChannelOnlyTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorChannelOnlyTest.java @@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.channel.ChannelInfoItem; import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor; import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory; +import org.schabi.newpipe.extractor.utils.Localization; import static java.util.Arrays.asList; import static org.junit.Assert.*; @@ -18,9 +19,9 @@ public class YoutubeSearchExtractorChannelOnlyTest extends YoutubeSearchExtracto @BeforeClass public static void setUpClass() throws Exception { - NewPipe.init(Downloader.getInstance()); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie", - asList(YoutubeSearchQueryHandlerFactory.CHANNELS), null, "de"); + asList(YoutubeSearchQueryHandlerFactory.CHANNELS), null, new Localization("GB", "en")); extractor.fetchPage(); itemsPage = extractor.getInitialPage(); } @@ -28,7 +29,7 @@ public class YoutubeSearchExtractorChannelOnlyTest extends YoutubeSearchExtracto @Test public void testGetSecondPage() throws Exception { YoutubeSearchExtractor secondExtractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie", - asList(YoutubeSearchQueryHandlerFactory.CHANNELS), null, "de"); + asList(YoutubeSearchQueryHandlerFactory.CHANNELS), null, new Localization("GB", "en")); ListExtractor.InfoItemsPage secondPage = secondExtractor.getPage(itemsPage.getNextPageUrl()); assertTrue(Integer.toString(secondPage.getItems().size()), secondPage.getItems().size() > 10); diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorDefaultTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorDefaultTest.java index 2ab7c6cd3..234ea5f96 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorDefaultTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchExtractorDefaultTest.java @@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.channel.ChannelInfoItem; import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor; import org.schabi.newpipe.extractor.stream.StreamInfoItem; +import org.schabi.newpipe.extractor.utils.Localization; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -42,8 +43,8 @@ public class YoutubeSearchExtractorDefaultTest extends YoutubeSearchExtractorBas @BeforeClass public static void setUpClass() throws Exception { - NewPipe.init(Downloader.getInstance()); - extractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie", "de"); + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); + extractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie"); extractor.fetchPage(); itemsPage = extractor.getInitialPage(); } @@ -79,7 +80,7 @@ public class YoutubeSearchExtractorDefaultTest extends YoutubeSearchExtractorBas @Test public void testGetSecondPage() throws Exception { YoutubeSearchExtractor secondExtractor = - (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie", "de"); + (YoutubeSearchExtractor) YouTube.getSearchExtractor("pewdiepie"); ListExtractor.InfoItemsPage secondPage = secondExtractor.getPage(itemsPage.getNextPageUrl()); assertTrue(Integer.toString(secondPage.getItems().size()), secondPage.getItems().size() > 10); From 49c2eb51859a58e4bb5ead2d9d0771408f7d59d6 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Thu, 20 Sep 2018 13:51:06 +0200 Subject: [PATCH 3/5] fix failing watch links --- .../youtube/extractors/YoutubeStreamExtractor.java | 8 +++----- .../youtube/YoutubeStreamExtractorDefaultTest.java | 12 ++++++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java index 28af223e8..3f8ddee49 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java @@ -177,12 +177,10 @@ public class YoutubeStreamExtractor extends StreamExtractor { // if link is null the a tag is a hashtag. // They refer to the youtube search. We do not handle them. a.text(link); - + } else if(redirectLink.toString().contains("https://www.youtube.com/")) { + a.text(redirectLink.toString()); } - } else if(redirectLink.toString().contains("watch?v=") - || redirectLink.toString().contains("https://www.youtube.com/")) { - // Another posibility is that this link is pointing to another video - // we need to put the redirectLink in here explicitly in order to add the domain part to the link. + } else if(redirectLink.toString().contains("https://www.youtube.com/")) { a.text(redirectLink.toString()); } } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java index 2b5f6058c..a01c16146 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java @@ -176,7 +176,7 @@ public class YoutubeStreamExtractorDefaultTest { public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance()); extractor = (YoutubeStreamExtractor) YouTube - .getStreamExtractor("https://www.youtube.com/watch?v=dJY8iT341F4"); + .getStreamExtractor("https://www.youtube.com/watch?v=LUldijpMUew"); extractor.fetchPage(); } @@ -189,14 +189,14 @@ public class YoutubeStreamExtractorDefaultTest { @Test public void testGetFullLinksInDescriptlion() throws ParsingException { assertTrue(extractor.getDescription().contains("https://www.reddit.com/r/PewdiepieSubmissions/")); - assertTrue(extractor.getDescription().contains("https://www.youtube.com/channel/UC3e8EMTOn4g6ZSKggHTnNng")); + assertTrue(extractor.getDescription().contains("https://www.youtube.com/channel/UCeKXymg6S6Pt4EjjOlA759w")); + assertTrue(extractor.getDescription().contains("https://www.youtube.com/watch?v=N6hVmn9FM7o")); + assertTrue(extractor.getDescription().contains("https://usa.clutchchairz.com/product/pewdiepie-edition-throttle-series/")); assertFalse(extractor.getDescription().contains("https://www.reddit.com/r/PewdiepieSub...")); + assertFalse(extractor.getDescription().contains("https://www.youtube.com/channel/UCeKX...")); + assertFalse(extractor.getDescription().contains("https://www.youtube.com/watch?v=qpaV3...")); assertFalse(extractor.getDescription().contains("https://usa.clutchchairz.com/product/...")); - assertFalse(extractor.getDescription().contains("https://europe.clutchchairz.com/en/pr...")); - assertFalse(extractor.getDescription().contains("https://canada.clutchchairz.com/produ...")); - assertFalse(extractor.getDescription().contains("http://store.steampowered.com/app/703...")); - assertFalse(extractor.getDescription().contains("https://www.youtube.com/channel/UC3e8...")); } } } From f334dd07de083b68c480d1773dd0d86d5c529da0 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Mon, 24 Sep 2018 15:06:00 +0200 Subject: [PATCH 4/5] fix youtub.be links in description --- .../YoutubeStreamExtractorDefaultTest.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java index 31f160d47..0040d4dc6 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java @@ -188,7 +188,7 @@ public class YoutubeStreamExtractorDefaultTest { } @Test - public void testGetFullLinksInDescriptlion() throws ParsingException { + public void testGetFullLinksInDescription() throws ParsingException { assertTrue(extractor.getDescription().contains("https://www.reddit.com/r/PewdiepieSubmissions/")); assertTrue(extractor.getDescription().contains("https://www.youtube.com/channel/UCeKXymg6S6Pt4EjjOlA759w")); assertTrue(extractor.getDescription().contains("https://www.youtube.com/watch?v=N6hVmn9FM7o")); @@ -200,4 +200,35 @@ public class YoutubeStreamExtractorDefaultTest { assertFalse(extractor.getDescription().contains("https://usa.clutchchairz.com/product/...")); } } + + public static class DescriptionTestUnboxing { + private static YoutubeStreamExtractor extractor; + + @BeforeClass + public static void setUp() throws Exception { + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); + extractor = (YoutubeStreamExtractor) YouTube + .getStreamExtractor("https://www.youtube.com/watch?v=cV5TjZCJkuA"); + extractor.fetchPage(); + } + + @Test + public void testGetDescription() throws ParsingException { + assertNotNull(extractor.getDescription()); + assertFalse(extractor.getDescription().isEmpty()); + } + + @Test + public void testGetFullLinksInDescription() throws ParsingException { + assertTrue(extractor.getDescription().contains("https://www.youtube.com/watch?v=X7FLCHVXpsA&list=PL7u4lWXQ3wfI_7PgX0C-VTiwLeu0S4v34")); + assertTrue(extractor.getDescription().contains("https://www.youtube.com/watch?v=Lqv6G0pDNnw&list=PL7u4lWXQ3wfI_7PgX0C-VTiwLeu0S4v34")); + assertTrue(extractor.getDescription().contains("https://www.youtube.com/watch?v=XxaRBPyrnBU&list=PL7u4lWXQ3wfI_7PgX0C-VTiwLeu0S4v34")); + assertTrue(extractor.getDescription().contains("https://www.youtube.com/watch?v=U-9tUEOFKNU&list=PL7u4lWXQ3wfI_7PgX0C-VTiwLeu0S4v34")); + + assertFalse(extractor.getDescription().contains("https://youtu.be/X7FLCHVXpsA?list=PL7...")); + assertFalse(extractor.getDescription().contains("https://youtu.be/Lqv6G0pDNnw?list=PL7...")); + assertFalse(extractor.getDescription().contains("https://youtu.be/XxaRBPyrnBU?list=PL7...")); + assertFalse(extractor.getDescription().contains("https://youtu.be/U-9tUEOFKNU?list=PL7...")); + } + } } From 5223aece7b2870206ac0a133bc1fc2585088038e Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Mon, 24 Sep 2018 15:17:57 +0200 Subject: [PATCH 5/5] fix failing unit test --- .../youtube/YoutubeStreamExtractorDefaultTest.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java index 0040d4dc6..ea88e350b 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java @@ -177,7 +177,7 @@ public class YoutubeStreamExtractorDefaultTest { public static void setUp() throws Exception { NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = (YoutubeStreamExtractor) YouTube - .getStreamExtractor("https://www.youtube.com/watch?v=LUldijpMUew"); + .getStreamExtractor("https://www.youtube.com/watch?v=LzR8Sf5PK2Q"); extractor.fetchPage(); } @@ -190,13 +190,11 @@ public class YoutubeStreamExtractorDefaultTest { @Test public void testGetFullLinksInDescription() throws ParsingException { assertTrue(extractor.getDescription().contains("https://www.reddit.com/r/PewdiepieSubmissions/")); - assertTrue(extractor.getDescription().contains("https://www.youtube.com/channel/UCeKXymg6S6Pt4EjjOlA759w")); - assertTrue(extractor.getDescription().contains("https://www.youtube.com/watch?v=N6hVmn9FM7o")); + assertTrue(extractor.getDescription().contains("https://www.youtube.com/channel/UC3e8EMTOn4g6ZSKggHTnNng")); assertTrue(extractor.getDescription().contains("https://usa.clutchchairz.com/product/pewdiepie-edition-throttle-series/")); assertFalse(extractor.getDescription().contains("https://www.reddit.com/r/PewdiepieSub...")); - assertFalse(extractor.getDescription().contains("https://www.youtube.com/channel/UCeKX...")); - assertFalse(extractor.getDescription().contains("https://www.youtube.com/watch?v=qpaV3...")); + assertFalse(extractor.getDescription().contains("https://www.youtube.com/channel/UC3e8...")); assertFalse(extractor.getDescription().contains("https://usa.clutchchairz.com/product/...")); } }