mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-22 16:19:53 +05:30
Proxy: fix the throttling issue once for all
This commit is contained in:
parent
a743d01a10
commit
865b7e584d
@ -53,11 +53,7 @@ module Invidious::Routes::VideoPlayback
|
|||||||
headers = HTTP::Headers.new
|
headers = HTTP::Headers.new
|
||||||
MediaProxy.copy_request_headers(from: env.request.headers, to: headers)
|
MediaProxy.copy_request_headers(from: env.request.headers, to: headers)
|
||||||
|
|
||||||
if has_range_param
|
headers["Range"] = "bytes=" + (range || "0-")
|
||||||
url += "&range=#{range}"
|
|
||||||
else
|
|
||||||
headers["Range"] = "bytes=#{range || "0-"}"
|
|
||||||
end
|
|
||||||
|
|
||||||
client = make_client(URI.parse(host), region)
|
client = make_client(URI.parse(host), region)
|
||||||
response = HTTP::Client::Response.new(500)
|
response = HTTP::Client::Response.new(500)
|
||||||
@ -107,13 +103,16 @@ module Invidious::Routes::VideoPlayback
|
|||||||
return error_template(403, "Administrator has disabled this endpoint.")
|
return error_template(403, "Administrator has disabled this endpoint.")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Add back the range header. Important!
|
||||||
|
headers["Range"] = "bytes=" + (range || "0-")
|
||||||
|
|
||||||
MediaProxy.proxy_dash_chunk(env, client, url, region)
|
MediaProxy.proxy_dash_chunk(env, client, url, region)
|
||||||
elsif has_range_param
|
elsif has_range_param
|
||||||
if CONFIG.disabled?("dash")
|
if CONFIG.disabled?("dash")
|
||||||
return error_template(403, "Administrator has disabled this endpoint.")
|
return error_template(403, "Administrator has disabled this endpoint.")
|
||||||
end
|
end
|
||||||
|
|
||||||
MediaProxy.proxy_dash_chunk(env, client, url, region)
|
MediaProxy.proxy_dash_chunk(env, client, url + "&range=#{range}", region)
|
||||||
else
|
else
|
||||||
if (title && CONFIG.disabled?("downloads")) || (title.nil? && CONFIG.disabled?("local"))
|
if (title && CONFIG.disabled?("downloads")) || (title.nil? && CONFIG.disabled?("local"))
|
||||||
return error_template(403, "Administrator has disabled this endpoint.")
|
return error_template(403, "Administrator has disabled this endpoint.")
|
||||||
|
Loading…
Reference in New Issue
Block a user