From 769bf87a4a93805c0ef70bef884d596a6906f38d Mon Sep 17 00:00:00 2001 From: lllusion3469 <31420484+lllusion3469@users.noreply.github.com> Date: Sun, 10 May 2020 21:33:43 +0200 Subject: [PATCH] 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 --- app/logical/sources/strategies/deviant_art.rb | 2 +- test/unit/sources/deviant_art_test.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/logical/sources/strategies/deviant_art.rb b/app/logical/sources/strategies/deviant_art.rb index 00f4f48f7..bcb3a3fb7 100644 --- a/app/logical/sources/strategies/deviant_art.rb +++ b/app/logical/sources/strategies/deviant_art.rb @@ -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 diff --git a/test/unit/sources/deviant_art_test.rb b/test/unit/sources/deviant_art_test.rb index dbc084106..d1de694be 100644 --- a/test/unit/sources/deviant_art_test.rb +++ b/test/unit/sources/deviant_art_test.rb @@ -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")