diff options
| author | Émilien Devos (perso) <contact@emiliendevos.be> | 2023-03-15 20:07:06 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-15 20:07:06 +0100 |
| commit | a6d21cb2119610eb90171c18498037c737933163 (patch) | |
| tree | 1a54b2eb6f98b53362d169d43df553a0657c99dc /src | |
| parent | 712aea0831cff6a071b303ac3cc25a3559147917 (diff) | |
| parent | 3848c3f53f230e971eb67b1317f2cd4ad1b76176 (diff) | |
| download | invidious-a6d21cb2119610eb90171c18498037c737933163.tar.gz invidious-a6d21cb2119610eb90171c18498037c737933163.tar.bz2 invidious-a6d21cb2119610eb90171c18498037c737933163.zip | |
Merge pull request #3627 from iBicha/feature/latest-version-optional-itag
Co-authored-by: Samantaz Fox <coding@samantaz.fr>
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/routes/video_playback.cr | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/invidious/routes/video_playback.cr b/src/invidious/routes/video_playback.cr index 1e932d11..9641e01a 100644 --- a/src/invidious/routes/video_playback.cr +++ b/src/invidious/routes/video_playback.cr @@ -256,7 +256,7 @@ module Invidious::Routes::VideoPlayback return error_template(400, "Invalid video ID") end - if itag.nil? || itag <= 0 || itag >= 1000 + if !itag.nil? && (itag <= 0 || itag >= 1000) return error_template(400, "Invalid itag") end @@ -277,7 +277,11 @@ module Invidious::Routes::VideoPlayback return error_template(500, ex) end - fmt = video.fmt_stream.find(nil) { |f| f["itag"].as_i == itag } || video.adaptive_fmts.find(nil) { |f| f["itag"].as_i == itag } + if itag.nil? + fmt = video.fmt_stream[-1]? + else + fmt = video.fmt_stream.find(nil) { |f| f["itag"].as_i == itag } || video.adaptive_fmts.find(nil) { |f| f["itag"].as_i == itag } + end url = fmt.try &.["url"]?.try &.as_s if !url |
