From 807c3dd5f4bf2609281a6b12a2892c97fbc26cbe Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 2 Sep 2018 14:49:58 -0500 Subject: [PATCH] deviantart: remove obsolete image sample rewrite rules. Remove rewrite rules for these types of sample urls: * http://th00.deviantart.net/fs71/PRE/f/2014/065/3/b/goruto_by_xyelkiltrox-d797tit.png * http://th04.deviantart.net/fs70/300W/f/2009/364/4/d/Alphes_Mimic___Rika_by_Juriesute.png These URLs aren't served to users any more, and just stripping out "PRE" or "200H" isn't sufficient to get the full size image. In general, an api call is required to find the full size image url. --- app/logical/sources/strategies/deviant_art.rb | 11 ----------- test/unit/sources/deviantart_test.rb | 7 +++++++ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app/logical/sources/strategies/deviant_art.rb b/app/logical/sources/strategies/deviant_art.rb index 11fa8a5c3..060bc8a6f 100644 --- a/app/logical/sources/strategies/deviant_art.rb +++ b/app/logical/sources/strategies/deviant_art.rb @@ -18,17 +18,6 @@ module Sources end def image_urls - # normalize thumbnails - if url =~ %r{^(https?://(?:fc|th)\d{2}\.deviantart\.net/.+?/)200H/} - match = $1 - return [url.sub(match + "200H/", match)] - end - - if url =~ %r{^(https?://(?:fc|th)\d{2}\.deviantart\.net/.+?/)PRE/} - match = $1 - return [url.sub(match + "PRE/", match)] - end - # return direct links if url =~ ATTRIBUTED_ASSET || url =~ ASSET return [url] diff --git a/test/unit/sources/deviantart_test.rb b/test/unit/sources/deviantart_test.rb index 538495f87..c54e72f3d 100644 --- a/test/unit/sources/deviantart_test.rb +++ b/test/unit/sources/deviantart_test.rb @@ -56,6 +56,13 @@ module Sources end end + context "The source for a th00.deviantart.net/*/PRE/* thumbnail url" do + should "return the full size image url" do + @site = Sources::Strategies.find("http://th00.deviantart.net/fs71/PRE/f/2014/065/3/b/goruto_by_xyelkiltrox-d797tit.png") + assert_equal("http://origin-orig.deviantart.net/0f1e/f/2014/065/3/b/goruto_by_xyelkiltrox-d797tit.png", @site.image_url) + end + end + context "The source for an DeviantArt artwork page" do setup do @site = Sources::Strategies.find("http://noizave.deviantart.com/art/test-post-please-ignore-685436408")