Fix handling for maxres thumbnail

This commit is contained in:
syeopite 2021-10-08 06:58:06 -07:00
parent 48191aca6e
commit 6ec4dcfafd
No known key found for this signature in database
GPG Key ID: 6FA616E5A5294A82
1 changed files with 22 additions and 6 deletions

View File

@ -237,10 +237,27 @@ module Invidious::Routes::Images
if name == "maxres.jpg" if name == "maxres.jpg"
build_thumbnails(id).each do |thumb| build_thumbnails(id).each do |thumb|
if YT_POOL.client &.head("/vi/#{id}/#{thumb[:url]}.jpg", headers).status_code == 200 thumbnail_resource_path = "/vi/#{id}/#{thumb[:url]}.jpg"
name = thumb[:url] + ".jpg" # Logic here is short enough that manually typing them out should be fine.
break {% unless flag?(:disable_quic) %}
end if CONFIG.use_quic
if YT_POOL.client &.head(thumbnail_resource_path, headers).status_code == 200
name = thumb[:url] + ".jpg"
break
end
else
if HTTP::Client.head("https://i.ytimg.com#{thumbnail_resource_path}").status_code == 200
name = thumb[:url] + ".jpg"
break
end
end
{% else %}
# This can likely be optimized into a (small) pool sometime in the future.
if HTTP::Client.head("https://i.ytimg.com#{thumbnail_resource_path}").status_code == 200
name = thumb[:url] + ".jpg"
break
end
{% end %}
end end
end end
@ -277,7 +294,7 @@ module Invidious::Routes::Images
end end
else else
HTTP::Client.get("https://i.ytimg.com#{url}") do |resp| HTTP::Client.get("https://i.ytimg.com#{url}") do |resp|
return request_proc.call(resp) return request_proc.call(resp)
end end
end end
{% else %} {% else %}
@ -288,6 +305,5 @@ module Invidious::Routes::Images
{% end %} {% end %}
rescue ex rescue ex
end end
end end
end end