From d4008a5ddc1d667a50bd0bfe6c830d1f1f7d9083 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Mon, 9 Oct 2017 16:32:05 -0700 Subject: [PATCH] fixes #3327 --- app/logical/sources/strategies/deviant_art.rb | 5 +++++ test/unit/sources/deviantart_test.rb | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/app/logical/sources/strategies/deviant_art.rb b/app/logical/sources/strategies/deviant_art.rb index 4f0f8ea1b..e7b54dd2d 100644 --- a/app/logical/sources/strategies/deviant_art.rb +++ b/app/logical/sources/strategies/deviant_art.rb @@ -33,6 +33,11 @@ module Sources @artist_commentary_title = get_artist_commentary_title_from_page(page) @artist_commentary_desc = get_artist_commentary_desc_from_page(page) end + rescue Mechanize::ResponseCodeError + # try the normal url + if url =~ /\.(jpg|jpeg|png|gif)/ + @image_url = url + end end def self.to_dtext(text) diff --git a/test/unit/sources/deviantart_test.rb b/test/unit/sources/deviantart_test.rb index 95b7640c3..75d040613 100644 --- a/test/unit/sources/deviantart_test.rb +++ b/test/unit/sources/deviantart_test.rb @@ -2,6 +2,17 @@ require 'test_helper' module Sources class DeviantArtTest < ActiveSupport::TestCase + context "The source for a private DeviantArt image URL" do + setup do + @site = Sources::Site.new("https://pre00.deviantart.net/423b/th/pre/i/2017/281/e/0/mindflayer_girl01_by_nickbeja-dbpxdt8.png") + @site.get + end + + 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) + end + end + context "The source for an DeviantArt artwork page" do setup do @site = Sources::Site.new("http://noizave.deviantart.com/art/test-post-please-ignore-685436408")