From 865b7e584d16aa8947b3f0449bf4c048ca01a7f4 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Wed, 8 Mar 2023 19:38:15 +0100 Subject: [PATCH] Proxy: fix the throttling issue once for all --- src/invidious/routes/video_playback.cr | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/invidious/routes/video_playback.cr b/src/invidious/routes/video_playback.cr index 1d1c1648..562a1ed3 100644 --- a/src/invidious/routes/video_playback.cr +++ b/src/invidious/routes/video_playback.cr @@ -53,11 +53,7 @@ module Invidious::Routes::VideoPlayback headers = HTTP::Headers.new MediaProxy.copy_request_headers(from: env.request.headers, to: headers) - if has_range_param - url += "&range=#{range}" - else - headers["Range"] = "bytes=#{range || "0-"}" - end + headers["Range"] = "bytes=" + (range || "0-") client = make_client(URI.parse(host), region) response = HTTP::Client::Response.new(500) @@ -107,13 +103,16 @@ module Invidious::Routes::VideoPlayback return error_template(403, "Administrator has disabled this endpoint.") end + # Add back the range header. Important! + headers["Range"] = "bytes=" + (range || "0-") + MediaProxy.proxy_dash_chunk(env, client, url, region) elsif has_range_param if CONFIG.disabled?("dash") return error_template(403, "Administrator has disabled this endpoint.") end - MediaProxy.proxy_dash_chunk(env, client, url, region) + MediaProxy.proxy_dash_chunk(env, client, url + "&range=#{range}", region) else if (title && CONFIG.disabled?("downloads")) || (title.nil? && CONFIG.disabled?("local")) return error_template(403, "Administrator has disabled this endpoint.")