|
7 | 7 | import org.jsoup.Jsoup; |
8 | 8 | import org.jsoup.nodes.Document; |
9 | 9 | import org.jsoup.nodes.Element; |
10 | | -import org.schabi.newpipe.extractor.*; |
| 10 | +import org.schabi.newpipe.extractor.Downloader; |
| 11 | +import org.schabi.newpipe.extractor.NewPipe; |
| 12 | +import org.schabi.newpipe.extractor.StreamingService; |
11 | 13 | import org.schabi.newpipe.extractor.channel.ChannelExtractor; |
12 | 14 | import org.schabi.newpipe.extractor.exceptions.ExtractionException; |
13 | 15 | import org.schabi.newpipe.extractor.exceptions.ParsingException; |
| 16 | +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; |
14 | 17 | import org.schabi.newpipe.extractor.stream.StreamInfoItem; |
15 | 18 | import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; |
16 | | -import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; |
17 | 19 | import org.schabi.newpipe.extractor.utils.DonationLinkHelper; |
18 | 20 | import org.schabi.newpipe.extractor.utils.Parser; |
19 | 21 | import org.schabi.newpipe.extractor.utils.Utils; |
@@ -131,11 +133,16 @@ public String getFeedUrl() throws ParsingException { |
131 | 133 |
|
132 | 134 | @Override |
133 | 135 | public long getSubscriberCount() throws ParsingException { |
134 | | - Element el = doc.select("span[class*=\"yt-subscription-button-subscriber-count\"]").first(); |
| 136 | + final Element el = doc.select("span[class*=\"yt-subscription-button-subscriber-count\"]").first(); |
135 | 137 | if (el != null) { |
136 | | - return Long.parseLong(Utils.removeNonDigitCharacters(el.text())); |
| 138 | + try { |
| 139 | + return Long.parseLong(Utils.removeNonDigitCharacters(el.text())); |
| 140 | + } catch (NumberFormatException e) { |
| 141 | + throw new ParsingException("Could not get subscriber count", e); |
| 142 | + } |
137 | 143 | } else { |
138 | | - throw new ParsingException("Could not get subscriber count"); |
| 144 | + // If the element is null, the channel have the subscriber count disabled |
| 145 | + return -1; |
139 | 146 | } |
140 | 147 | } |
141 | 148 |
|
|
0 commit comments