mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-28 08:27:25 +00:00
fix download function when invidious companion used
This commit is contained in:
parent
bb2e3b2a3e
commit
734e72503f
@ -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
|
||||
|
@ -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"
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user