summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2024-11-10 17:36:49 +0100
committerSamantaz Fox <coding@samantaz.fr>2024-11-10 17:36:49 +0100
commit4b363e32fae8dcfe236112eff1566db8ec36c699 (patch)
treeb9bbca0cb1783b76e1d7d924cf6adb130b35ac8d
parentb173d4acf21563d47d26718eca7932878fb424e6 (diff)
parentb2a83991d16cc9fa65f71309cd4a745f005cdf61 (diff)
downloadinvidious-4b363e32fae8dcfe236112eff1566db8ec36c699.tar.gz
invidious-4b363e32fae8dcfe236112eff1566db8ec36c699.tar.bz2
invidious-4b363e32fae8dcfe236112eff1566db8ec36c699.zip
Parsers: Fix parsing live_now and premiere_timestamp (#4934)
This pull request fixes the parsing for the 'live_now' and 'premiere_timestamp' variables so that they work without the 'microformat' data being present. Related to 4929
-rw-r--r--src/invidious/videos/parser.cr11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/invidious/videos/parser.cr b/src/invidious/videos/parser.cr
index fb8935d9..70075da9 100644
--- a/src/invidious/videos/parser.cr
+++ b/src/invidious/videos/parser.cr
@@ -235,8 +235,17 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
premiere_timestamp = microformat.dig?("liveBroadcastDetails", "startTimestamp")
.try { |t| Time.parse_rfc3339(t.as_s) }
+ premiere_timestamp ||= player_response.dig?(
+ "playabilityStatus", "liveStreamability",
+ "liveStreamabilityRenderer", "offlineSlate",
+ "liveStreamOfflineSlateRenderer", "scheduledStartTime"
+ )
+ .try &.as_s.to_i64
+ .try { |t| Time.unix(t) }
+
live_now = microformat.dig?("liveBroadcastDetails", "isLiveNow")
- .try &.as_bool || false
+ .try &.as_bool
+ live_now ||= video_details.dig?("isLive").try &.as_bool || false
post_live_dvr = video_details.dig?("isPostLiveDvr")
.try &.as_bool || false