fix detecting live_now

This commit is contained in:
Emilien Devos 2024-10-14 00:59:40 +02:00
parent 9438a6df35
commit 126f8fd097
1 changed files with 6 additions and 4 deletions

View File

@ -236,7 +236,7 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
published = microformat["publishDate"]? published = microformat["publishDate"]?
.try { |t| Time.parse(t.as_s, "%Y-%m-%d", Time::Location::UTC) } .try { |t| Time.parse(t.as_s, "%Y-%m-%d", Time::Location::UTC) }
if !published if published.nil?
published_txt = video_primary_renderer published_txt = video_primary_renderer
.try &.dig?("dateText", "simpleText") .try &.dig?("dateText", "simpleText")
@ -254,8 +254,10 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
live_now = microformat.dig?("liveBroadcastDetails", "isLiveNow") live_now = microformat.dig?("liveBroadcastDetails", "isLiveNow")
.try &.as_bool .try &.as_bool
live_now ||= video_primary_renderer if live_now.nil?
.try &.dig?("viewCount", "videoViewCountRenderer", "isLive").try &.as_bool || false live_now = video_primary_renderer
.try &.dig?("viewCount", "videoViewCountRenderer", "isLive").try &.as_bool || false
end
post_live_dvr = video_details.dig?("isPostLiveDvr") post_live_dvr = video_details.dig?("isPostLiveDvr")
.try &.as_bool || false .try &.as_bool || false
@ -279,7 +281,7 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
else else
is_listed ||= true is_listed ||= true
end end
# if no badges but videoDetails not available then assume isListed # if no badges but videoDetails not available then assume isListed
else else
is_listed ||= true is_listed ||= true
end end