mirror of
https://github.com/iv-org/invidious.git
synced 2026-06-17 04:16:44 -05:00
chore: build premiere_timestamp using video_type and published time
This commit is contained in:
parent
a6d4c488ef
commit
5f9b474ecb
@ -129,6 +129,8 @@ module Invidious::Routes::Watch
|
|||||||
video_streams = video.video_streams
|
video_streams = video.video_streams
|
||||||
audio_streams = video.audio_streams
|
audio_streams = video.audio_streams
|
||||||
|
|
||||||
|
# Videos that are a premiere do not have audio streams.
|
||||||
|
if video.premiere_timestamp.nil?
|
||||||
# Older videos may not have audio sources available.
|
# Older videos may not have audio sources available.
|
||||||
# We redirect here so they're not unplayable
|
# We redirect here so they're not unplayable
|
||||||
if audio_streams.empty? && !video.live_now
|
if audio_streams.empty? && !video.live_now
|
||||||
@ -142,6 +144,7 @@ module Invidious::Routes::Watch
|
|||||||
return env.redirect "/watch?#{env.params.query}"
|
return env.redirect "/watch?#{env.params.query}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
captions = video.captions
|
captions = video.captions
|
||||||
|
|
||||||
|
|||||||
@ -81,10 +81,11 @@ struct Video
|
|||||||
end
|
end
|
||||||
|
|
||||||
def premiere_timestamp : Time?
|
def premiere_timestamp : Time?
|
||||||
info
|
if self.video_type == VideoType::Scheduled
|
||||||
.dig?("microformat", "playerMicroformatRenderer", "liveBroadcastDetails", "startTimestamp")
|
return info["published"]?
|
||||||
.try { |t| Time.parse_rfc3339(t.as_s) }
|
.try { |t| Time.parse_rfc3339(t.as_s) }
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def related_videos
|
def related_videos
|
||||||
info["relatedVideos"]?.try &.as_a.map { |h| h.as_h.transform_values &.as_s } || [] of Hash(String, String)
|
info["relatedVideos"]?.try &.as_a.map { |h| h.as_h.transform_values &.as_s } || [] of Hash(String, String)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user