forked from midou/invidious
Fix local redirects in /videoplayback
This commit is contained in:
parent
665ef9424e
commit
61769c6f9c
@ -4200,6 +4200,11 @@ get "/videoplayback" do |env|
|
|||||||
fvip = query_params["fvip"]? || "3"
|
fvip = query_params["fvip"]? || "3"
|
||||||
mns = query_params["mn"].split(",")
|
mns = query_params["mn"].split(",")
|
||||||
|
|
||||||
|
if query_params["region"]?
|
||||||
|
region = query_params["region"]
|
||||||
|
query_params.delete("region")
|
||||||
|
end
|
||||||
|
|
||||||
if query_params["host"]? && !query_params["host"].empty?
|
if query_params["host"]? && !query_params["host"].empty?
|
||||||
host = "https://#{query_params["host"]}"
|
host = "https://#{query_params["host"]}"
|
||||||
query_params.delete("host")
|
query_params.delete("host")
|
||||||
@ -4216,8 +4221,6 @@ get "/videoplayback" do |env|
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
region = query_params["region"]?
|
|
||||||
|
|
||||||
response = HTTP::Client::Response.new(403)
|
response = HTTP::Client::Response.new(403)
|
||||||
5.times do
|
5.times do
|
||||||
begin
|
begin
|
||||||
@ -4240,6 +4243,8 @@ get "/videoplayback" do |env|
|
|||||||
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
||||||
|
|
||||||
url = url.full_path
|
url = url.full_path
|
||||||
|
url += "&host=#{host.lchop("https://")}"
|
||||||
|
|
||||||
if region
|
if region
|
||||||
url += "®ion=#{region}"
|
url += "®ion=#{region}"
|
||||||
end
|
end
|
||||||
@ -4260,6 +4265,20 @@ get "/videoplayback" do |env|
|
|||||||
env.response.headers[key] = value
|
env.response.headers[key] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if response.headers["Location"]?
|
||||||
|
url = URI.parse(response.headers["Location"])
|
||||||
|
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
||||||
|
|
||||||
|
url = url.full_path
|
||||||
|
url += "&host=#{host.lchop("https://")}"
|
||||||
|
|
||||||
|
if region
|
||||||
|
url += "®ion=#{region}"
|
||||||
|
end
|
||||||
|
|
||||||
|
next env.redirect url
|
||||||
|
end
|
||||||
|
|
||||||
if title = query_params["title"]?
|
if title = query_params["title"]?
|
||||||
# https://blog.fastmail.com/2011/06/24/download-non-english-filenames/
|
# https://blog.fastmail.com/2011/06/24/download-non-english-filenames/
|
||||||
env.response.headers["Content-Disposition"] = "attachment; filename=\"#{URI.escape(title)}\"; filename*=UTF-8''#{URI.escape(title)}"
|
env.response.headers["Content-Disposition"] = "attachment; filename=\"#{URI.escape(title)}\"; filename*=UTF-8''#{URI.escape(title)}"
|
||||||
|
Loading…
Reference in New Issue
Block a user