From d57d278f32e94d2bec75ffbc3c7bf28e6cb7638d Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 9 Feb 2023 15:00:23 -0500 Subject: [PATCH 1/2] Make itag optional under /latest_version --- src/invidious/routes/video_playback.cr | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/invidious/routes/video_playback.cr b/src/invidious/routes/video_playback.cr index 1e932d11b..f24c0dedb 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 From 3848c3f53f230e971eb67b1317f2cd4ad1b76176 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Sun, 12 Mar 2023 18:36:03 -0400 Subject: [PATCH 2/2] Update src/invidious/routes/video_playback.cr Co-authored-by: Samantaz Fox --- src/invidious/routes/video_playback.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious/routes/video_playback.cr b/src/invidious/routes/video_playback.cr index f24c0dedb..9641e01a1 100644 --- a/src/invidious/routes/video_playback.cr +++ b/src/invidious/routes/video_playback.cr @@ -278,7 +278,7 @@ module Invidious::Routes::VideoPlayback end if itag.nil? - fmt = video.fmt_stream[-1] + 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