From f57d9d43ceb0ef329fc3959226c9db3f626a061b Mon Sep 17 00:00:00 2001 From: 7FM <> Date: Sat, 21 Dec 2019 13:17:58 +0100 Subject: [PATCH 01/14] fix switching on null causing NPE --- .../services/youtube/extractors/YoutubeStreamExtractor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 671db465d..23566f676 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 @@ -662,7 +662,7 @@ public class YoutubeStreamExtractor extends StreamExtractor { } } - return errorReason != null ? errorReason.toString() : null; + return errorReason != null ? errorReason.toString() : ""; } /*////////////////////////////////////////////////////////////////////////// From 0a3422a591f49c2bc9a1643ca93b690fbc65eb5b Mon Sep 17 00:00:00 2001 From: Zsombor Gegesy Date: Thu, 28 Nov 2019 22:04:29 +0100 Subject: [PATCH 02/14] Fix invalid jsoup query --- .../services/youtube/extractors/YoutubeStreamExtractor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 671db465d..f1a039bca 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 @@ -697,7 +697,7 @@ public class YoutubeStreamExtractor extends StreamExtractor { final String playerUrl; // Check if the video is age restricted - if (!doc.select("meta[property=\"og:restrictions:age\"").isEmpty()) { + if (!doc.select("meta[property=\"og:restrictions:age\"]").isEmpty()) { final EmbeddedInfo info = getEmbeddedInfo(); final String videoInfoUrl = getVideoInfoUrl(getId(), info.sts); final String infoPageResponse = downloader.get(videoInfoUrl, getExtractorLocalization()).responseBody(); From 2123b3abd3ad9bae4cb9b7069d03d737c7a213e0 Mon Sep 17 00:00:00 2001 From: Zsombor Gegesy Date: Thu, 21 Nov 2019 23:03:14 +0100 Subject: [PATCH 03/14] Fix search result paging - due to the way as the InfoItemsSearchCollector are re-used, the returned item list just grows, which cause that same videos are returned. --- .../services/media_ccc/extractors/MediaCCCSearchExtractor.java | 1 + .../extractor/services/soundcloud/SoundcloudSearchExtractor.java | 1 + .../services/youtube/extractors/YoutubeSearchExtractor.java | 1 + 3 files changed, 3 insertions(+) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCSearchExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCSearchExtractor.java index eab97ce32..429445f24 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCSearchExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCSearchExtractor.java @@ -48,6 +48,7 @@ public class MediaCCCSearchExtractor extends SearchExtractor { @Override public InfoItemsPage getInitialPage() throws IOException, ExtractionException { InfoItemsSearchCollector searchItems = getInfoItemSearchCollector(); + searchItems.reset(); if(getLinkHandler().getContentFilters().contains(CONFERENCES) || getLinkHandler().getContentFilters().contains(ALL) 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 97e69dc6f..9ed340fa1 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 @@ -76,6 +76,7 @@ public class SoundcloudSearchExtractor extends SearchExtractor { private InfoItemsCollector collectItems(JsonArray searchCollection) { final InfoItemsSearchCollector collector = getInfoItemSearchCollector(); + collector.reset(); for (Object result : searchCollection) { if (!(result instanceof JsonObject)) continue; 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 f6236e93a..2e3aad320 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 @@ -106,6 +106,7 @@ public class YoutubeSearchExtractor extends SearchExtractor { private InfoItemsSearchCollector collectItems(Document doc) throws NothingFoundException { InfoItemsSearchCollector collector = getInfoItemSearchCollector(); + collector.reset(); Element list = doc.select("ol[class=\"item-section\"]").first(); final TimeAgoParser timeAgoParser = getTimeAgoParser(); From 68b0fd9650b5cd459e142bbf175d48b9cbcfd39f Mon Sep 17 00:00:00 2001 From: Zsombor Gegesy Date: Wed, 4 Dec 2019 23:57:44 +0100 Subject: [PATCH 04/14] Add test for search paging --- .../search/YoutubeSearchPagingTest.java | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchPagingTest.java diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchPagingTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchPagingTest.java new file mode 100644 index 000000000..b4596633d --- /dev/null +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchPagingTest.java @@ -0,0 +1,78 @@ +package org.schabi.newpipe.extractor.services.youtube.search; + +import static java.util.Collections.singletonList; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.schabi.newpipe.extractor.ServiceList.YouTube; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.schabi.newpipe.DownloaderTestImpl; +import org.schabi.newpipe.extractor.InfoItem; +import org.schabi.newpipe.extractor.ListExtractor; +import org.schabi.newpipe.extractor.NewPipe; +import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeSearchExtractor; +import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeSearchQueryHandlerFactory; + +public class YoutubeSearchPagingTest { + private static ListExtractor.InfoItemsPage page1; + private static ListExtractor.InfoItemsPage page2; + private static Set urlList1; + private static Set urlList2; + + @BeforeClass + public static void setUpClass() throws Exception { + NewPipe.init(DownloaderTestImpl.getInstance()); + + YoutubeSearchExtractor extractor = (YoutubeSearchExtractor) YouTube.getSearchExtractor("cirque du soleil", + singletonList(YoutubeSearchQueryHandlerFactory.VIDEOS), null); + + extractor.fetchPage(); + page1 = extractor.getInitialPage(); + urlList1 = extractUrls(page1.getItems()); + assertEquals("page with items loaded", 20, page1.getItems().size()); + assertEquals("distinct videos", 20, urlList1.size()); + + assertTrue("has more page", page1.hasNextPage()); + assertNotNull("has next page url", page1.getNextPageUrl()); + page2 = extractor.getPage(page1.getNextPageUrl()); + urlList2 = extractUrls(page2.getItems()); + } + + private static Set extractUrls(List list) { + Set result = new HashSet<>(); + for (InfoItem item : list) { + result.add(item.getUrl()); + } + return result; + } + + @Test + public void firstPageOk() { + assertEquals("page with items loaded", 20, page1.getItems().size()); + assertEquals("distinct videos", 20, urlList1.size()); + } + + @Test + public void secondPageLength() { + assertEquals("one page", 20, page2.getItems().size()); + } + + @Test + public void secondPageUniqueVideos() { + assertEquals("distinct videos", 20, urlList2.size()); + } + + @Test + public void noRepeatingVideosInPages() { + Set intersection = new HashSet<>(urlList2); + intersection.retainAll(urlList1); + assertEquals("empty intersection", 0, intersection.size()); + } + +} \ No newline at end of file From 64729e535723ccbc15b656d6f732a79ea97b388d Mon Sep 17 00:00:00 2001 From: Zsombor Gegesy Date: Sat, 7 Dec 2019 22:58:01 +0100 Subject: [PATCH 05/14] Improve the tests --- .../search/YoutubeSearchPagingTest.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchPagingTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchPagingTest.java index b4596633d..50776abc9 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchPagingTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchPagingTest.java @@ -24,6 +24,7 @@ public class YoutubeSearchPagingTest { private static ListExtractor.InfoItemsPage page2; private static Set urlList1; private static Set urlList2; + private static int pageSize; @BeforeClass public static void setUpClass() throws Exception { @@ -35,10 +36,11 @@ public class YoutubeSearchPagingTest { extractor.fetchPage(); page1 = extractor.getInitialPage(); urlList1 = extractUrls(page1.getItems()); - assertEquals("page with items loaded", 20, page1.getItems().size()); - assertEquals("distinct videos", 20, urlList1.size()); + assertTrue("page with items loaded", 15 < page1.getItems().size()); + pageSize = page1.getItems().size(); + assertEquals("they are all distinct, no repetition", pageSize, urlList1.size()); - assertTrue("has more page", page1.hasNextPage()); + assertTrue("has more than one page of results", page1.hasNextPage()); assertNotNull("has next page url", page1.getNextPageUrl()); page2 = extractor.getPage(page1.getNextPageUrl()); urlList2 = extractUrls(page2.getItems()); @@ -54,25 +56,25 @@ public class YoutubeSearchPagingTest { @Test public void firstPageOk() { - assertEquals("page with items loaded", 20, page1.getItems().size()); - assertEquals("distinct videos", 20, urlList1.size()); + assertTrue("first page contains the expected number of items", 15 < page1.getItems().size()); + assertEquals("they are all distinct, no repetition", pageSize, urlList1.size()); } @Test public void secondPageLength() { - assertEquals("one page", 20, page2.getItems().size()); + assertEquals("second page contains only the expected number of items", pageSize, page2.getItems().size()); } @Test public void secondPageUniqueVideos() { - assertEquals("distinct videos", 20, urlList2.size()); + assertEquals("they are all distinct, no repetition", pageSize, urlList2.size()); } @Test public void noRepeatingVideosInPages() { Set intersection = new HashSet<>(urlList2); intersection.retainAll(urlList1); - assertEquals("empty intersection", 0, intersection.size()); + assertEquals("Found a duplicated video on second search page", 0, intersection.size()); } } \ No newline at end of file From 0b6e37e71f6679cecf983f5be65e6a16bf7fe525 Mon Sep 17 00:00:00 2001 From: TobiGr Date: Tue, 31 Dec 2019 00:18:53 +0100 Subject: [PATCH 06/14] Improve YouTubeSearchPagingtest --- .../search/YoutubeSearchPagingTest.java | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchPagingTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchPagingTest.java index 50776abc9..7df7b0cb3 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchPagingTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/search/YoutubeSearchPagingTest.java @@ -24,7 +24,8 @@ public class YoutubeSearchPagingTest { private static ListExtractor.InfoItemsPage page2; private static Set urlList1; private static Set urlList2; - private static int pageSize; + private static int page1Size; + private static int page2Size; @BeforeClass public static void setUpClass() throws Exception { @@ -36,14 +37,15 @@ public class YoutubeSearchPagingTest { extractor.fetchPage(); page1 = extractor.getInitialPage(); urlList1 = extractUrls(page1.getItems()); - assertTrue("page with items loaded", 15 < page1.getItems().size()); - pageSize = page1.getItems().size(); - assertEquals("they are all distinct, no repetition", pageSize, urlList1.size()); + assertTrue("failed to load search result page one: too few items", 15 < page1.getItems().size()); + page1Size = page1.getItems().size(); + assertEquals("duplicated items in search result on page one", page1Size, urlList1.size()); - assertTrue("has more than one page of results", page1.hasNextPage()); - assertNotNull("has next page url", page1.getNextPageUrl()); + assertTrue("search result has no second page", page1.hasNextPage()); + assertNotNull("next page url is null", page1.getNextPageUrl()); page2 = extractor.getPage(page1.getNextPageUrl()); urlList2 = extractUrls(page2.getItems()); + page2Size = page2.getItems().size(); } private static Set extractUrls(List list) { @@ -54,27 +56,16 @@ public class YoutubeSearchPagingTest { return result; } - @Test - public void firstPageOk() { - assertTrue("first page contains the expected number of items", 15 < page1.getItems().size()); - assertEquals("they are all distinct, no repetition", pageSize, urlList1.size()); - } - - @Test - public void secondPageLength() { - assertEquals("second page contains only the expected number of items", pageSize, page2.getItems().size()); - } - @Test public void secondPageUniqueVideos() { - assertEquals("they are all distinct, no repetition", pageSize, urlList2.size()); + assertEquals("Second search result page has duplicated items", page2Size, urlList2.size()); } @Test public void noRepeatingVideosInPages() { Set intersection = new HashSet<>(urlList2); intersection.retainAll(urlList1); - assertEquals("Found a duplicated video on second search page", 0, intersection.size()); + assertEquals("Found the same item on first AND second search page", 0, intersection.size()); } } \ No newline at end of file From d4e0930f44300fab9eb07574403b2b4f42f7ca70 Mon Sep 17 00:00:00 2001 From: pihug12 Date: Tue, 31 Dec 2019 23:36:23 +0100 Subject: [PATCH 07/14] [Soundcloud] Update client_id --- .../extractor/services/soundcloud/SoundcloudParsingHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java index b01830d7d..4617f9163 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java @@ -31,7 +31,7 @@ import static org.schabi.newpipe.extractor.ServiceList.SoundCloud; import static org.schabi.newpipe.extractor.utils.Utils.replaceHttpWithHttps; public class SoundcloudParsingHelper { - private static final String HARDCODED_CLIENT_ID = "bkcJLoXNaiFlsLaKBQXOxO5FhW0NJVnu"; // Updated on 29/11/19 + private static final String HARDCODED_CLIENT_ID = "r5ELVSy3RkcjX7ilaL7n2v1Z8irA9SL8"; // Updated on 31/12/19 private static String clientId; private SoundcloudParsingHelper() { From 4aaf123f24a3b7763c07547fc81c199e45233149 Mon Sep 17 00:00:00 2001 From: TobiGr Date: Tue, 14 Jan 2020 14:40:39 +0100 Subject: [PATCH 08/14] Add PeerTube to supported services in README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3cf4e4c5b..f8c9c8cf2 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ The following sites are currently supported: - YouTube - SoundCloud - MediaCCC +- PeerTube (no P2P) ## License From 3743c60695c7a4349b5ddec9bedee13b3fb75c26 Mon Sep 17 00:00:00 2001 From: B0pol Date: Wed, 15 Jan 2020 14:27:52 +0100 Subject: [PATCH 09/14] fix: typos in Test --- .../peertube/PeertubeChannelLinkHandlerFactoryTest.java | 2 +- .../peertube/PeertubeCommentsLinkHandlerFactoryTest.java | 2 +- .../peertube/PeertubePlaylistLinkHandlerFactoryTest.java | 2 +- .../services/youtube/YoutubeChannelLinkHandlerFactoryTest.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeChannelLinkHandlerFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeChannelLinkHandlerFactoryTest.java index d90e4321b..633307a28 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeChannelLinkHandlerFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeChannelLinkHandlerFactoryTest.java @@ -24,7 +24,7 @@ public class PeertubeChannelLinkHandlerFactoryTest { } @Test - public void acceptrUrlTest() throws ParsingException { + public void acceptUrlTest() throws ParsingException { assertTrue(linkHandler.acceptUrl("https://peertube.mastodon.host/accounts/kranti@videos.squat.net")); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeCommentsLinkHandlerFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeCommentsLinkHandlerFactoryTest.java index c13150302..fcc27c54d 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeCommentsLinkHandlerFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeCommentsLinkHandlerFactoryTest.java @@ -24,7 +24,7 @@ public class PeertubeCommentsLinkHandlerFactoryTest { } @Test - public void acceptrUrlTest() throws ParsingException { + public void acceptUrlTest() throws ParsingException { assertTrue(linkHandler.acceptUrl("https://peertube.mastodon.host/api/v1/videos/19319/comment-threads?start=0&count=10&sort=-createdAt")); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubePlaylistLinkHandlerFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubePlaylistLinkHandlerFactoryTest.java index 77e7d2e84..9ad291027 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubePlaylistLinkHandlerFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubePlaylistLinkHandlerFactoryTest.java @@ -24,7 +24,7 @@ public class PeertubePlaylistLinkHandlerFactoryTest { } @Test - public void acceptrUrlTest() throws ParsingException { + public void acceptUrlTest() throws ParsingException { assertTrue(linkHandler.acceptUrl("https://peertube.mastodon.host/video-channels/b45e84fb-c47f-475b-94f2-718126154d33/videos")); } 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 7b4814cf6..4c598a9b6 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 @@ -24,7 +24,7 @@ public class YoutubeChannelLinkHandlerFactoryTest { } @Test - public void acceptrUrlTest() throws ParsingException { + public void acceptUrlTest() throws ParsingException { assertTrue(linkHandler.acceptUrl("https://www.youtube.com/user/Gronkh")); assertTrue(linkHandler.acceptUrl("https://www.youtube.com/user/Netzkino/videos")); From a12c0e2a37ff2697aa528cb13d69713bc860997b Mon Sep 17 00:00:00 2001 From: B0pol Date: Fri, 17 Jan 2020 12:09:59 +0100 Subject: [PATCH 10/14] fix:invidious: getID and onAccpetURl for comments --- .../YoutubeCommentsLinkHandlerFactory.java | 222 ++++++++++++------ .../youtube/YoutubeCommentsExtractorTest.java | 4 +- 2 files changed, 157 insertions(+), 69 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeCommentsLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeCommentsLinkHandlerFactory.java index 036529abd..8dc8715f2 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeCommentsLinkHandlerFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeCommentsLinkHandlerFactory.java @@ -1,13 +1,15 @@ package org.schabi.newpipe.extractor.services.youtube.linkHandler; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.util.List; - import org.schabi.newpipe.extractor.exceptions.FoundAdException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory; -import org.schabi.newpipe.extractor.utils.Parser; +import org.schabi.newpipe.extractor.utils.Utils; + +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.List; public class YoutubeCommentsLinkHandlerFactory extends ListLinkHandlerFactory { @@ -18,84 +20,170 @@ public class YoutubeCommentsLinkHandlerFactory extends ListLinkHandlerFactory { return instance; } + private static String assertIsID(String id) throws ParsingException { + if (id == null || !id.matches("[a-zA-Z0-9_-]{11}")) { + throw new ParsingException("The given string is not a Youtube-Video-ID"); + } + + return id; + } + @Override public String getUrl(String id) { return "https://m.youtube.com/watch?v=" + id; } @Override - public String getId(String url) throws ParsingException, IllegalArgumentException { - if (url.isEmpty()) { - throw new IllegalArgumentException("The url parameter should not be empty"); - } + public String getId(String urlString) throws ParsingException, IllegalArgumentException { + try { + URI uri = new URI(urlString); + String scheme = uri.getScheme(); - String id; - String lowercaseUrl = url.toLowerCase(); - if (lowercaseUrl.contains("youtube")) { - if (url.contains("attribution_link")) { - try { - String escapedQuery = Parser.matchGroup1("u=(.[^&|$]*)", url); - String query = URLDecoder.decode(escapedQuery, "UTF-8"); - id = Parser.matchGroup1("v=" + ID_PATTERN, query); - } catch (UnsupportedEncodingException uee) { - throw new ParsingException("Could not parse attribution_link", uee); + if (scheme != null && (scheme.equals("vnd.youtube") || scheme.equals("vnd.youtube.launch"))) { + String schemeSpecificPart = uri.getSchemeSpecificPart(); + if (schemeSpecificPart.startsWith("//")) { + urlString = "https:" + schemeSpecificPart; + } else { + return assertIsID(schemeSpecificPart); } - } else if (url.contains("vnd.youtube")) { - id = Parser.matchGroup1(ID_PATTERN, url); - } else if (url.contains("embed")) { - id = Parser.matchGroup1("embed/" + ID_PATTERN, url); - } else if (url.contains("googleads")) { - throw new FoundAdException("Error found add: " + url); - } else { - id = Parser.matchGroup1("[?&]v=" + ID_PATTERN, url); } - } else if (lowercaseUrl.contains("youtu.be")) { - if (url.contains("v=")) { - id = Parser.matchGroup1("v=" + ID_PATTERN, url); - } else { - id = Parser.matchGroup1("[Yy][Oo][Uu][Tt][Uu]\\.[Bb][Ee]/" + ID_PATTERN, url); - } - } else if(lowercaseUrl.contains("hooktube")) { - if(lowercaseUrl.contains("&v=") - || lowercaseUrl.contains("?v=")) { - id = Parser.matchGroup1("[?&]v=" + ID_PATTERN, url); - } else if (url.contains("/embed/")) { - id = Parser.matchGroup1("embed/" + ID_PATTERN, url); - } else if (url.contains("/v/")) { - id = Parser.matchGroup1("v/" + ID_PATTERN, url); - } else if (url.contains("/watch/")) { - id = Parser.matchGroup1("watch/" + ID_PATTERN, url); - } else { - throw new ParsingException("Error no suitable url: " + url); - } - } else { - throw new ParsingException("Error no suitable url: " + url); + } catch (URISyntaxException ignored) { } - - if (!id.isEmpty()) { - return id; - } else { - throw new ParsingException("Error could not parse url: " + url); + URL url; + try { + url = Utils.stringToURL(urlString); + } catch (MalformedURLException e) { + throw new IllegalArgumentException("The given URL is not valid"); } + + String host = url.getHost(); + String path = url.getPath(); + // remove leading "/" of URL-path if URL-path is given + if (!path.isEmpty()) { + path = path.substring(1); + } + + if (!Utils.isHTTP(url) || !(YoutubeParsingHelper.isYoutubeURL(url) || + YoutubeParsingHelper.isYoutubeServiceURL(url) || YoutubeParsingHelper.isHooktubeURL(url) || + YoutubeParsingHelper.isInvidioURL(url))) { + if (host.equalsIgnoreCase("googleads.g.doubleclick.net")) { + throw new FoundAdException("Error found ad: " + urlString); + } + + throw new ParsingException("The url is not a Youtube-URL"); + } + + if (YoutubePlaylistLinkHandlerFactory.getInstance().acceptUrl(urlString)) { + throw new ParsingException("Error no suitable url: " + urlString); + } + + // using uppercase instead of lowercase, because toLowercase replaces some unicode characters + // with their lowercase ASCII equivalent. Using toLowercase could result in faultily matching unicode urls. + switch (host.toUpperCase()) { + case "WWW.YOUTUBE-NOCOOKIE.COM": { + if (path.startsWith("embed/")) { + String id = path.split("/")[1]; + + return assertIsID(id); + } + + break; + } + + case "YOUTUBE.COM": + case "WWW.YOUTUBE.COM": + case "M.YOUTUBE.COM": + case "MUSIC.YOUTUBE.COM": { + if (path.equals("attribution_link")) { + String uQueryValue = Utils.getQueryValue(url, "u"); + + URL decodedURL; + try { + decodedURL = Utils.stringToURL("http://www.youtube.com" + uQueryValue); + } catch (MalformedURLException e) { + throw new ParsingException("Error no suitable url: " + urlString); + } + + String viewQueryValue = Utils.getQueryValue(decodedURL, "v"); + return assertIsID(viewQueryValue); + } + + if (path.startsWith("embed/")) { + String id = path.split("/")[1]; + + return assertIsID(id); + } + + String viewQueryValue = Utils.getQueryValue(url, "v"); + return assertIsID(viewQueryValue); + } + + case "YOUTU.BE": { + String viewQueryValue = Utils.getQueryValue(url, "v"); + if (viewQueryValue != null) { + return assertIsID(viewQueryValue); + } + + return assertIsID(path); + } + + case "HOOKTUBE.COM": { + if (path.startsWith("v/")) { + String id = path.substring("v/".length()); + + return assertIsID(id); + } + if (path.startsWith("watch/")) { + String id = path.substring("watch/".length()); + + return assertIsID(id); + } + // there is no break-statement here on purpose so the next code-block gets also run for hooktube + } + + case "WWW.INVIDIO.US": + case "DEV.INVIDIO.US": + case "INVIDIO.US": + case "INVIDIOUS.SNOPYTA.ORG": + case "DE.INVIDIOUS.SNOPYTA.ORG": + case "FI.INVIDIOUS.SNOPYTA.ORG": + case "VID.WXZM.SX": + case "INVIDIOUS.KABI.TK": + case "INVIDIOU.SH": + case "WWW.INVIDIOU.SH": + case "NO.INVIDIOU.SH": + case "INVIDIOUS.ENKIRTON.NET": + case "TUBE.POAL.CO": + case "INVIDIOUS.13AD.DE": + case "YT.ELUKERIO.ORG": { // code-block for hooktube.com and Invidious instances + if (path.equals("watch")) { + String viewQueryValue = Utils.getQueryValue(url, "v"); + if (viewQueryValue != null) { + return assertIsID(viewQueryValue); + } + } + if (path.startsWith("embed/")) { + String id = path.substring("embed/".length()); + + return assertIsID(id); + } + + break; + } + } + + throw new ParsingException("Error no suitable url: " + urlString); } @Override public boolean onAcceptUrl(final String url) throws FoundAdException { - final String lowercaseUrl = url.toLowerCase(); - if (lowercaseUrl.contains("youtube") - || lowercaseUrl.contains("youtu.be") - || lowercaseUrl.contains("hooktube")) { - // bad programming I know - try { - getId(url); - return true; - } catch (FoundAdException fe) { - throw fe; - } catch (ParsingException e) { - return false; - } - } else { + try { + getId(url); + return true; + } catch (FoundAdException fe) { + throw fe; + } catch (ParsingException e) { return false; } } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java index 6bf76b615..79f13b6bf 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java @@ -27,7 +27,7 @@ public class YoutubeCommentsExtractorTest { public static void setUp() throws Exception { NewPipe.init(DownloaderTestImpl.getInstance()); extractor = (YoutubeCommentsExtractor) YouTube - .getCommentsExtractor("https://www.youtube.com/watch?v=D00Au7k3i6o"); + .getCommentsExtractor("https://www.invidio.us/watch?v=D00Au7k3i6o"); } @Test @@ -47,7 +47,7 @@ public class YoutubeCommentsExtractorTest { @Test public void testGetCommentsFromCommentsInfo() throws IOException, ExtractionException { boolean result = false; - CommentsInfo commentsInfo = CommentsInfo.getInfo("https://www.youtube.com/watch?v=D00Au7k3i6o"); + CommentsInfo commentsInfo = CommentsInfo.getInfo("https://www.invidio.us/watch?v=D00Au7k3i6o"); assertTrue("what the fuck am i doing with my life".equals(commentsInfo.getName())); result = findInComments(commentsInfo.getRelatedItems(), "s1ck m3m3"); From 02930d08f1c17d1bc95a6326bd86fd8e499a9cc5 Mon Sep 17 00:00:00 2001 From: B0pol Date: Fri, 17 Jan 2020 12:58:50 +0100 Subject: [PATCH 11/14] added comments test for invidious --- .../YoutubeCommentsLinkHandlerFactory.java | 1 - .../youtube/YoutubeCommentsExtractorTest.java | 46 +++++++++++++------ 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeCommentsLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeCommentsLinkHandlerFactory.java index 8dc8715f2..71e54568d 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeCommentsLinkHandlerFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeCommentsLinkHandlerFactory.java @@ -14,7 +14,6 @@ import java.util.List; public class YoutubeCommentsLinkHandlerFactory extends ListLinkHandlerFactory { private static final YoutubeCommentsLinkHandlerFactory instance = new YoutubeCommentsLinkHandlerFactory(); - private static final String ID_PATTERN = "([\\-a-zA-Z0-9_]{11})"; public static YoutubeCommentsLinkHandlerFactory getInstance() { return instance; diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java index 79f13b6bf..44a79621c 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java @@ -4,7 +4,6 @@ import org.jsoup.helper.StringUtil; import org.junit.BeforeClass; import org.junit.Test; import org.schabi.newpipe.DownloaderTestImpl; -import org.schabi.newpipe.DownloaderTestImpl; import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.comments.CommentsInfo; @@ -21,17 +20,32 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube; public class YoutubeCommentsExtractorTest { - private static YoutubeCommentsExtractor extractor; + private static final String urlYT = "https://www.youtube.com/watch?v=D00Au7k3i6o"; + private static final String urlInvidious = "https://invidio.us/watch?v=D00Au7k3i6o"; + private static final String urlInvidioush = "https://invidiou.sh/watch?v=D00Au7k3i6o"; + private static YoutubeCommentsExtractor extractorYT; + private static YoutubeCommentsExtractor extractorInvidious; + private static YoutubeCommentsExtractor extractorInvidioush; @BeforeClass public static void setUp() throws Exception { NewPipe.init(DownloaderTestImpl.getInstance()); - extractor = (YoutubeCommentsExtractor) YouTube - .getCommentsExtractor("https://www.invidio.us/watch?v=D00Au7k3i6o"); + extractorYT = (YoutubeCommentsExtractor) YouTube + .getCommentsExtractor(urlYT); + extractorInvidious = (YoutubeCommentsExtractor) YouTube + .getCommentsExtractor(urlInvidious); + extractorInvidioush = (YoutubeCommentsExtractor) YouTube + .getCommentsExtractor(urlInvidioush); } @Test public void testGetComments() throws IOException, ExtractionException { + assertTrue(getCommentsHelper(extractorYT)); + assertTrue(getCommentsHelper(extractorInvidious)); + assertTrue(getCommentsHelper(extractorInvidioush)); + } + + private boolean getCommentsHelper(YoutubeCommentsExtractor extractor) throws IOException, ExtractionException { boolean result; InfoItemsPage comments = extractor.getInitialPage(); result = findInComments(comments, "s1ck m3m3"); @@ -41,13 +55,20 @@ public class YoutubeCommentsExtractorTest { result = findInComments(comments, "s1ck m3m3"); } - assertTrue(result); + return result; + } @Test public void testGetCommentsFromCommentsInfo() throws IOException, ExtractionException { + assertTrue(getCommentsFromCommentsInfoHelper(urlYT)); + assertTrue(getCommentsFromCommentsInfoHelper(urlInvidious)); + assertTrue(getCommentsFromCommentsInfoHelper(urlInvidioush)); + } + + private boolean getCommentsFromCommentsInfoHelper(String url) throws IOException, ExtractionException { boolean result = false; - CommentsInfo commentsInfo = CommentsInfo.getInfo("https://www.invidio.us/watch?v=D00Au7k3i6o"); + CommentsInfo commentsInfo = CommentsInfo.getInfo(url); assertTrue("what the fuck am i doing with my life".equals(commentsInfo.getName())); result = findInComments(commentsInfo.getRelatedItems(), "s1ck m3m3"); @@ -57,16 +78,15 @@ public class YoutubeCommentsExtractorTest { result = findInComments(moreItems.getItems(), "s1ck m3m3"); nextPage = moreItems.getNextPageUrl(); } - - assertTrue(result); + return result; } - + @Test public void testGetCommentsAllData() throws IOException, ExtractionException { - InfoItemsPage comments = extractor.getInitialPage(); + InfoItemsPage comments = extractorYT.getInitialPage(); DefaultTests.defaultTestListOfItems(YouTube.getServiceId(), comments.getItems(), comments.getErrors()); - for(CommentsInfoItem c: comments.getItems()) { + for (CommentsInfoItem c : comments.getItems()) { assertFalse(StringUtil.isBlank(c.getAuthorEndpoint())); assertFalse(StringUtil.isBlank(c.getAuthorName())); assertFalse(StringUtil.isBlank(c.getAuthorThumbnail())); @@ -86,8 +106,8 @@ public class YoutubeCommentsExtractorTest { } private boolean findInComments(List comments, String comment) { - for(CommentsInfoItem c: comments) { - if(c.getCommentText().contains(comment)) { + for (CommentsInfoItem c : comments) { + if (c.getCommentText().contains(comment)) { return true; } } From 7e8d00981f9a8c508469525ebe55c8e0334e22d5 Mon Sep 17 00:00:00 2001 From: B0pol Date: Fri, 17 Jan 2020 13:44:55 +0100 Subject: [PATCH 12/14] changed getId() to remove duplicate code --- .../YoutubeCommentsLinkHandlerFactory.java | 153 +----------------- 1 file changed, 1 insertion(+), 152 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeCommentsLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeCommentsLinkHandlerFactory.java index 71e54568d..421fc13f3 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeCommentsLinkHandlerFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeCommentsLinkHandlerFactory.java @@ -3,12 +3,7 @@ package org.schabi.newpipe.extractor.services.youtube.linkHandler; import org.schabi.newpipe.extractor.exceptions.FoundAdException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory; -import org.schabi.newpipe.extractor.utils.Utils; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; import java.util.List; public class YoutubeCommentsLinkHandlerFactory extends ListLinkHandlerFactory { @@ -19,14 +14,6 @@ public class YoutubeCommentsLinkHandlerFactory extends ListLinkHandlerFactory { return instance; } - private static String assertIsID(String id) throws ParsingException { - if (id == null || !id.matches("[a-zA-Z0-9_-]{11}")) { - throw new ParsingException("The given string is not a Youtube-Video-ID"); - } - - return id; - } - @Override public String getUrl(String id) { return "https://m.youtube.com/watch?v=" + id; @@ -34,145 +21,7 @@ public class YoutubeCommentsLinkHandlerFactory extends ListLinkHandlerFactory { @Override public String getId(String urlString) throws ParsingException, IllegalArgumentException { - try { - URI uri = new URI(urlString); - String scheme = uri.getScheme(); - - if (scheme != null && (scheme.equals("vnd.youtube") || scheme.equals("vnd.youtube.launch"))) { - String schemeSpecificPart = uri.getSchemeSpecificPart(); - if (schemeSpecificPart.startsWith("//")) { - urlString = "https:" + schemeSpecificPart; - } else { - return assertIsID(schemeSpecificPart); - } - } - } catch (URISyntaxException ignored) { - } - - URL url; - try { - url = Utils.stringToURL(urlString); - } catch (MalformedURLException e) { - throw new IllegalArgumentException("The given URL is not valid"); - } - - String host = url.getHost(); - String path = url.getPath(); - // remove leading "/" of URL-path if URL-path is given - if (!path.isEmpty()) { - path = path.substring(1); - } - - if (!Utils.isHTTP(url) || !(YoutubeParsingHelper.isYoutubeURL(url) || - YoutubeParsingHelper.isYoutubeServiceURL(url) || YoutubeParsingHelper.isHooktubeURL(url) || - YoutubeParsingHelper.isInvidioURL(url))) { - if (host.equalsIgnoreCase("googleads.g.doubleclick.net")) { - throw new FoundAdException("Error found ad: " + urlString); - } - - throw new ParsingException("The url is not a Youtube-URL"); - } - - if (YoutubePlaylistLinkHandlerFactory.getInstance().acceptUrl(urlString)) { - throw new ParsingException("Error no suitable url: " + urlString); - } - - // using uppercase instead of lowercase, because toLowercase replaces some unicode characters - // with their lowercase ASCII equivalent. Using toLowercase could result in faultily matching unicode urls. - switch (host.toUpperCase()) { - case "WWW.YOUTUBE-NOCOOKIE.COM": { - if (path.startsWith("embed/")) { - String id = path.split("/")[1]; - - return assertIsID(id); - } - - break; - } - - case "YOUTUBE.COM": - case "WWW.YOUTUBE.COM": - case "M.YOUTUBE.COM": - case "MUSIC.YOUTUBE.COM": { - if (path.equals("attribution_link")) { - String uQueryValue = Utils.getQueryValue(url, "u"); - - URL decodedURL; - try { - decodedURL = Utils.stringToURL("http://www.youtube.com" + uQueryValue); - } catch (MalformedURLException e) { - throw new ParsingException("Error no suitable url: " + urlString); - } - - String viewQueryValue = Utils.getQueryValue(decodedURL, "v"); - return assertIsID(viewQueryValue); - } - - if (path.startsWith("embed/")) { - String id = path.split("/")[1]; - - return assertIsID(id); - } - - String viewQueryValue = Utils.getQueryValue(url, "v"); - return assertIsID(viewQueryValue); - } - - case "YOUTU.BE": { - String viewQueryValue = Utils.getQueryValue(url, "v"); - if (viewQueryValue != null) { - return assertIsID(viewQueryValue); - } - - return assertIsID(path); - } - - case "HOOKTUBE.COM": { - if (path.startsWith("v/")) { - String id = path.substring("v/".length()); - - return assertIsID(id); - } - if (path.startsWith("watch/")) { - String id = path.substring("watch/".length()); - - return assertIsID(id); - } - // there is no break-statement here on purpose so the next code-block gets also run for hooktube - } - - case "WWW.INVIDIO.US": - case "DEV.INVIDIO.US": - case "INVIDIO.US": - case "INVIDIOUS.SNOPYTA.ORG": - case "DE.INVIDIOUS.SNOPYTA.ORG": - case "FI.INVIDIOUS.SNOPYTA.ORG": - case "VID.WXZM.SX": - case "INVIDIOUS.KABI.TK": - case "INVIDIOU.SH": - case "WWW.INVIDIOU.SH": - case "NO.INVIDIOU.SH": - case "INVIDIOUS.ENKIRTON.NET": - case "TUBE.POAL.CO": - case "INVIDIOUS.13AD.DE": - case "YT.ELUKERIO.ORG": { // code-block for hooktube.com and Invidious instances - if (path.equals("watch")) { - String viewQueryValue = Utils.getQueryValue(url, "v"); - if (viewQueryValue != null) { - return assertIsID(viewQueryValue); - } - } - if (path.startsWith("embed/")) { - String id = path.substring("embed/".length()); - - return assertIsID(id); - } - - break; - } - } - - throw new ParsingException("Error no suitable url: " + urlString); + return YoutubeStreamLinkHandlerFactory.getInstance().getId(urlString); //we need the same id, avoids duplicate code } @Override From 5e81ed1dff5ab3109e02ac4ac98dcd093c6acd6b Mon Sep 17 00:00:00 2001 From: bopol Date: Fri, 17 Jan 2020 19:27:54 +0100 Subject: [PATCH 13/14] add support to /c/shortened_url channel links --- .../linkHandler/YoutubeChannelLinkHandlerFactory.java | 2 +- .../youtube/YoutubeChannelLinkHandlerFactoryTest.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeChannelLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeChannelLinkHandlerFactory.java index 5a2e687c9..eb34cf065 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeChannelLinkHandlerFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeChannelLinkHandlerFactory.java @@ -51,7 +51,7 @@ public class YoutubeChannelLinkHandlerFactory extends ListLinkHandlerFactory { throw new ParsingException("the URL given is not a Youtube-URL"); } - if (!path.startsWith("/user/") && !path.startsWith("/channel/")) { + if (!path.startsWith("/user/") && !path.startsWith("/channel/") && !path.startsWith("/c/")) { throw new ParsingException("the URL given is neither a channel nor an user"); } 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 7b4814cf6..3e70a44c9 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 @@ -28,6 +28,8 @@ public class YoutubeChannelLinkHandlerFactoryTest { assertTrue(linkHandler.acceptUrl("https://www.youtube.com/user/Gronkh")); assertTrue(linkHandler.acceptUrl("https://www.youtube.com/user/Netzkino/videos")); + assertTrue(linkHandler.acceptUrl("https://www.youtube.com/c/creatoracademy")); + assertTrue(linkHandler.acceptUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA")); assertTrue(linkHandler.acceptUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1")); @@ -64,5 +66,8 @@ public class YoutubeChannelLinkHandlerFactoryTest { assertEquals("channel/UClq42foiSgl7sSpLupnugGA", linkHandler.fromUrl("https://invidio.us/channel/UClq42foiSgl7sSpLupnugGA").getId()); assertEquals("channel/UClq42foiSgl7sSpLupnugGA", linkHandler.fromUrl("https://invidio.us/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1").getId()); + + assertEquals("c/creatoracademy", linkHandler.fromUrl("https://www.youtube.com/c/creatoracademy").getId()); + assertEquals("c/YouTubeCreators", linkHandler.fromUrl("https://www.youtube.com/c/YouTubeCreators").getId()); } } From 221e8dd171ac31ac684774d432079fb4b60e0e79 Mon Sep 17 00:00:00 2001 From: bopol Date: Fri, 17 Jan 2020 21:24:52 +0100 Subject: [PATCH 14/14] changed assertTrue(string.equals(string)) to assertEquals(string, string) --- .../services/youtube/YoutubeCommentsExtractorTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java index 44a79621c..3345ae3a4 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeCommentsExtractorTest.java @@ -56,7 +56,6 @@ public class YoutubeCommentsExtractorTest { } return result; - } @Test @@ -69,7 +68,7 @@ public class YoutubeCommentsExtractorTest { private boolean getCommentsFromCommentsInfoHelper(String url) throws IOException, ExtractionException { boolean result = false; CommentsInfo commentsInfo = CommentsInfo.getInfo(url); - assertTrue("what the fuck am i doing with my life".equals(commentsInfo.getName())); + assertEquals("what the fuck am i doing with my life", commentsInfo.getName()); result = findInComments(commentsInfo.getRelatedItems(), "s1ck m3m3"); String nextPage = commentsInfo.getNextPageUrl();