mirror of
https://github.com/iv-org/invidious.git
synced 2025-08-21 02:39:00 -05:00
Merge 4d1f10a30d531531611154ff9f95f05859e30503 into 1ae0f45b0e5dca696986925a06ef4f4b4f43894b
This commit is contained in:
commit
ddbe4b7084
@ -4,15 +4,17 @@ module Invidious::Routes::ErrorRoutes
|
||||
if HOST_URL.empty? && env.request.path.starts_with?("/v1/storyboards/sb")
|
||||
return env.redirect "#{env.request.path[15..]}?#{env.params.query}"
|
||||
end
|
||||
|
||||
|
||||
if md = env.request.path.match(/^\/(?<id>([a-zA-Z0-9_-]{11})|(\w+))$/)
|
||||
item = md["id"]
|
||||
|
||||
# Check if item is branding URL e.g. https://youtube.com/gaming
|
||||
response = YT_POOL.client &.get("/#{item}")
|
||||
|
||||
headers = HTTP::Headers{
|
||||
"Cookie" => "SOCS=CAE" # Cookies to prevent redirects to Cookie Consent Page CAE~Reject all, CAA~showing the cookie banner, CAI~Accept all
|
||||
}
|
||||
response = YT_POOL.client &.get("/#{item}", headers: headers)
|
||||
if response.status_code == 301
|
||||
response = YT_POOL.client &.get(URI.parse(response.headers["Location"]).request_target)
|
||||
response = YT_POOL.client &.get(URI.parse(response.headers["Location"]).request_target, headers: headers)
|
||||
end
|
||||
|
||||
if response.body.empty?
|
||||
@ -49,4 +51,4 @@ module Invidious::Routes::ErrorRoutes
|
||||
env.response.headers["Location"] = "/"
|
||||
haltf env, status_code: 302
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user