nicoseiga: optimize image_url method.
The image_url method makes a request to `https://seiga.nicovideo.jp/images/source/:image_id` to see where this URL redirects to. Before we did a GET request, which caused it to download the full image. This could fail with a timeout error if the download took too long. We also cached the request, which caused the full image to be cached, even though we only need the headers. Change it to a HEAD request so we don't have to download the entire image just to check the URL.
This commit is contained in:
@@ -81,7 +81,7 @@ module Sources
|
||||
else image_urls.first
|
||||
end
|
||||
|
||||
resp = api_client.get(img)
|
||||
resp = api_client.login.head(img)
|
||||
if resp.uri.to_s =~ %r{https?://.+/(\w+/\d+/\d+)\z}i
|
||||
"https://lohas.nicoseiga.jp/priv/#{$1}"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user