crystal handle decompression already by itself

This commit is contained in:
Emilien 2024-11-17 12:26:35 +01:00
parent b51770dbdb
commit bb2e3b2a3e
2 changed files with 5 additions and 6 deletions

View File

@ -251,16 +251,16 @@ class Config
end end
{% end %} {% end %}
if !CONFIG.invidious_companion.empty? if !config.invidious_companion.empty?
# invidious_companion and signature_server can't work together # invidious_companion and signature_server can't work together
if CONFIG.signature_server if config.signature_server
puts "Config: You can not run inv_sig_helper and invidious_companion at the same time." puts "Config: You can not run inv_sig_helper and invidious_companion at the same time."
exit(1) exit(1)
end end
if CONFIG.invidious_companion_key.empty? if config.invidious_companion_key.empty?
puts "Config: Please configure a key if you are using invidious companion." puts "Config: Please configure a key if you are using invidious companion."
exit(1) exit(1)
elsif CONFIG.invidious_companion_key == "CHANGE_ME!!" elsif config.invidious_companion_key == "CHANGE_ME!!"
puts "Config: The value of 'invidious_companion_key' needs to be changed!!" puts "Config: The value of 'invidious_companion_key' needs to be changed!!"
exit(1) exit(1)
end end

View File

@ -685,7 +685,6 @@ module YoutubeAPI
) : Hash(String, JSON::Any) ) : Hash(String, JSON::Any)
headers = HTTP::Headers{ headers = HTTP::Headers{
"Content-Type" => "application/json; charset=UTF-8", "Content-Type" => "application/json; charset=UTF-8",
"Accept-Encoding" => "gzip",
"Authorization" => "Bearer " + CONFIG.invidious_companion_key, "Authorization" => "Bearer " + CONFIG.invidious_companion_key,
} }
@ -698,7 +697,7 @@ module YoutubeAPI
begin begin
response = make_client(CONFIG.invidious_companion.sample, response = make_client(CONFIG.invidious_companion.sample,
&.post(endpoint, headers: headers, body: data.to_json)) &.post(endpoint, headers: headers, body: data.to_json))
body = self._decompress(response.body_io, response.headers["Content-Encoding"]?) body = response.body
if (response.status_code != 200) if (response.status_code != 200)
raise Exception.new("Error while communicating with Invidious companion: \ raise Exception.new("Error while communicating with Invidious companion: \
status code: " + response.status_code.to_s + " and body: " + body) status code: " + response.status_code.to_s + " and body: " + body)