mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-12-14 00:55:10 +00:00
Add header duplication for feeds
This commit is contained in:
@@ -170,7 +170,7 @@ module Invidious::Routes::Feeds
|
|||||||
"default" => "http://www.w3.org/2005/Atom",
|
"default" => "http://www.w3.org/2005/Atom",
|
||||||
}
|
}
|
||||||
|
|
||||||
response = YT_POOL.client &.get("/feeds/videos.xml?channel_id=#{ucid}")
|
response = YT_POOL.client env, ["Expires", "Cache-Control", "Date"], &.get("/feeds/videos.xml?channel_id=#{ucid}")
|
||||||
return error_atom(404, NotFoundException.new("Channel does not exist.")) if response.status_code == 404
|
return error_atom(404, NotFoundException.new("Channel does not exist.")) if response.status_code == 404
|
||||||
rss = XML.parse(response.body)
|
rss = XML.parse(response.body)
|
||||||
|
|
||||||
@@ -320,7 +320,7 @@ module Invidious::Routes::Feeds
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
response = YT_POOL.client &.get("/feeds/videos.xml?playlist_id=#{plid}")
|
response = YT_POOL.client env, ["Expires", "Cache-Control", "Date"], &.get("/feeds/videos.xml?playlist_id=#{plid}")
|
||||||
return error_atom(404, NotFoundException.new("Playlist does not exist.")) if response.status_code == 404
|
return error_atom(404, NotFoundException.new("Playlist does not exist.")) if response.status_code == 404
|
||||||
|
|
||||||
document = XML.parse(response.body)
|
document = XML.parse(response.body)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ struct YoutubeConnectionPool
|
|||||||
@pool = build_pool()
|
@pool = build_pool()
|
||||||
end
|
end
|
||||||
|
|
||||||
def client(&)
|
def client(env : HTTP::Server::Context? = nil, headers_to_duplicate : Array(String)? = nil, &)
|
||||||
conn = pool.checkout
|
conn = pool.checkout
|
||||||
# Proxy needs to be reinstated every time we get a client from the pool
|
# Proxy needs to be reinstated every time we get a client from the pool
|
||||||
conn.proxy = make_configured_http_proxy_client() if CONFIG.http_proxy
|
conn.proxy = make_configured_http_proxy_client() if CONFIG.http_proxy
|
||||||
@@ -29,6 +29,20 @@ struct YoutubeConnectionPool
|
|||||||
pool.release(conn)
|
pool.release(conn)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Shit way do not use do not replicate this is horrible because how blocks work
|
||||||
|
if env && headers_to_duplicate
|
||||||
|
if response.is_a?(HTTP::Client::Response)
|
||||||
|
youtube_response_headers = response.headers
|
||||||
|
if youtube_response_headers
|
||||||
|
headers_to_duplicate.each do |header|
|
||||||
|
if header_value = youtube_response_headers[header]?
|
||||||
|
env.response.headers[header] = header_value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user