Compare commits

...

2 Commits

Author SHA1 Message Date
Émilien (perso)
9cd8ccb373
Merge 734e72503f into 9892604758 2024-11-17 19:18:36 +01:00
Emilien
734e72503f fix download function when invidious companion used 2024-11-17 19:18:29 +01:00
2 changed files with 10 additions and 6 deletions

View File

@ -253,7 +253,7 @@ module Invidious::Routes::VideoPlayback
# YouTube /videoplayback links expire after 6 hours,
# so we have a mechanism here to redirect to the latest version
def self.latest_version(env)
if !CONFIG.invidious_companion.empty? && CONFIG.disabled?("downloads")
if !CONFIG.invidious_companion.empty?
return error_template(403, "This endpoint is not permitted because it is handled by Invidious companion.")
end
@ -298,9 +298,6 @@ module Invidious::Routes::VideoPlayback
end
if local
if (!CONFIG.invidious_companion.empty?)
return env.redirect "#{video.invidious_companion.not_nil!["baseUrl"].as_s}#{env.request.path}?#{env.request.query}"
end
url = URI.parse(url).request_target.not_nil!
url += "&title=#{URI.encode_www_form(title, space_to_plus: false)}" if title
end

View File

@ -328,13 +328,20 @@ module Invidious::Routes::Watch
return Invidious::Routes::API::V1::Videos.captions(env)
elsif itag = download_widget["itag"]?.try &.as_i
itag = itag.to_s
# URL params specific to /latest_version
env.params.query["id"] = video_id
env.params.query["itag"] = itag.to_s
env.params.query["itag"] = itag
env.params.query["title"] = filename
env.params.query["local"] = "true"
return Invidious::Routes::VideoPlayback.latest_version(env)
if (!CONFIG.invidious_companion.empty?)
video = get_video(video_id)
return env.redirect "#{video.invidious_companion.not_nil!["baseUrl"].as_s}/latest_version?id=#{video_id}&itag=#{itag}&local=true"
else
return Invidious::Routes::VideoPlayback.latest_version(env)
end
else
return error_template(400, "Invalid label or itag")
end