Fix like/dislike parsing
This commit is contained in:
parent
a34e5c18e1
commit
3ec422a542
|
@ -388,9 +388,8 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
assertPageFetched();
|
assertPageFetched();
|
||||||
String likesString = "";
|
String likesString = "";
|
||||||
try {
|
try {
|
||||||
Element button = doc.select("button.like-button-renderer-like-button").first();
|
|
||||||
try {
|
try {
|
||||||
likesString = button.select("span.yt-uix-button-content").first().text();
|
likesString = ytInitialData.getObject("contents").getObject("twoColumnWatchNextResults").getObject("results").getObject("results").getArray("contents").getObject(0).getObject("videoPrimaryInfoRenderer").getObject("sentimentBar").getObject("sentimentBarRenderer").getString("tooltip").split("/")[0];
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
//if this kicks in our button has no content and therefore ratings must be disabled
|
//if this kicks in our button has no content and therefore ratings must be disabled
|
||||||
if (playerResponse.getObject("videoDetails").getBoolean("allowRatings")) {
|
if (playerResponse.getObject("videoDetails").getBoolean("allowRatings")) {
|
||||||
|
@ -413,7 +412,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
try {
|
try {
|
||||||
Element button = doc.select("button.like-button-renderer-dislike-button").first();
|
Element button = doc.select("button.like-button-renderer-dislike-button").first();
|
||||||
try {
|
try {
|
||||||
dislikesString = button.select("span.yt-uix-button-content").first().text();
|
dislikesString = ytInitialData.getObject("contents").getObject("twoColumnWatchNextResults").getObject("results").getObject("results").getArray("contents").getObject(0).getObject("videoPrimaryInfoRenderer").getObject("sentimentBar").getObject("sentimentBarRenderer").getString("tooltip").split("/")[1];
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
//if this kicks in our button has no content and therefore ratings must be disabled
|
//if this kicks in our button has no content and therefore ratings must be disabled
|
||||||
if (playerResponse.getObject("videoDetails").getBoolean("allowRatings")) {
|
if (playerResponse.getObject("videoDetails").getBoolean("allowRatings")) {
|
||||||
|
|
Loading…
Reference in New Issue