Add redirect for videos with no audio sources

This commit is contained in:
Omar Roth 2019-05-04 10:47:54 -05:00
parent 716705aa15
commit 0cf86974dd
No known key found for this signature in database
GPG Key ID: B8254FB7EC3D37F2

View File

@ -419,6 +419,12 @@ get "/watch" do |env|
video_streams = video.video_streams(adaptive_fmts)
audio_streams = video.audio_streams(adaptive_fmts)
# Older videos may not have audio sources available.
# We redirect here so they're not unplayable
if params.listen && audio_streams.empty?
next env.redirect "/watch?#{env.params.query}&listen=0"
end
captions = video.captions
preferred_captions = captions.select { |caption|