deviantart: don't apply /intermediary/ hack for gifs

gifs are always stored as original anyways so the /intermediary/ url
doesn't actually exist for gifs

example:
https://www.deviantart.com/heartgear/art/Silent-Night-579982816
This commit is contained in:
lllusion3469
2020-05-10 21:33:43 +02:00
parent c2e86385a3
commit 769bf87a4a
2 changed files with 11 additions and 1 deletions

View File

@@ -86,7 +86,7 @@ module Sources
[api_download[:src]]
elsif api_deviation.present?
src = api_deviation.dig(:content, :src)
if deviation_id && deviation_id.to_i <= 790677560 && src =~ /^https:\/\/images-wixmp-/
if deviation_id && deviation_id.to_i <= 790677560 && src =~ /^https:\/\/images-wixmp-/ && src !~ /\.gif\?/
src = src.sub(%r!(/f/[a-f0-9-]+/[a-f0-9-]+)!, '/intermediary\1')
src = src.sub(%r!/v1/(fit|fill)/.*\z!i, "")
end

View File

@@ -244,6 +244,16 @@ module Sources
end
end
context "The source for a non-downloadable animated gif with id<=790677560" do
should "return working image url" do
@site = Sources::Strategies.find("https://www.deviantart.com/heartgear/art/Silent-Night-579982816")
# md5: 62caac1863aa264a56d548b4b7607097
assert_match(%r!\Ahttps://images-wixmp-ed30a86b8c4ca887773594c2\.wixmp\.com/f/ea95be00-c5aa-4063-bd55-f5a9183912f7/d9lb1ls-7d625444-0003-4123-bf00-274737ca7fdd.gif\?token=!, @site.image_url)
assert_downloaded(350_156, @site.image_url)
end
end
context "The source for an DeviantArt artwork page" do
setup do
@site = Sources::Strategies.find("http://noizave.deviantart.com/art/test-post-please-ignore-685436408")