From 7a33831d1471da0d117692539b739f0da146e540 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sun, 4 Aug 2019 20:56:24 -0500 Subject: [PATCH] Fix detection of premium content --- src/invidious/videos.cr | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 49ff0494..e1dff5aa 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -803,8 +803,11 @@ struct Video end def premium - premium = self.player_response.to_s.includes? "Get YouTube without the ads." - return premium + if info["premium"]? + self.info["premium"] == "true" + else + false + end end def captions @@ -1189,6 +1192,8 @@ def fetch_video(id, region) author = player_json["videoDetails"]["author"]?.try &.as_s || "" ucid = player_json["videoDetails"]["channelId"]?.try &.as_s || "" + info["premium"] = html.xpath_node(%q(.//span[text()="Premium"])) ? "true" : "false" + views = html.xpath_node(%q(//meta[@itemprop="interactionCount"])) .try &.["content"].to_i64? || 0_i64