diff options
| author | Omar Roth <omarroth@protonmail.com> | 2019-08-08 22:09:34 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@protonmail.com> | 2019-08-09 10:36:22 -0500 |
| commit | 2d955dae487200dba652d540110ed4ffb79bfb97 (patch) | |
| tree | 20057ab06e5067c961422562e6f0465e896e538d /src | |
| parent | 66b949bed1b2d685ec2f76c99897a13b94a9373b (diff) | |
| download | invidious-2d955dae487200dba652d540110ed4ffb79bfb97.tar.gz invidious-2d955dae487200dba652d540110ed4ffb79bfb97.tar.bz2 invidious-2d955dae487200dba652d540110ed4ffb79bfb97.zip | |
Force redirect for videos without audio
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious.cr | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index c2de0dcf..46d38414 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -463,8 +463,16 @@ get "/watch" do |env| # 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" + if audio_streams.empty? + if params.quality == "dash" + env.params.query.delete_all("quality") + env.params.query["quality"] = "medium" + next env.redirect "/watch?#{env.params.query}" + elsif params.listen + env.params.query.delete_all("listen") + env.params.query["listen"] = "0" + next env.redirect "/watch?#{env.params.query}" + end end captions = video.captions @@ -689,6 +697,17 @@ get "/embed/:id" do |env| video_streams = video.video_streams(adaptive_fmts) audio_streams = video.audio_streams(adaptive_fmts) + if audio_streams.empty? + if params.quality == "dash" + env.params.query.delete_all("quality") + next env.redirect "/embed/#{video_id}?#{env.params.query}" + elsif params.listen + env.params.query.delete_all("listen") + env.params.query["listen"] = "0" + next env.redirect "/embed/#{video_id}?#{env.params.query}" + end + end + captions = video.captions preferred_captions = captions.select { |caption| |
