diff --git a/app/logical/sources/strategies/deviant_art.rb b/app/logical/sources/strategies/deviant_art.rb index d6599b75e..6965be8aa 100644 --- a/app/logical/sources/strategies/deviant_art.rb +++ b/app/logical/sources/strategies/deviant_art.rb @@ -147,17 +147,20 @@ module Sources if resp.success? body = Zlib.gunzip(resp.body) + Nokogiri::HTML(body) + # the work was deleted + elsif resp.code == 404 + nil else raise HTTParty::ResponseError.new(resp) end - - Nokogiri::HTML(body) end memoize :page # Scrape UUID from - # For private works the UUID will be nil. + # For hidden or deleted works the UUID will be nil. def uuid + return nil if page.nil? meta = page.search('meta[property="da:appurl"]').first return nil if meta.nil? diff --git a/test/unit/sources/deviantart_test.rb b/test/unit/sources/deviantart_test.rb index 9e63d0709..63b3b52e7 100644 --- a/test/unit/sources/deviantart_test.rb +++ b/test/unit/sources/deviantart_test.rb @@ -17,13 +17,10 @@ module Sources end end - context "The source for a private 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 - + context "The source for a deleted DeviantArt image URL" 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