[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

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);
}