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