mirror of
https://github.com/iv-org/invidious.git
synced 2025-01-10 11:30:34 +05:30
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,
|
# YouTube /videoplayback links expire after 6 hours,
|
||||||
# so we have a mechanism here to redirect to the latest version
|
# so we have a mechanism here to redirect to the latest version
|
||||||
def self.latest_version(env)
|
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.")
|
return error_template(403, "This endpoint is not permitted because it is handled by Invidious companion.")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -298,9 +298,6 @@ module Invidious::Routes::VideoPlayback
|
|||||||
end
|
end
|
||||||
|
|
||||||
if local
|
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 = URI.parse(url).request_target.not_nil!
|
||||||
url += "&title=#{URI.encode_www_form(title, space_to_plus: false)}" if title
|
url += "&title=#{URI.encode_www_form(title, space_to_plus: false)}" if title
|
||||||
end
|
end
|
||||||
|
@ -328,13 +328,20 @@ module Invidious::Routes::Watch
|
|||||||
|
|
||||||
return Invidious::Routes::API::V1::Videos.captions(env)
|
return Invidious::Routes::API::V1::Videos.captions(env)
|
||||||
elsif itag = download_widget["itag"]?.try &.as_i
|
elsif itag = download_widget["itag"]?.try &.as_i
|
||||||
|
itag = itag.to_s
|
||||||
|
|
||||||
# URL params specific to /latest_version
|
# URL params specific to /latest_version
|
||||||
env.params.query["id"] = video_id
|
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["title"] = filename
|
||||||
env.params.query["local"] = "true"
|
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
|
else
|
||||||
return error_template(400, "Invalid label or itag")
|
return error_template(400, "Invalid label or itag")
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user