Return null for related streams at age restricted videos

This commit is contained in:
wb9688 2020-02-25 16:14:49 +01:00 committed by TobiGr
parent 9efcc61ca6
commit eed29ea734

View file

@ -177,7 +177,6 @@ public class YoutubeStreamExtractor extends StreamExtractor {
@Override @Override
public int getAgeLimit() throws ParsingException { public int getAgeLimit() throws ParsingException {
assertPageFetched(); assertPageFetched();
// TODO: Find new way to get age limit
if (!isAgeRestricted) { if (!isAgeRestricted) {
return NO_AGE_LIMIT; return NO_AGE_LIMIT;
} }
@ -497,6 +496,9 @@ public class YoutubeStreamExtractor extends StreamExtractor {
@Override @Override
public StreamInfoItem getNextStream() throws ExtractionException { public StreamInfoItem getNextStream() throws ExtractionException {
assertPageFetched(); assertPageFetched();
if (isAgeRestricted) {
return null;
}
try { try {
final JsonObject videoInfo = initialData.getObject("contents").getObject("twoColumnWatchNextResults") final JsonObject videoInfo = initialData.getObject("contents").getObject("twoColumnWatchNextResults")
.getObject("secondaryResults").getObject("secondaryResults").getArray("results") .getObject("secondaryResults").getObject("secondaryResults").getArray("results")
@ -515,6 +517,9 @@ public class YoutubeStreamExtractor extends StreamExtractor {
@Override @Override
public StreamInfoItemsCollector getRelatedStreams() throws ExtractionException { public StreamInfoItemsCollector getRelatedStreams() throws ExtractionException {
assertPageFetched(); assertPageFetched();
if (isAgeRestricted) {
return null;
}
try { try {
StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId()); StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
JsonArray results = initialData.getObject("contents").getObject("twoColumnWatchNextResults") JsonArray results = initialData.getObject("contents").getObject("twoColumnWatchNextResults")