From 45ae8bfb6f8d8b183b87ccc7b76ee7bde57857cc Mon Sep 17 00:00:00 2001 From: lllusion3469 <31420484+lllusion3469@users.noreply.github.com> Date: Mon, 11 May 2020 16:35:44 +0200 Subject: [PATCH] deviantart: support non-downloadable videos --- 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 bc71cae28..eb60440b7 100644 --- a/app/logical/sources/strategies/deviant_art.rb +++ b/app/logical/sources/strategies/deviant_art.rb @@ -90,6 +90,8 @@ module Sources api_download[:src] elsif api_deviation[:flash].present? api_deviation.dig(:flash, :src) + elsif api_deviation[:videos].present? + api_deviation[:videos].max_by { |x| x[:filesize] }[: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 884007616..9b321f6d2 100644 --- a/test/unit/sources/deviant_art_test.rb +++ b/test/unit/sources/deviant_art_test.rb @@ -264,6 +264,16 @@ module Sources end end + context "The source for a non-downloadable video file" do + should "return working image url" do + @site = Sources::Strategies.find("https://www.deviantart.com/gs-mantis/art/Chen-Goes-Fishing-505847233") + + # md5: 344ac2b9fd5a87982af4b648aa2b2b0d + assert_equal("https://wixmp-ed30a86b8c4ca887773594c2.wixmp.com/v/mp4/fe046bc7-4d68-4699-96c1-19aa464edff6/d8d6281-91959e92-214f-4b2d-a138-ace09f4b6d09.1080p.8e57939eba634743a9fa41185e398d00.mp4", @site.image_url) + assert_downloaded(9_739_947, @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")