From 3a865749e89b213538f5073b2161d154173f67e1 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Fri, 5 Oct 2018 16:01:10 +0200 Subject: [PATCH 1/4] fix issues Kiosk issue about localization, nad rename to preferred localization --- .../org/schabi/newpipe/extractor/NewPipe.java | 2 +- .../newpipe/extractor/StreamingService.java | 24 ++++++++---------- .../extractor/channel/ChannelInfo.java | 3 +-- .../newpipe/extractor/kiosk/KioskInfo.java | 13 +++------- .../newpipe/extractor/kiosk/KioskList.java | 25 ++++++++++++++----- .../soundcloud/SoundcloudService.java | 4 +-- .../services/youtube/YoutubeService.java | 4 +-- .../YoutubeStreamExtractorDefaultTest.java | 2 +- .../youtube/YoutubeTrendingKioskInfoTest.java | 2 +- 9 files changed, 41 insertions(+), 38 deletions(-) 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 fcbde0f9e..cf4a26437 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/NewPipe.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/NewPipe.java @@ -103,7 +103,7 @@ public class NewPipe { NewPipe.localization = localization; } - public static Localization getLocalization() { + public static Localization getPreferredLocalization() { 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 55efd1f57..a85d8f3a1 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/StreamingService.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/StreamingService.java @@ -80,7 +80,7 @@ public abstract class StreamingService { public abstract SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler, Localization localization); public abstract SuggestionExtractor getSuggestionExtractor(Localization localization); public abstract SubscriptionExtractor getSubscriptionExtractor(); - public abstract KioskList getKioskList(Localization localization) throws ExtractionException; + public abstract KioskList getKioskList() throws ExtractionException; public abstract ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler, Localization localization) throws ExtractionException; @@ -93,27 +93,23 @@ public abstract class StreamingService { //////////////////////////////////////////// public SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler) { - return getSearchExtractor(queryHandler, NewPipe.getLocalization()); + return getSearchExtractor(queryHandler, NewPipe.getPreferredLocalization()); } public SuggestionExtractor getSuggestionExtractor() { - return getSuggestionExtractor(NewPipe.getLocalization()); - } - - public KioskList getKioskList() throws ExtractionException { - return getKioskList(NewPipe.getLocalization()); + return getSuggestionExtractor(NewPipe.getPreferredLocalization()); } public ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler) throws ExtractionException { - return getChannelExtractor(linkHandler, NewPipe.getLocalization()); + return getChannelExtractor(linkHandler, NewPipe.getPreferredLocalization()); } public PlaylistExtractor getPlaylistExtractor(ListLinkHandler linkHandler) throws ExtractionException { - return getPlaylistExtractor(linkHandler, NewPipe.getLocalization()); + return getPlaylistExtractor(linkHandler, NewPipe.getPreferredLocalization()); } public StreamExtractor getStreamExtractor(LinkHandler linkHandler) throws ExtractionException { - return getStreamExtractor(linkHandler, NewPipe.getLocalization()); + return getStreamExtractor(linkHandler, NewPipe.getPreferredLocalization()); } //////////////////////////////////////////// @@ -154,19 +150,19 @@ public abstract class StreamingService { //////////////////////////////////////////// public SearchExtractor getSearchExtractor(String query) throws ExtractionException { - return getSearchExtractor(getSearchQHFactory().fromQuery(query), NewPipe.getLocalization()); + return getSearchExtractor(getSearchQHFactory().fromQuery(query), NewPipe.getPreferredLocalization()); } public ChannelExtractor getChannelExtractor(String url) throws ExtractionException { - return getChannelExtractor(getChannelLHFactory().fromUrl(url), NewPipe.getLocalization()); + return getChannelExtractor(getChannelLHFactory().fromUrl(url), NewPipe.getPreferredLocalization()); } public PlaylistExtractor getPlaylistExtractor(String url) throws ExtractionException { - return getPlaylistExtractor(getPlaylistLHFactory().fromUrl(url), NewPipe.getLocalization()); + return getPlaylistExtractor(getPlaylistLHFactory().fromUrl(url), NewPipe.getPreferredLocalization()); } public StreamExtractor getStreamExtractor(String url) throws ExtractionException { - return getStreamExtractor(getStreamLHFactory().fromUrl(url), NewPipe.getLocalization()); + return getStreamExtractor(getStreamLHFactory().fromUrl(url), NewPipe.getPreferredLocalization()); } 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 0aed6e118..20abdfe42 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 @@ -51,8 +51,7 @@ public class ChannelInfo extends ListInfo { public static InfoItemsPage getMoreItems(StreamingService service, String url, - String pageUrl, - Localization localization) throws IOException, ExtractionException { + String pageUrl) throws IOException, ExtractionException { return service.getChannelExtractor(url).getPage(pageUrl); } 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 141b480cd..9ebb0cd93 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 @@ -37,25 +37,20 @@ public class KioskInfo extends ListInfo { public static ListExtractor.InfoItemsPage getMoreItems(StreamingService service, String url, - String pageUrl, - String contentCountry) throws IOException, ExtractionException { + String pageUrl) throws IOException, ExtractionException { KioskList kl = service.getKioskList(); KioskExtractor extractor = kl.getExtractorByUrl(url, pageUrl); - extractor.setContentCountry(contentCountry); return extractor.getPage(pageUrl); } - public static KioskInfo getInfo(String url, - String contentCountry) throws IOException, ExtractionException { - return getInfo(NewPipe.getServiceByUrl(url), url, contentCountry); + public static KioskInfo getInfo(String url) throws IOException, ExtractionException { + return getInfo(NewPipe.getServiceByUrl(url), url); } public static KioskInfo getInfo(StreamingService service, - String url, - String contentCountry) throws IOException, ExtractionException { + String url) throws IOException, ExtractionException { KioskList kl = service.getKioskList(); KioskExtractor extractor = kl.getExtractorByUrl(url, null); - extractor.setContentCountry(contentCountry); extractor.fetchPage(); return getInfo(extractor); } 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 b37b7c04f..22a9f2ca8 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 @@ -23,7 +23,6 @@ public class KioskList { 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) { @@ -34,9 +33,8 @@ public class KioskList { final ListLinkHandlerFactory handlerFactory; } - public KioskList(int service_id, Localization localization) { + public KioskList(int service_id) { this.service_id = service_id; - this.localization = localization; } public void addKioskEntry(KioskExtractorFactory extractorFactory, ListLinkHandlerFactory handlerFactory, String id) @@ -53,13 +51,18 @@ public class KioskList { public KioskExtractor getDefaultKioskExtractor(String nextPageUrl) throws ExtractionException, IOException { + return getDefaultKioskExtractor(nextPageUrl, NewPipe.getPreferredLocalization()); + } + + public KioskExtractor getDefaultKioskExtractor(String nextPageUrl, Localization localization) + throws ExtractionException, IOException { if(defaultKiosk != null && !defaultKiosk.equals("")) { - return getExtractorById(defaultKiosk, nextPageUrl); + return getExtractorById(defaultKiosk, nextPageUrl, localization); } else { if(!kioskList.isEmpty()) { // if not set get any entry Object[] keySet = kioskList.keySet().toArray(); - return getExtractorById(keySet[0].toString(), nextPageUrl); + return getExtractorById(keySet[0].toString(), nextPageUrl, localization); } else { return null; } @@ -72,6 +75,11 @@ public class KioskList { public KioskExtractor getExtractorById(String kioskId, String nextPageUrl) throws ExtractionException, IOException { + return getExtractorById(kioskId, nextPageUrl, NewPipe.getPreferredLocalization()); + } + + public KioskExtractor getExtractorById(String kioskId, String nextPageUrl, Localization localization) + throws ExtractionException, IOException { KioskEntry ke = kioskList.get(kioskId); if(ke == null) { throw new ExtractionException("No kiosk found with the type: " + kioskId); @@ -86,11 +94,16 @@ public class KioskList { } public KioskExtractor getExtractorByUrl(String url, String nextPageUrl) + throws ExtractionException, IOException{ + return getExtractorByUrl(url, nextPageUrl, NewPipe.getPreferredLocalization()); + } + + public KioskExtractor getExtractorByUrl(String url, String nextPageUrl, Localization localization) throws ExtractionException, IOException { for(Map.Entry e : kioskList.entrySet()) { KioskEntry ke = e.getValue(); if(ke.handlerFactory.acceptUrl(url)) { - return getExtractorById(e.getKey(), nextPageUrl); + return getExtractorById(e.getKey(), nextPageUrl, localization); } } throw new ExtractionException("Could not find a kiosk that fits to the url: " + url); 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 c43d34ce2..0202bba56 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 @@ -68,7 +68,7 @@ public class SoundcloudService extends StreamingService { } @Override - public KioskList getKioskList(Localization localization) throws ExtractionException { + public KioskList getKioskList() throws ExtractionException { KioskList.KioskExtractorFactory chartsFactory = new KioskList.KioskExtractorFactory() { @Override public KioskExtractor createNewKiosk(StreamingService streamingService, @@ -81,7 +81,7 @@ public class SoundcloudService extends StreamingService { } }; - KioskList list = new KioskList(getServiceId(), localization); + KioskList list = new KioskList(getServiceId()); // add kiosks here e.g.: final SoundcloudChartsLinkHandlerFactory h = new SoundcloudChartsLinkHandlerFactory(); 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 d9187ca4c..57cd3f852 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 @@ -90,8 +90,8 @@ public class YoutubeService extends StreamingService { } @Override - public KioskList getKioskList(final Localization localization) throws ExtractionException { - KioskList list = new KioskList(getServiceId(), localization); + public KioskList getKioskList() throws ExtractionException { + KioskList list = new KioskList(getServiceId()); // add kiosks here e.g.: try { 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 ea88e350b..2c026f361 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=LzR8Sf5PK2Q"); + .getStreamExtractor("https://www.youtube.com/watch?v=fBc4Q_htqPg"); extractor.fetchPage(); } 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 85480eaf6..68a5bae0f 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 @@ -46,7 +46,7 @@ public class YoutubeTrendingKioskInfoTest { StreamingService service = YouTube; LinkHandlerFactory LinkHandlerFactory = service.getKioskList().getListLinkHandlerFactoryByType("Trending"); - kioskInfo = KioskInfo.getInfo(YouTube, LinkHandlerFactory.fromId("Trending").getUrl(), null); + kioskInfo = KioskInfo.getInfo(YouTube, LinkHandlerFactory.fromId("Trending").getUrl()); } @Test From 0c3dc86b07e5d57970cd7e994af0ee62b49b8484 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sat, 6 Oct 2018 12:22:37 +0200 Subject: [PATCH 2/4] add support for yt content country --- .../extractor/kiosk/KioskExtractor.java | 17 ----------------- .../extractors/YoutubeSearchExtractor.java | 18 ++++++------------ .../extractors/YoutubeTrendingExtractor.java | 2 +- .../youtube/YoutubeTrendingExtractorTest.java | 1 - 4 files changed, 7 insertions(+), 31 deletions(-) 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 8c003b015..481bb63ca 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 @@ -30,7 +30,6 @@ import org.schabi.newpipe.extractor.utils.Localization; import javax.annotation.Nonnull; public abstract class KioskExtractor extends ListExtractor { - private String contentCountry = null; private final String id; public KioskExtractor(StreamingService streamingService, @@ -41,17 +40,6 @@ public abstract class KioskExtractor extends ListExtractor { this.id = kioskId; } - /** - * For certain Websites the content of a kiosk will be different depending - * on the country you want to poen the website in. Therefore you should - * set the contentCountry. - * @param contentCountry Set the country decoded as Country Code: http://www.1728.org/countries.htm - */ - public void setContentCountry(String contentCountry) { - this.contentCountry = contentCountry; - } - - @Nonnull @Override public String getId() { @@ -69,9 +57,4 @@ public abstract class KioskExtractor extends ListExtractor { @Nonnull @Override public abstract String getName() throws ParsingException; - - - public String getContentCountry() { - return contentCountry; - } } 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 1c1bad6b2..2d411fa78 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 @@ -53,22 +53,16 @@ public class YoutubeSearchExtractor extends SearchExtractor { @Override public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException { final String site; - final String url = getUrl(); - final String contentCountry = getLocalization().getCountry(); + final String url = getUrl() + "?gl="+ 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, getLocalization()); - } else { - site = downloader.download(url); - } + site = downloader.download(url, getLocalization()); doc = Jsoup.parse(site, url); } @Override - public String getSearchSuggestion() throws ParsingException { + public String getSearchSuggestion() { final Element el = doc.select("div[class*=\"spell-correction\"]").first(); if (el != null) { return el.select("a").first().text(); @@ -79,13 +73,13 @@ public class YoutubeSearchExtractor extends SearchExtractor { @Nonnull @Override - public InfoItemsPage getInitialPage() throws IOException, ExtractionException { + public InfoItemsPage getInitialPage() throws ExtractionException { return new InfoItemsPage<>(collectItems(doc), getNextPageUrl()); } @Override public String getNextPageUrl() throws ExtractionException { - return getUrl() + "&page=" + Integer.toString( 2); + return getUrl() + "&page=" + 2; } @Override @@ -104,7 +98,7 @@ public class YoutubeSearchExtractor extends SearchExtractor { .getQuery()) .get("page")); - return currentUrl.replace("&page=" + Integer.toString( pageNr), + return currentUrl.replace("&page=" + pageNr, "&page=" + Integer.toString(pageNr + 1)); } 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 9dd0a6371..f33f7b8a5 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 @@ -50,7 +50,7 @@ public class YoutubeTrendingExtractor extends KioskExtractor { @Override public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException { - final String contentCountry = getContentCountry(); + final String contentCountry = getLocalization().getCountry(); String url = getUrl(); if(contentCountry != null && !contentCountry.isEmpty()) { url += "?gl=" + contentCountry; 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 fb61797bf..8dee92e09 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 @@ -51,7 +51,6 @@ public class YoutubeTrendingExtractorTest { .getKioskList() .getExtractorById("Trending", null); extractor.fetchPage(); - extractor.setContentCountry("de"); } @Test From 0920680708b79a59d351f64ef57e6fb3cdcd98b0 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sat, 6 Oct 2018 17:03:55 +0200 Subject: [PATCH 3/4] fix search country for next page --- .../services/youtube/extractors/YoutubeSearchExtractor.java | 2 +- .../youtube/search/YoutubeSearchExtractorChannelOnlyTest.java | 4 ++-- .../youtube/search/YoutubeSearchExtractorDefaultTest.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) 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 2d411fa78..ddac54996 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 @@ -79,7 +79,7 @@ public class YoutubeSearchExtractor extends SearchExtractor { @Override public String getNextPageUrl() throws ExtractionException { - return getUrl() + "&page=" + 2; + return getUrl() + "&page=" + 2 + "&gl=" + getLocalization().getCountry(); } @Override 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 3b86042d8..937cee5ec 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 @@ -45,12 +45,12 @@ public class YoutubeSearchExtractorChannelOnlyTest extends YoutubeSearchExtracto } assertFalse("First and second page are equal", equals); - assertEquals("https://www.youtube.com/results?q=pewdiepie&sp=EgIQAlAU&page=3", secondPage.getNextPageUrl()); + assertEquals("https://www.youtube.com/results?q=pewdiepie&sp=EgIQAlAU&page=3&gl=GB", secondPage.getNextPageUrl()); } @Test public void testGetSecondPageUrl() throws Exception { - assertEquals("https://www.youtube.com/results?q=pewdiepie&sp=EgIQAlAU&page=2", extractor.getNextPageUrl()); + assertEquals("https://www.youtube.com/results?q=pewdiepie&sp=EgIQAlAU&page=2&gl=GB", extractor.getNextPageUrl()); } @Test 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 234ea5f96..6b0d09c7e 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 @@ -53,7 +53,7 @@ public class YoutubeSearchExtractorDefaultTest extends YoutubeSearchExtractorBas @Test public void testGetSecondPageUrl() throws Exception { - assertEquals("https://www.youtube.com/results?q=pewdiepie&page=2", extractor.getNextPageUrl()); + assertEquals("https://www.youtube.com/results?q=pewdiepie&page=2&gl=GB", extractor.getNextPageUrl()); } @Test @@ -96,7 +96,7 @@ public class YoutubeSearchExtractorDefaultTest extends YoutubeSearchExtractorBas } assertFalse("First and second page are equal", equals); - assertEquals("https://www.youtube.com/results?q=pewdiepie&page=3", secondPage.getNextPageUrl()); + assertEquals("https://www.youtube.com/results?q=pewdiepie&page=3&gl=GB", secondPage.getNextPageUrl()); } @Test From 24cb684e235314bdf2bb45be7d8e07f01bae6fd2 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sat, 6 Oct 2018 17:11:12 +0200 Subject: [PATCH 4/4] fix failing test --- .../youtube/search/YoutubeSearchExtractorDefaultTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6b0d09c7e..3df6434ee 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 @@ -58,7 +58,7 @@ public class YoutubeSearchExtractorDefaultTest extends YoutubeSearchExtractorBas @Test public void testResultList_FirstElement() { - InfoItem firstInfoItem = itemsPage.getItems().get(0); + InfoItem firstInfoItem = itemsPage.getItems().get(1); // THe channel should be the first item assertTrue(firstInfoItem instanceof ChannelInfoItem);