deviantart: use image_url as it's a single image

This commit is contained in:
lllusion3469
2020-05-10 21:39:43 +02:00
parent 769bf87a4a
commit f4b4e12235

View File

@@ -79,11 +79,15 @@ module Sources
end end
def image_urls def image_urls
[image_url]
end
def image_url
# work is private, deleted, or the url didn't contain a deviation id; use image url as given by user. # work is private, deleted, or the url didn't contain a deviation id; use image url as given by user.
if api_deviation.blank? if api_deviation.blank?
[url] url
elsif api_deviation[:is_downloadable] elsif api_deviation[:is_downloadable]
[api_download[:src]] api_download[:src]
elsif api_deviation.present? elsif api_deviation.present?
src = api_deviation.dig(:content, :src) src = api_deviation.dig(:content, :src)
if deviation_id && deviation_id.to_i <= 790677560 && src =~ /^https:\/\/images-wixmp-/ && src !~ /\.gif\?/ if deviation_id && deviation_id.to_i <= 790677560 && src =~ /^https:\/\/images-wixmp-/ && src !~ /\.gif\?/
@@ -92,7 +96,7 @@ module Sources
end end
src = src.sub(%r!\Ahttps?://orig\d+\.deviantart\.net!i, "http://origin-orig.deviantart.net") src = src.sub(%r!\Ahttps?://orig\d+\.deviantart\.net!i, "http://origin-orig.deviantart.net")
src = src.gsub(%r!q_\d+,strp!, "q_100") src = src.gsub(%r!q_\d+,strp!, "q_100")
[src] src
else else
raise "Couldn't find image url" # this should never happen raise "Couldn't find image url" # this should never happen
end end