moebooru: fix preview_urls to fallback to image_urls.
Fix the moebooru strategy to fallback to returning the image url if we can't find the preview url. Fixes iqdb lookups failing in some cases because the strategy didn't return a valid url for preview_url.
This commit is contained in:
@@ -62,7 +62,7 @@ module Sources
|
||||
end
|
||||
|
||||
def preview_urls
|
||||
return [] unless post_md5.present?
|
||||
return image_urls unless post_md5.present?
|
||||
["https://#{file_host}/data/preview/#{post_md5[0..1]}/#{post_md5[2..3]}/#{post_md5}.jpg"]
|
||||
end
|
||||
|
||||
|
||||
@@ -28,6 +28,15 @@ module Sources
|
||||
end
|
||||
end
|
||||
|
||||
context "A 'https://assets.yande.re/preview/:hh/:hh/:file.jpg' preview url" do
|
||||
should "return a non-empty list of preview_urls" do
|
||||
url = "https://assets.yande.re/data/preview/7c/d1/7cd124fc28203233cce3bade26651d43.jpg"
|
||||
site = Sources::Strategies.find(url)
|
||||
|
||||
assert_equal([url], site.preview_urls)
|
||||
end
|
||||
end
|
||||
|
||||
context "Fetching data for an active yande.re .jpg post" do
|
||||
should "work" do
|
||||
@prev = "https://files.yande.re/data/preview/7e/cf/7ecfdead705d7b956b26b1d37b98d089.jpg"
|
||||
|
||||
Reference in New Issue
Block a user