Skip to content

Commit

Permalink
VideoProxy: Handle 302 redirects in chunked section
Browse files Browse the repository at this point in the history
  • Loading branch information
SamantazFox committed Nov 10, 2024
1 parent e7a93fc commit 91c0ae4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/invidious/routes/video_playback.cr
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,13 @@ module Invidious::Routes::VideoPlayback
env.response.headers["Access-Control-Allow-Origin"] = "*"

if location = resp.headers["Location"]?
location = URI.parse(location)
location = "#{location.request_target}&host=#{location.host}#{region ? "&region=#{region}" : ""}"
url = Invidious::HttpServer::Utils.proxy_video_url(location, region: region)

env.redirect location
break
if title = query_params["title"]?
url = "#{url}&title=#{URI.encode_www_form(title)}"
end

return env.redirect url
end

if title = query_params["title"]?
Expand Down

0 comments on commit 91c0ae4

Please sign in to comment.