mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-04-11.git
synced 2024-08-15 00:43:26 +00:00
Clean up /videoplayback
This commit is contained in:
parent
77b12b6249
commit
41a04e7c67
1 changed files with 22 additions and 22 deletions
|
@ -2659,6 +2659,12 @@ get "/videoplayback" do |env|
|
||||||
client = make_client(URI.parse(host))
|
client = make_client(URI.parse(host))
|
||||||
response = client.head(url)
|
response = client.head(url)
|
||||||
|
|
||||||
|
if response.headers["Location"]?
|
||||||
|
url = URI.parse(response.headers["Location"])
|
||||||
|
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
||||||
|
next env.redirect url.full_path
|
||||||
|
end
|
||||||
|
|
||||||
headers = env.request.headers
|
headers = env.request.headers
|
||||||
headers.delete("Host")
|
headers.delete("Host")
|
||||||
headers.delete("Cookie")
|
headers.delete("Cookie")
|
||||||
|
@ -2666,30 +2672,24 @@ get "/videoplayback" do |env|
|
||||||
headers.delete("Referer")
|
headers.delete("Referer")
|
||||||
|
|
||||||
client.get(url, headers) do |response|
|
client.get(url, headers) do |response|
|
||||||
if response.headers["Location"]?
|
env.response.status_code = response.status_code
|
||||||
url = URI.parse(response.headers["Location"])
|
|
||||||
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
|
||||||
env.redirect url.full_path
|
|
||||||
else
|
|
||||||
env.response.status_code = response.status_code
|
|
||||||
|
|
||||||
response.headers.each do |key, value|
|
response.headers.each do |key, value|
|
||||||
env.response.headers[key] = value
|
env.response.headers[key] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
||||||
|
|
||||||
begin
|
begin
|
||||||
chunk_size = 4096
|
chunk_size = 4096
|
||||||
size = 1
|
size = 1
|
||||||
while size > 0
|
while size > 0
|
||||||
size = IO.copy(response.body_io, env.response.output, chunk_size)
|
size = IO.copy(response.body_io, env.response.output, chunk_size)
|
||||||
env.response.flush
|
env.response.flush
|
||||||
Fiber.yield
|
Fiber.yield
|
||||||
end
|
|
||||||
rescue ex
|
|
||||||
break
|
|
||||||
end
|
end
|
||||||
|
rescue ex
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue