[YouTube] Check if channel item has subscription count in search

This commit is contained in:
Mauricio Colli 2020-03-21 03:15:23 -03:00
parent 9704fc9952
commit 9b7999fe54
No known key found for this signature in database
GPG Key ID: F200BFD6F29DDD85
1 changed files with 8 additions and 2 deletions

View File

@ -70,8 +70,14 @@ public class YoutubeChannelInfoItemExtractor implements ChannelInfoItemExtractor
@Override
public long getSubscriberCount() throws ParsingException {
try {
String subscribers = getTextFromObject(channelInfoItem.getObject("subscriberCountText"));
return Utils.mixedNumberWordToLong(subscribers);
final JsonObject subscriberCountObject = channelInfoItem.getObject("subscriberCountText");
if (subscriberCountObject == null) {
// Subscription count is not available for this channel item.
return -1;
}
return Utils.mixedNumberWordToLong(getTextFromObject(subscriberCountObject));
} catch (Exception e) {
throw new ParsingException("Could not get subscriber count", e);
}