mirror of
https://github.com/iv-org/invidious.git
synced 2025-08-14 00:28:31 +00:00
YoutubeAPI: use proxy_region from client_config
And accept gzip compressed data, to help save on bandwidth
This commit is contained in:
parent
79a638e059
commit
9d2932afdb
@ -333,13 +333,27 @@ module YoutubeAPI
|
|||||||
# Use the default client config if nil is passed
|
# Use the default client config if nil is passed
|
||||||
client_config ||= DEFAULT_CLIENT_CONFIG
|
client_config ||= DEFAULT_CLIENT_CONFIG
|
||||||
|
|
||||||
# Send the POST request and parse result
|
# Query parameters
|
||||||
response = YT_POOL.client &.post(
|
url = "#{endpoint}?key=#{client_config.api_key}"
|
||||||
"#{endpoint}?key=#{client_config.api_key}",
|
|
||||||
headers: HTTP::Headers{"content-type" => "application/json; charset=UTF-8"},
|
|
||||||
body: data.to_json
|
|
||||||
)
|
|
||||||
|
|
||||||
|
headers = HTTP::Headers{
|
||||||
|
"Content-Type" => "application/json; charset=UTF-8",
|
||||||
|
"Accept-Encoding" => "gzip",
|
||||||
|
}
|
||||||
|
|
||||||
|
# Send the POST request
|
||||||
|
if client_config.proxy_region
|
||||||
|
response = YT_POOL.client(
|
||||||
|
client_config.proxy_region,
|
||||||
|
&.post(url, headers: headers, body: data.to_json)
|
||||||
|
)
|
||||||
|
else
|
||||||
|
response = YT_POOL.client &.post(
|
||||||
|
url, headers: headers, body: data.to_json
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Convert result to Hash
|
||||||
initial_data = JSON.parse(response.body).as_h
|
initial_data = JSON.parse(response.body).as_h
|
||||||
|
|
||||||
# Error handling
|
# Error handling
|
||||||
|
Loading…
Reference in New Issue
Block a user