summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2023-03-19 22:44:59 +0100
committerSamantaz Fox <coding@samantaz.fr>2023-03-19 22:44:59 +0100
commit4ae158ef6dcb89c2cd0eec646a42f11ebc207fba (patch)
treee2642a562cfe94789804ac7e5ec72911821cff58 /src
parent1f3317e257745a7ef4c44fcf8748ec18fe401fb0 (diff)
downloadinvidious-4ae158ef6dcb89c2cd0eec646a42f11ebc207fba.tar.gz
invidious-4ae158ef6dcb89c2cd0eec646a42f11ebc207fba.tar.bz2
invidious-4ae158ef6dcb89c2cd0eec646a42f11ebc207fba.zip
Videos: Add back support for views on livestreams
Diffstat (limited to 'src')
-rw-r--r--src/invidious/videos/parser.cr10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/invidious/videos/parser.cr b/src/invidious/videos/parser.cr
index 04ee7303..efc4b2e5 100644
--- a/src/invidious/videos/parser.cr
+++ b/src/invidious/videos/parser.cr
@@ -185,10 +185,12 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
# We have to try to extract viewCount from videoPrimaryInfoRenderer first,
# then from videoDetails, as the latter is "0" for livestreams (we want
# to get the amount of viewers watching).
- views_txt = video_primary_renderer
- .try &.dig?("viewCount", "videoViewCountRenderer", "viewCount", "simpleText")
- views_txt ||= video_details["viewCount"]?
- views = views_txt.try &.as_s.gsub(/\D/, "").to_i64?
+ views_txt = extract_text(
+ video_primary_renderer
+ .try &.dig?("viewCount", "videoViewCountRenderer", "viewCount")
+ )
+ views_txt ||= video_details["viewCount"]?.try &.as_s || ""
+ views = views_txt.gsub(/\D/, "").to_i64?
length_txt = (microformat["lengthSeconds"]? || video_details["lengthSeconds"])
.try &.as_s.to_i64