Code refactoring
This commit is contained in:
parent
c4eca91be9
commit
56c8af710e
|
@ -380,12 +380,12 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
public long getDislikeCount() throws ParsingException {
|
public long getDislikeCount() throws ParsingException {
|
||||||
assertPageFetched();
|
assertPageFetched();
|
||||||
|
|
||||||
String dislikesString = null;
|
|
||||||
try {
|
try {
|
||||||
dislikesString = getVideoPrimaryInfoRenderer().getObject("sentimentBar")
|
String dislikesString = getVideoPrimaryInfoRenderer().getObject("sentimentBar")
|
||||||
.getObject("sentimentBarRenderer").getString("tooltip");
|
.getObject("sentimentBarRenderer").getString("tooltip");
|
||||||
if (dislikesString != null && dislikesString.contains("/")) {
|
if (dislikesString != null && dislikesString.contains("/")) {
|
||||||
dislikesString = dislikesString.split("/")[1];
|
dislikesString = dislikesString.split("/")[1];
|
||||||
|
return Integer.parseInt(Utils.removeNonDigitCharacters(dislikesString));
|
||||||
} else {
|
} else {
|
||||||
// Calculate dislike with average rating and like count
|
// Calculate dislike with average rating and like count
|
||||||
long likes = getLikeCount();
|
long likes = getLikeCount();
|
||||||
|
@ -397,11 +397,6 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
return Math.round(likes * ((5 - averageRating) / (averageRating - 1)));
|
return Math.round(likes * ((5 - averageRating) / (averageRating - 1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dislikesString != null) {
|
|
||||||
return Integer.parseInt(Utils.removeNonDigitCharacters(dislikesString));
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
}
|
}
|
||||||
// Silently fail as YouTube is "gradually rolling out" removing dislike count
|
// Silently fail as YouTube is "gradually rolling out" removing dislike count
|
||||||
|
|
Loading…
Reference in New Issue