mirror of
https://github.com/iv-org/invidious.git
synced 2026-06-02 21:04:25 +00:00
fix: Do not append query params quality=medium to videos that are about to premiere
Video premieres do not have `audio_streams` and they aren't `video.live_now == true` either, therefore we skip the checks that are made for older videos (`if audio_streams.empty? && !video.live_now` closure) if the video is a premiere. This commit also adds the `microformat` field to the `info` instance variable of the `Video` struct, since it's needed for the function `Video#premiere_timestamp : Time?`. This is more like a quick fix than a proper fix because in `Invidious::Videos::Parser#parse_video_info`, `premiere_timestamp` is gathered from the `microformat` JSON Object but is used to set the `published` hash key for the `params` variable. The parsers and structs really need a rework :/
This commit is contained in:
@@ -129,17 +129,20 @@ module Invidious::Routes::Watch
|
|||||||
video_streams = video.video_streams
|
video_streams = video.video_streams
|
||||||
audio_streams = video.audio_streams
|
audio_streams = video.audio_streams
|
||||||
|
|
||||||
# Older videos may not have audio sources available.
|
# Videos that are a premiere do not have audio streams.
|
||||||
# We redirect here so they're not unplayable
|
if !video.premiere_timestamp.nil?
|
||||||
if audio_streams.empty? && !video.live_now
|
# Older videos may not have audio sources available.
|
||||||
if params.quality == "dash"
|
# We redirect here so they're not unplayable
|
||||||
env.params.query.delete_all("quality")
|
if audio_streams.empty? && !video.live_now
|
||||||
env.params.query["quality"] = "medium"
|
if params.quality == "dash"
|
||||||
return env.redirect "/watch?#{env.params.query}"
|
env.params.query.delete_all("quality")
|
||||||
elsif params.listen
|
env.params.query["quality"] = "medium"
|
||||||
env.params.query.delete_all("listen")
|
return env.redirect "/watch?#{env.params.query}"
|
||||||
env.params.query["listen"] = "0"
|
elsif params.listen
|
||||||
return env.redirect "/watch?#{env.params.query}"
|
env.params.query.delete_all("listen")
|
||||||
|
env.params.query["listen"] = "0"
|
||||||
|
return env.redirect "/watch?#{env.params.query}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ module Invidious::Videos::Parser
|
|||||||
params = self.parse_video_info(video_id, player_response)
|
params = self.parse_video_info(video_id, player_response)
|
||||||
params["reason"] = JSON::Any.new(reason) if reason
|
params["reason"] = JSON::Any.new(reason) if reason
|
||||||
|
|
||||||
{"captions", "playabilityStatus", "playerConfig", "storyboards"}.each do |f|
|
{"captions", "playabilityStatus", "playerConfig", "storyboards", "microformat"}.each do |f|
|
||||||
params[f] = player_response[f] if player_response[f]?
|
params[f] = player_response[f] if player_response[f]?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user