[YouTube] Do not crash if there is no next stream, but return null

Like every other extractor does if there is no next stream
This commit is contained in:
Stypox 2020-03-14 14:02:48 +01:00
parent 6446abc6d1
commit 325a51f73a
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
1 changed files with 12 additions and 4 deletions

View File

@ -523,10 +523,18 @@ public class YoutubeStreamExtractor extends StreamExtractor {
if (getAgeLimit() != NO_AGE_LIMIT) return null;
try {
final JsonObject videoInfo = initialData.getObject("contents").getObject("twoColumnWatchNextResults")
.getObject("secondaryResults").getObject("secondaryResults").getArray("results")
.getObject(0).getObject("compactAutoplayRenderer").getArray("contents")
.getObject(0).getObject("compactVideoRenderer");
final JsonObject firstWatchNextItem = initialData.getObject("contents")
.getObject("twoColumnWatchNextResults").getObject("secondaryResults")
.getObject("secondaryResults").getArray("results").getObject(0);
if (!firstWatchNextItem.has("compactAutoplayRenderer")) {
// there is no "next" stream
return null;
}
final JsonObject videoInfo = firstWatchNextItem.getObject("compactAutoplayRenderer")
.getArray("contents").getObject(0).getObject("compactVideoRenderer");
final TimeAgoParser timeAgoParser = getTimeAgoParser();
StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());