From 88282761f44921e0533afdf93a4d83de0c0a4c20 Mon Sep 17 00:00:00 2001 From: wb9688 Date: Wed, 26 Feb 2020 16:19:42 +0100 Subject: [PATCH] Fix YoutubeStreamExtractor not being able to getAgeLimit() in onFetchPage() --- .../services/youtube/extractors/YoutubeStreamExtractor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 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 516dc1817..8a725593c 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 @@ -260,7 +260,7 @@ public class YoutubeStreamExtractor extends StreamExtractor { @Override public int getAgeLimit() { - assertPageFetched(); + if (initialData == null || initialData.isEmpty()) throw new IllegalStateException("initialData is not parsed yet"); if (initialData.getObject("contents").getObject("twoColumnWatchNextResults") .getObject("secondaryResults") == null) { return 18; @@ -672,6 +672,7 @@ public class YoutubeStreamExtractor extends StreamExtractor { doc = YoutubeParsingHelper.parseAndCheckPage(verifiedUrl, response); final String playerUrl; + initialData = YoutubeParsingHelper.getInitialData(pageHtml); // Check if the video is age restricted if (getAgeLimit() == 18) { final EmbeddedInfo info = getEmbeddedInfo(); @@ -685,7 +686,6 @@ public class YoutubeStreamExtractor extends StreamExtractor { playerUrl = getPlayerUrl(ytPlayerConfig); } playerResponse = getPlayerResponse(); - initialData = YoutubeParsingHelper.getInitialData(pageHtml); if (decryptionCode.isEmpty()) { decryptionCode = loadDecryptionCode(playerUrl);