#1866: Support deviantart source rewriting

* html work page -> full image
* thumbnail -> full image
This commit is contained in:
Toks
2013-11-26 16:44:29 -05:00
parent 100f3a666b
commit 6fbd373873
7 changed files with 12452 additions and 2 deletions

View File

@@ -2,7 +2,7 @@ module Downloads
module Strategies
class Base
def self.strategies
[Pixiv, Twitpic]
[Pixiv, Twitpic, DeviantArt]
end
def rewrite(url, headers)

View File

@@ -0,0 +1,34 @@
module Downloads
module Strategies
class DeviantArt < Base
def rewrite(url, headers)
if url =~ /https?:\/\/(?:\w+\.)?deviantart\.(?:com|net)/
url, headers = rewrite_html_pages(url, headers)
url, headers = rewrite_thumbnails(url, headers)
end
return [url, headers]
end
protected
def rewrite_html_pages(url, headers)
if url =~ %r{^http://\w+\.deviantart\.com/art/\w+}
source = ::Sources::Strategies::DeviantArt.new(url)
source.get
return [source.image_url, headers]
else
return [url, headers]
end
end
def rewrite_thumbnails(url, headers)
if url =~ %r{^(http://\w+.deviantart.net/\w+/)200H/}
match = $1
url.sub!(match + "200H/", match)
end
return [url, headers]
end
end
end
end