Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
B0pol committed Nov 21, 2021
1 parent c4eca91 commit 56c8af7
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,12 @@ public long getLikeCount() throws ParsingException {
public long getDislikeCount() throws ParsingException {
assertPageFetched();

String dislikesString = null;
try {
dislikesString = getVideoPrimaryInfoRenderer().getObject("sentimentBar")
String dislikesString = getVideoPrimaryInfoRenderer().getObject("sentimentBar")
.getObject("sentimentBarRenderer").getString("tooltip");
if (dislikesString != null && dislikesString.contains("/")) {
dislikesString = dislikesString.split("/")[1];
return Integer.parseInt(Utils.removeNonDigitCharacters(dislikesString));
} else {
// Calculate dislike with average rating and like count
long likes = getLikeCount();
Expand All @@ -397,11 +397,6 @@ public long getDislikeCount() throws ParsingException {
return Math.round(likes * ((5 - averageRating) / (averageRating - 1)));
}
}

if (dislikesString != null) {
return Integer.parseInt(Utils.removeNonDigitCharacters(dislikesString));
}

} catch (final Exception e) {
}
// Silently fail as YouTube is "gradually rolling out" removing dislike count
Expand Down

0 comments on commit 56c8af7

Please sign in to comment.