diff options
| author | Samantaz Fox <coding@samantaz.fr> | 2024-04-26 23:38:28 +0200 |
|---|---|---|
| committer | Samantaz Fox <coding@samantaz.fr> | 2024-04-26 23:44:30 +0200 |
| commit | f1fd197cbc28b44c0980eba5bbd0aa6b805e5915 (patch) | |
| tree | 84f80a9963005749748e2deb80a8ac5ecb447b3e | |
| parent | bd549f21e91a05df4d02017cf77f1b99c2eb9d20 (diff) | |
| parent | bfd9c9876e2fc31d7e61fc298e31e7da75f35c87 (diff) | |
| download | invidious-f1fd197cbc28b44c0980eba5bbd0aa6b805e5915.tar.gz invidious-f1fd197cbc28b44c0980eba5bbd0aa6b805e5915.tar.bz2 invidious-f1fd197cbc28b44c0980eba5bbd0aa6b805e5915.zip | |
API: convey info "is post live" from Youtube response (#4569)
Returns the 'isPostLiveDvr' field in the videos API when the video
is a post-live DVR (= ended livestream that hasn't been reprocessed
into VOD yet).
Example taken 10 minutes after that livestream ended:
/api/v1/videos/euqnWk-uP6M
{
...
"isPostLiveDvr": true,
...
}
Partially fixes 4421
| -rw-r--r-- | src/invidious/jsonify/api_v1/video_json.cr | 1 | ||||
| -rw-r--r-- | src/invidious/videos.cr | 4 | ||||
| -rw-r--r-- | src/invidious/videos/parser.cr | 4 |
3 files changed, 9 insertions, 0 deletions
diff --git a/src/invidious/jsonify/api_v1/video_json.cr b/src/invidious/jsonify/api_v1/video_json.cr index a189dc57..4fe90289 100644 --- a/src/invidious/jsonify/api_v1/video_json.cr +++ b/src/invidious/jsonify/api_v1/video_json.cr @@ -62,6 +62,7 @@ module Invidious::JSONify::APIv1 json.field "rating", 0_i64 json.field "isListed", video.is_listed json.field "liveNow", video.live_now + json.field "isPostLiveDvr", video.post_live_dvr json.field "isUpcoming", video.is_upcoming if video.premiere_timestamp diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index a8f02056..2f44939c 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -82,6 +82,10 @@ struct Video return (self.video_type == VideoType::Livestream) end + def post_live_dvr + return info["isPostLiveDvr"].as_bool + end + def premiere_timestamp : Time? info .dig?("microformat", "playerMicroformatRenderer", "liveBroadcastDetails", "startTimestamp") diff --git a/src/invidious/videos/parser.cr b/src/invidious/videos/parser.cr index 6fd57462..c6fd632f 100644 --- a/src/invidious/videos/parser.cr +++ b/src/invidious/videos/parser.cr @@ -216,6 +216,9 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any live_now = microformat.dig?("liveBroadcastDetails", "isLiveNow") .try &.as_bool || false + post_live_dvr = video_details.dig?("isPostLiveDvr") + .try &.as_bool || false + # Extra video infos allowed_regions = microformat["availableCountries"]? @@ -417,6 +420,7 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any "isListed" => JSON::Any.new(is_listed || false), "isUpcoming" => JSON::Any.new(is_upcoming || false), "keywords" => JSON::Any.new(keywords.map { |v| JSON::Any.new(v) }), + "isPostLiveDvr" => JSON::Any.new(post_live_dvr), # Related videos "relatedVideos" => JSON::Any.new(related), # Description |
