Skip to content

Commit 9a0f4a8

Browse files
committed
[YouTube] Use iterators to check for members-only content
1 parent 9ae17d8 commit 9a0f4a8

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -473,14 +473,12 @@ public boolean isShortFormContent() throws ParsingException {
473473
}
474474

475475
private boolean isMembersOnly() throws ParsingException {
476-
final JsonArray badges = videoInfo.getArray("badges");
477-
for (final Object badge : badges) {
478-
if (((JsonObject) badge).getObject("metadataBadgeRenderer")
479-
.getString("style", "").equals("BADGE_STYLE_TYPE_MEMBERS_ONLY")) {
480-
return true;
481-
}
482-
}
483-
return false;
476+
return videoInfo.getArray("badges")
477+
.stream()
478+
.filter(JsonObject.class::isInstance)
479+
.map(JsonObject.class::cast)
480+
.map(badge -> badge.getObject("metadataBadgeRenderer").getString("style"))
481+
.anyMatch("BADGE_STYLE_TYPE_MEMBERS_ONLY"::equals);
484482
}
485483

486484

0 commit comments

Comments
 (0)