deviantart: fix non-downloadable posts (#4219).

Adapted from e51e1aa7dd.
This commit is contained in:
evazion
2019-12-06 22:54:08 -06:00
parent 2bffad9311
commit 1c3b96dc4e

View File

@@ -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('<prettyName>', 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')