1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-07-04 02:53:31 +00:00

fix rising exception for empty related videos

This commit is contained in:
Christian Schabesberger 2016-09-12 00:56:20 +02:00
parent a63128bd45
commit bd7077c1cf

View File

@ -668,12 +668,15 @@ public class YoutubeStreamExtractor extends StreamExtractor {
public StreamPreviewInfoCollector getRelatedVideos() throws ParsingException { public StreamPreviewInfoCollector getRelatedVideos() throws ParsingException {
try { try {
StreamPreviewInfoCollector collector = getStreamPreviewInfoCollector(); StreamPreviewInfoCollector collector = getStreamPreviewInfoCollector();
for (Element li : doc.select("ul[id=\"watch-related\"]").first().children()) { Element ul = doc.select("ul[id=\"watch-related\"]").first();
if(ul != null) {
for (Element li : ul.children()) {
// first check if we have a playlist. If so leave them out // first check if we have a playlist. If so leave them out
if (li.select("a[class*=\"content-link\"]").first() != null) { if (li.select("a[class*=\"content-link\"]").first() != null) {
collector.commit(extractVideoPreviewInfo(li)); collector.commit(extractVideoPreviewInfo(li));
} }
} }
}
return collector; return collector;
} catch(Exception e) { } catch(Exception e) {
throw new ParsingException("Could not get related videos", e); throw new ParsingException("Could not get related videos", e);