mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-03-16.git
synced 2024-08-15 00:53:18 +00:00
Add retry for /videoplaybacl
This commit is contained in:
parent
40fb29ea2b
commit
952b208a01
1 changed files with 16 additions and 8 deletions
|
@ -3644,9 +3644,23 @@ get "/videoplayback" do |env|
|
||||||
host = "https://r#{fvip}---#{mn}.googlevideo.com"
|
host = "https://r#{fvip}---#{mn}.googlevideo.com"
|
||||||
url = "/videoplayback?#{query_params.to_s}"
|
url = "/videoplayback?#{query_params.to_s}"
|
||||||
|
|
||||||
|
headers = env.request.headers
|
||||||
|
headers.delete("Host")
|
||||||
|
headers.delete("Cookie")
|
||||||
|
headers.delete("User-Agent")
|
||||||
|
headers.delete("Referer")
|
||||||
|
|
||||||
region = query_params["region"]?
|
region = query_params["region"]?
|
||||||
|
|
||||||
|
response = HTTP::Client::Response.new(403)
|
||||||
|
loop do
|
||||||
|
begin
|
||||||
client = make_client(URI.parse(host), proxies, region)
|
client = make_client(URI.parse(host), proxies, region)
|
||||||
response = client.head(url)
|
response = client.head(url, headers)
|
||||||
|
break
|
||||||
|
rescue ex
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if response.headers["Location"]?
|
if response.headers["Location"]?
|
||||||
url = URI.parse(response.headers["Location"])
|
url = URI.parse(response.headers["Location"])
|
||||||
|
@ -3664,12 +3678,6 @@ get "/videoplayback" do |env|
|
||||||
halt env, status_code: 403
|
halt env, status_code: 403
|
||||||
end
|
end
|
||||||
|
|
||||||
headers = env.request.headers
|
|
||||||
headers.delete("Host")
|
|
||||||
headers.delete("Cookie")
|
|
||||||
headers.delete("User-Agent")
|
|
||||||
headers.delete("Referer")
|
|
||||||
|
|
||||||
client = make_client(URI.parse(host), proxies, region)
|
client = make_client(URI.parse(host), proxies, region)
|
||||||
client.get(url, headers) do |response|
|
client.get(url, headers) do |response|
|
||||||
env.response.status_code = response.status_code
|
env.response.status_code = response.status_code
|
||||||
|
|
Loading…
Reference in a new issue