Fix #3994: Some deviantart images mistakenly choosing preview image.

This commit is contained in:
evazion 2018-11-29 23:01:08 -06:00
parent 0317b99330
commit 8da3474a8b
2 changed files with 10 additions and 1 deletions

View File

@ -70,7 +70,7 @@ module Sources
if api_deviation.blank?
[url]
# work is downloadable
elsif api_deviation[:is_downloadable] && api_deviation[:download_filesize] != api_deviation.dig(:content, :filesize)
elsif api_deviation[:is_downloadable]
src = api_download[:src]
src.gsub!(%r!\Ahttps?://s3\.amazonaws\.com/!i, "https://")
src.gsub!(/\?.*\z/, "") # strip s3 query params

View File

@ -43,6 +43,15 @@ module Sources
end
end
context "The source for a download-enabled DeviantArt artwork page" do
should "get the download image url" do
@site = Sources::Strategies.find("https://www.deviantart.com/len1/art/All-that-Glitters-II-774592781")
assert_equal(["http://origin-orig.deviantart.net/a713/f/2018/333/3/6/all_that_glitters_ii_by_len1-dct67m5.jpg"], @site.image_urls)
assert_equal(@site.image_url, @site.canonical_url)
end
end
context "The source for a DeviantArt image url" do
should "fetch the source data" do
@site = Sources::Strategies.find("https://pre00.deviantart.net/b5e6/th/pre/f/2016/265/3/5/legend_of_galactic_heroes_by_hideyoshi-daihpha.jpg")