From 49c2eb51859a58e4bb5ead2d9d0771408f7d59d6 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Thu, 20 Sep 2018 13:51:06 +0200 Subject: [PATCH] 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...")); } } }