From 1c3b96dc4e85283544439bb8d5ce1765acb7a7a2 Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 6 Dec 2019 22:54:08 -0600 Subject: [PATCH] deviantart: fix non-downloadable posts (#4219). Adapted from https://github.com/lllusion3469/danbooru/commit/e51e1aa7ddb73e92541bfbcab5c2f8c0359a07dc. --- app/logical/sources/strategies/deviant_art.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/logical/sources/strategies/deviant_art.rb b/app/logical/sources/strategies/deviant_art.rb index 3cc05a8b5..7db3501c1 100644 --- a/app/logical/sources/strategies/deviant_art.rb +++ b/app/logical/sources/strategies/deviant_art.rb @@ -91,8 +91,16 @@ module Sources elsif api_deviation[:isDownloadable] api_client.download_url else - file = api_deviation[:files].find { |data| data[:type] == "fullview" } - src = file[:src] + media = api_deviation[:media] + token = media[:token].first + fullview = media[:types].find { |data| data[:t] == "fullview" && data[:c].present? } + + if fullview.present? + op = fullview[:c].gsub('', media[:prettyName]) + src = "#{media[:baseUri]}/#{op}?token=#{token}" + else + src = "#{media[:baseUri]}?token=#{token}" + end if deviation_id && deviation_id.to_i <= 790677560 && src =~ /\Ahttps:\/\/images-wixmp-/i src = src.gsub(%r!(/f/[a-f0-9-]+/[a-f0-9-]+)!, '/intermediary\1')