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:
evazion
2019-10-26 13:35:59 -05:00
parent ecfeaca7d4
commit a15bbe4264
2 changed files with 10 additions and 1 deletions

View File

@@ -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

View File

@@ -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"