Simplify namespace calls to ConnectionPool

This commit is contained in:
syeopite 2024-11-14 19:52:48 -08:00
parent 6b3f665dfb
commit 4c1db6e03e
No known key found for this signature in database
GPG Key ID: A73C186DA3955A1A
2 changed files with 6 additions and 6 deletions

View File

@ -87,7 +87,7 @@ module Invidious::ConnectionPool
# Mapping of subdomain => Invidious::ConnectionPool::Pool # Mapping of subdomain => Invidious::ConnectionPool::Pool
# This is needed as we may need to access arbitrary subdomains of ytimg # This is needed as we may need to access arbitrary subdomains of ytimg
private YTIMG_POOLS = {} of String => Invidious::ConnectionPool::Pool private YTIMG_POOLS = {} of String => ConnectionPool::Pool
# Fetches a HTTP pool for the specified subdomain of ytimg.com # Fetches a HTTP pool for the specified subdomain of ytimg.com
# #
@ -97,7 +97,7 @@ module Invidious::ConnectionPool
return pool return pool
else else
LOGGER.info("ytimg_pool: Creating a new HTTP pool for \"https://#{subdomain}.ytimg.com\"") LOGGER.info("ytimg_pool: Creating a new HTTP pool for \"https://#{subdomain}.ytimg.com\"")
pool = Invidious::ConnectionPool::Pool.new( pool = ConnectionPool::Pool.new(
URI.parse("https://#{subdomain}.ytimg.com"), URI.parse("https://#{subdomain}.ytimg.com"),
max_capacity: CONFIG.pool_size, max_capacity: CONFIG.pool_size,
idle_capacity: CONFIG.idle_pool_size, idle_capacity: CONFIG.idle_pool_size,

View File

@ -42,7 +42,7 @@ module Invidious::Routes::Images
end end
begin begin
Invidious::ConnectionPool.get_ytimg_pool(authority).get(url, headers) do |resp| ConnectionPool.get_ytimg_pool(authority).get(url, headers) do |resp|
env.response.headers["Connection"] = "close" env.response.headers["Connection"] = "close"
return self.proxy_image(env, resp) return self.proxy_image(env, resp)
end end
@ -65,7 +65,7 @@ module Invidious::Routes::Images
end end
begin begin
Invidious::ConnectionPool.get_ytimg_pool("i9").get(url, headers) do |resp| ConnectionPool.get_ytimg_pool("i9").get(url, headers) do |resp|
return self.proxy_image(env, resp) return self.proxy_image(env, resp)
end end
rescue ex rescue ex
@ -111,7 +111,7 @@ module Invidious::Routes::Images
if name == "maxres.jpg" if name == "maxres.jpg"
build_thumbnails(id).each do |thumb| build_thumbnails(id).each do |thumb|
thumbnail_resource_path = "/vi/#{id}/#{thumb[:url]}.jpg" thumbnail_resource_path = "/vi/#{id}/#{thumb[:url]}.jpg"
if Invidious::ConnectionPool.get_ytimg_pool("i9").head(thumbnail_resource_path, headers).status_code == 200 if ConnectionPool.get_ytimg_pool("i9").head(thumbnail_resource_path, headers).status_code == 200
name = thumb[:url] + ".jpg" name = thumb[:url] + ".jpg"
break break
end end
@ -127,7 +127,7 @@ module Invidious::Routes::Images
end end
begin begin
Invidious::ConnectionPool.get_ytimg_pool("i").get(url, headers) do |resp| ConnectionPool.get_ytimg_pool("i").get(url, headers) do |resp|
return self.proxy_image(env, resp) return self.proxy_image(env, resp)
end end
rescue ex rescue ex