Skip to content

Commit 9b7999f

Browse files
committed
[YouTube] Check if channel item has subscription count in search
1 parent 9704fc9 commit 9b7999f

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,14 @@ public String getUrl() throws ParsingException {
7070
@Override
7171
public long getSubscriberCount() throws ParsingException {
7272
try {
73-
String subscribers = getTextFromObject(channelInfoItem.getObject("subscriberCountText"));
74-
return Utils.mixedNumberWordToLong(subscribers);
73+
final JsonObject subscriberCountObject = channelInfoItem.getObject("subscriberCountText");
74+
75+
if (subscriberCountObject == null) {
76+
// Subscription count is not available for this channel item.
77+
return -1;
78+
}
79+
80+
return Utils.mixedNumberWordToLong(getTextFromObject(subscriberCountObject));
7581
} catch (Exception e) {
7682
throw new ParsingException("Could not get subscriber count", e);
7783
}

0 commit comments

Comments
 (0)