Use "getAgeLimit() != NO_AGE_LIMIT" instead of "getAgeLimit() == 18"

This commit is contained in:
wb9688 2020-02-28 16:40:50 +01:00
parent beb07a4852
commit 0b940f5cf4

View File

@ -504,9 +504,9 @@ public class YoutubeStreamExtractor extends StreamExtractor {
@Override @Override
public StreamInfoItem getNextStream() throws ExtractionException { public StreamInfoItem getNextStream() throws ExtractionException {
assertPageFetched(); assertPageFetched();
if (getAgeLimit() == 18) {
return null; if (getAgeLimit() != NO_AGE_LIMIT) 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")
@ -525,9 +525,9 @@ public class YoutubeStreamExtractor extends StreamExtractor {
@Override @Override
public StreamInfoItemsCollector getRelatedStreams() throws ExtractionException { public StreamInfoItemsCollector getRelatedStreams() throws ExtractionException {
assertPageFetched(); assertPageFetched();
if (getAgeLimit() == 18) {
return null; if (getAgeLimit() != NO_AGE_LIMIT) 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")
@ -773,7 +773,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
@Nonnull @Nonnull
private List<SubtitlesInfo> getAvailableSubtitlesInfo() { private List<SubtitlesInfo> getAvailableSubtitlesInfo() {
// If the video is age restricted getPlayerConfig will fail // If the video is age restricted getPlayerConfig will fail
if (getAgeLimit() == 18) return Collections.emptyList(); if (getAgeLimit() != NO_AGE_LIMIT) return Collections.emptyList();
final JsonObject captions; final JsonObject captions;
if (!playerResponse.has("captions")) { if (!playerResponse.has("captions")) {