Skip to content

Commit d051342

Browse files
committed
[YouTube] Correctly handle unverified channels
1 parent c3362e9 commit d051342

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,9 +1599,13 @@ public static JsonBuilder<JsonObject> prepareJsonBuilder(
15991599
@Nullable
16001600
public static JsonObject getFirstCollaborator(final JsonObject navigationEndpoint)
16011601
throws ParsingException {
1602-
// CHECKSTYLE:OFF
1603-
final JsonArray listItems = JsonUtils.getArray(navigationEndpoint, "showDialogCommand.panelLoadingStrategy.inlineContent.dialogViewModel.customContent.listViewModel.listItems");
1604-
// CHECKSTYLE:ON
1605-
return listItems.getObject(0).getObject("listItemViewModel");
1602+
try {
1603+
// CHECKSTYLE:OFF
1604+
final JsonArray listItems = JsonUtils.getArray(navigationEndpoint, "showDialogCommand.panelLoadingStrategy.inlineContent.dialogViewModel.customContent.listViewModel.listItems");
1605+
// CHECKSTYLE:ON
1606+
return listItems.getObject(0).getObject("listItemViewModel");
1607+
} catch (final ParsingException e) {
1608+
return null;
1609+
}
16061610
}
16071611
}

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -550,12 +550,15 @@ public boolean isUploaderVerified() throws ParsingException {
550550
.getArray("badges"));
551551
}
552552

553+
554+
final JsonObject channel = YoutubeParsingHelper.getFirstCollaborator(
555+
videoOwnerRenderer.getObject("navigationEndpoint"));
556+
if (channel == null) {
557+
return false;
558+
}
559+
553560
return YoutubeParsingHelper.hasArtistOrVerifiedIconBadgeAttachment(
554-
YoutubeParsingHelper.getFirstCollaborator(videoOwnerRenderer
555-
.getObject("navigationEndpoint"))
556-
.getObject("title")
557-
.getArray("attachmentRuns")
558-
);
561+
channel.getObject("title").getArray("attachmentRuns"));
559562
}
560563

561564
@Nonnull

0 commit comments

Comments
 (0)