fix failing watch links

This commit is contained in:
Christian Schabesberger 2018-09-20 13:51:06 +02:00
parent 1e7bcfbd66
commit 49c2eb5185
2 changed files with 9 additions and 11 deletions

View File

@ -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());
}
}

View File

@ -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..."));
}
}
}