Skip to content

Commit 2a470ac

Browse files
mauriciocolliTobiGr
authored andcommitted
[YouTube] Handle videos with no views or with "Recommended to you" text
1 parent da2c562 commit 2a470ac

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ public long getViewCount() throws ParsingException {
203203

204204
final String viewCount = getTextFromObject(viewCountObject);
205205

206+
if (viewCount.toLowerCase().contains("no views")) {
207+
return 0;
208+
} else if (viewCount.toLowerCase().contains("recommended")) {
209+
return -1;
210+
}
211+
206212
return Long.parseLong(Utils.removeNonDigitCharacters(viewCount));
207213
} catch (Exception e) {
208214
throw new ParsingException("Could not get view count", e);

0 commit comments

Comments
 (0)