Merge pull request #5201 from nonamethanks/fix-deviantart
Deviantart: fix regression in 3a0a32b98a
This commit is contained in:
@@ -38,10 +38,7 @@ module Source
|
||||
def extract_largest(src)
|
||||
if src =~ %r{\Ahttps://images-wixmp-}
|
||||
sample, separator, * = src.partition("/v1/")
|
||||
if separator.blank?
|
||||
src = src.sub(%r{(/f/[a-f0-9-]+/[a-f0-9-]+)}, '/intermediary\1') unless src =~ /\.gif\?/
|
||||
src
|
||||
else
|
||||
if separator.present?
|
||||
# :^) https://i.imgur.com/KG5bVRU.png
|
||||
# shamelessly aped from:
|
||||
# https://github.com/mikf/gallery-dl/blob/7990fe84f11271bc8e4079db6b0248dbeb79474a/gallery_dl/extractor/deviantart.py#L293
|
||||
@@ -49,6 +46,11 @@ module Source
|
||||
data = {sub: "urn:app:", iss: "urn:app:", obj: [[{path: "/f/#{f_value}"}]], aud: ["urn:service:file.download"]}
|
||||
token = Base64.encode64(JSON.generate(data)).gsub("=", "").gsub("\n", "")
|
||||
"#{sample}?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.#{token}."
|
||||
elsif deviation_id && deviation_id.to_i <= 790_677_560 && src !~ /\.gif\?/
|
||||
src = src.sub(%r{(/f/[a-f0-9-]+/[a-f0-9-]+)}, '/intermediary\1')
|
||||
src.sub(%r{/v1/(fit|fill)/.*\z}i, "")
|
||||
else
|
||||
src
|
||||
end
|
||||
else
|
||||
src = src.sub(%r{\Ahttps?://orig\d+\.deviantart\.net}i, "http://origin-orig.deviantart.net")
|
||||
|
||||
@@ -42,6 +42,13 @@ module Sources
|
||||
)
|
||||
end
|
||||
|
||||
context "A deviantart post with the intermediary version giving 404" do
|
||||
strategy_should_work(
|
||||
"https://www.deviantart.com/gregmks/art/Rhino-Castle-811778248",
|
||||
image_urls: [%r{\Ahttps://images-wixmp-ed30a86b8c4ca887773594c2\.wixmp\.com/f/8c03bd02-63bf-407e-9c3e-c3fd21ab4bd5/ddfb83s-64c3b1fd-a554-498c-87dd-7ce83721a3d0\.jpg\?token=}]
|
||||
)
|
||||
end
|
||||
|
||||
context "A deviantart origin-orig image" do
|
||||
desc = <<-EOS.strip_heredoc.chomp
|
||||
blah blah
|
||||
|
||||
Reference in New Issue
Block a user