From 2c7533c37010af6a400b8270a66749dcee02c843 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Mon, 14 Sep 2026 02:39:25 -0300 Subject: [PATCH] chore: Update headers sent to innertube in JSON requests --- src/invidious/yt_backend/youtube_api.cr | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/invidious/yt_backend/youtube_api.cr b/src/invidious/yt_backend/youtube_api.cr index 04c4ac36a..94fe039e8 100644 --- a/src/invidious/yt_backend/youtube_api.cr +++ b/src/invidious/yt_backend/youtube_api.cr @@ -580,12 +580,20 @@ module YoutubeAPI # Query parameters url = "#{endpoint}?prettyPrint=false" + # true if logged in into a Google account on Youtube, therefore + # we set it to true if the instance has cookies enabled. + logged_in = if !CONFIG.cookies.empty? + true + else + false + end + headers = HTTP::Headers{ - "Content-Type" => "application/json; charset=UTF-8", - "Accept-Encoding" => "gzip, deflate", - "x-goog-api-format-version" => "2", - "x-youtube-client-name" => client_config.name_proto, - "x-youtube-client-version" => client_config.version, + "Content-Type" => "application/json", + "Accept-Encoding" => "gzip, deflate", + "x-youtube-bootstrap-logged-in" => logged_in, + "x-youtube-client-name" => client_config.name_proto, + "x-youtube-client-version" => client_config.version, } if user_agent = client_config.user_agent