From bb2e3b2a3e5f53610b9dd602f8507303ec641450 Mon Sep 17 00:00:00 2001 From: Emilien <4016501+unixfox@users.noreply.github.com> Date: Sun, 17 Nov 2024 12:26:35 +0100 Subject: [PATCH] crystal handle decompression already by itself --- src/invidious/config.cr | 8 ++++---- src/invidious/yt_backend/youtube_api.cr | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/invidious/config.cr b/src/invidious/config.cr index 4b06ff83..20268ed1 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -251,16 +251,16 @@ class Config end {% end %} - if !CONFIG.invidious_companion.empty? + if !config.invidious_companion.empty? # 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." exit(1) 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." 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!!" exit(1) end diff --git a/src/invidious/yt_backend/youtube_api.cr b/src/invidious/yt_backend/youtube_api.cr index 6a0e50a1..8fef8472 100644 --- a/src/invidious/yt_backend/youtube_api.cr +++ b/src/invidious/yt_backend/youtube_api.cr @@ -685,7 +685,6 @@ module YoutubeAPI ) : Hash(String, JSON::Any) headers = HTTP::Headers{ "Content-Type" => "application/json; charset=UTF-8", - "Accept-Encoding" => "gzip", "Authorization" => "Bearer " + CONFIG.invidious_companion_key, } @@ -698,7 +697,7 @@ module YoutubeAPI begin response = make_client(CONFIG.invidious_companion.sample, &.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) raise Exception.new("Error while communicating with Invidious companion: \ status code: " + response.status_code.to_s + " and body: " + body)