Readd the deleted code of views because watching count of livestreams was broken

The number shown was the total number of views that a livestream has. In order to fix this bug, the previous code is readded.
This commit is contained in:
TiA4f8R 2021-06-02 18:46:35 +02:00
parent 947baec805
commit 318bc46a8c
No known key found for this signature in database
GPG Key ID: E6D3E7F5949450DD
1 changed files with 16 additions and 3 deletions

View File

@ -320,9 +320,22 @@ public class YoutubeStreamExtractor extends StreamExtractor {
@Override
public long getViewCount() throws ParsingException {
assertPageFetched();
final String views = playerResponse.getObject("videoDetails").getString("viewCount");
if (isNullOrEmpty(views)) throw new ParsingException("Could not get view count");
String views = null;
try {
views = getTextFromObject(getVideoPrimaryInfoRenderer().getObject("viewCount")
.getObject("videoViewCountRenderer").getObject("viewCount"));
} catch (final ParsingException ignored) {
// Age-restricted videos cause a ParsingException here
}
if (isNullOrEmpty(views)) {
views = playerResponse.getObject("videoDetails").getString("viewCount");
if (isNullOrEmpty(views)) throw new ParsingException("Could not get view count");
}
if (views.toLowerCase().contains("no views")) return 0;
return Long.parseLong(Utils.removeNonDigitCharacters(views));
}