Browse Source
Merge pull request #3627 from iBicha/feature/latest-version-optional-itag
Co-authored-by: Samantaz Fox <coding@samantaz.fr>
pull/3691/head
Émilien Devos (perso)
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
2 deletions
-
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 |
|
|
|
|