deviantart: fix error when uploading image belonging to deleted work.
This commit is contained in:
@@ -147,17 +147,20 @@ module Sources
|
|||||||
|
|
||||||
if resp.success?
|
if resp.success?
|
||||||
body = Zlib.gunzip(resp.body)
|
body = Zlib.gunzip(resp.body)
|
||||||
|
Nokogiri::HTML(body)
|
||||||
|
# the work was deleted
|
||||||
|
elsif resp.code == 404
|
||||||
|
nil
|
||||||
else
|
else
|
||||||
raise HTTParty::ResponseError.new(resp)
|
raise HTTParty::ResponseError.new(resp)
|
||||||
end
|
end
|
||||||
|
|
||||||
Nokogiri::HTML(body)
|
|
||||||
end
|
end
|
||||||
memoize :page
|
memoize :page
|
||||||
|
|
||||||
# Scrape UUID from <meta property="da:appurl" content="DeviantArt://deviation/12F08C5D-A3A4-338C-2F1A-7E4E268C0E8B">
|
# Scrape UUID from <meta property="da:appurl" content="DeviantArt://deviation/12F08C5D-A3A4-338C-2F1A-7E4E268C0E8B">
|
||||||
# For private works the UUID will be nil.
|
# For hidden or deleted works the UUID will be nil.
|
||||||
def uuid
|
def uuid
|
||||||
|
return nil if page.nil?
|
||||||
meta = page.search('meta[property="da:appurl"]').first
|
meta = page.search('meta[property="da:appurl"]').first
|
||||||
return nil if meta.nil?
|
return nil if meta.nil?
|
||||||
|
|
||||||
|
|||||||
@@ -17,13 +17,10 @@ module Sources
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "The source for a private DeviantArt image URL" do
|
context "The source for a deleted DeviantArt image URL" do
|
||||||
setup do
|
|
||||||
@site = Sources::Strategies.find("https://pre00.deviantart.net/423b/th/pre/i/2017/281/e/0/mindflayer_girl01_by_nickbeja-dbpxdt8.png")
|
|
||||||
end
|
|
||||||
|
|
||||||
should "work" do
|
should "work" do
|
||||||
assert_equal(["https://pre00.deviantart.net/423b/th/pre/i/2017/281/e/0/mindflayer_girl01_by_nickbeja-dbpxdt8.png"], @site.image_urls)
|
@site = Sources::Strategies.find("https://pre00.deviantart.net/423b/th/pre/i/2017/281/e/0/mindflayer_girl01_by_nickbeja-dbpxdt8.png")
|
||||||
|
assert_equal("https://pre00.deviantart.net/423b/th/pre/i/2017/281/e/0/mindflayer_girl01_by_nickbeja-dbpxdt8.png", @site.image_url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user