make_client: add YouTube headers on *.youtube.com

This commit is contained in:
syeopite 2024-08-24 19:41:39 -07:00
parent 46c58bd84c
commit 6e39b9b303
No known key found for this signature in database
GPG Key ID: A73C186DA3955A1A

View File

@ -55,7 +55,7 @@ def make_client(url : URI, region = nil, force_resolve : Bool = false, force_you
client.family = Socket::Family::INET if client.family == Socket::Family::UNSPEC client.family = Socket::Family::INET if client.family == Socket::Family::UNSPEC
end end
client.before_request { |r| add_yt_headers(r) } if url.host == "www.youtube.com" || force_youtube_headers client.before_request { |r| add_yt_headers(r) } if url.host.try &.ends_with?("youtube.com") || force_youtube_headers
client.read_timeout = 10.seconds client.read_timeout = 10.seconds
client.connect_timeout = 10.seconds client.connect_timeout = 10.seconds