From 0d5e31868feecdf28cbd3c44db5c9d0f6cfebe19 Mon Sep 17 00:00:00 2001 From: lllusion3469 <31420484+lllusion3469@users.noreply.github.com> Date: Mon, 11 May 2020 00:55:06 +0200 Subject: [PATCH] deviantart: fix non-downloadable flash files --- app/logical/sources/strategies/deviant_art.rb | 2 ++ test/unit/sources/deviant_art_test.rb | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/app/logical/sources/strategies/deviant_art.rb b/app/logical/sources/strategies/deviant_art.rb index 6f39eea33..e69ee913c 100644 --- a/app/logical/sources/strategies/deviant_art.rb +++ b/app/logical/sources/strategies/deviant_art.rb @@ -88,6 +88,8 @@ module Sources url elsif api_deviation[:is_downloadable] api_download[:src] + elsif api_deviation[:flash].present? + api_deviation.dig(:flash, :src) else src = api_deviation.dig(:content, :src) if deviation_id && deviation_id.to_i <= 790677560 && src =~ /^https:\/\/images-wixmp-/ && src !~ /\.gif\?/ diff --git a/test/unit/sources/deviant_art_test.rb b/test/unit/sources/deviant_art_test.rb index d1de694be..884007616 100644 --- a/test/unit/sources/deviant_art_test.rb +++ b/test/unit/sources/deviant_art_test.rb @@ -254,6 +254,16 @@ module Sources end end + context "The source for a non-downloadable flash file" do + should "return working image url" do + @site = Sources::Strategies.find("https://www.deviantart.com/heartgear/art/SL-40v3-522007633") + + # md5: 6adf1a3d532f898f44cf9948cbc7db7d + assert_match(%r!\Ahttps://api-da\.wixmp\.com/_api/download/file\?downloadToken=!, @site.image_url) + assert_downloaded(3_496_110, @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")