Implement getSubscriberCount() in YoutubeChannelInfoItemExtractor

This commit is contained in:
wb9688 2020-02-24 10:39:52 +01:00 committed by TobiGr
parent 6d20b2b1d0
commit 51fb26625a

View file

@ -63,9 +63,13 @@ public class YoutubeChannelInfoItemExtractor implements ChannelInfoItemExtractor
}
@Override
public long getSubscriberCount() {
// TODO: get subscriber count, it's in subscriberCountText.simpleText as a string like "103M subscribers"
return -1;
public long getSubscriberCount() throws ParsingException {
try {
String subscribers = channelInfoItem.getObject("subscriberCountText").getString("simpleText").split(" ")[0];
return Utils.mixedNumberWordToLong(subscribers);
} catch (Exception e) {
throw new ParsingException("Could not get subscriber count", e);
}
}
@Override