#1866: Support deviantart source rewriting
* html work page -> full image * thumbnail -> full image
This commit is contained in:
@@ -2,7 +2,7 @@ module Downloads
|
||||
module Strategies
|
||||
class Base
|
||||
def self.strategies
|
||||
[Pixiv, Twitpic]
|
||||
[Pixiv, Twitpic, DeviantArt]
|
||||
end
|
||||
|
||||
def rewrite(url, headers)
|
||||
|
||||
34
app/logical/downloads/strategies/deviant_art.rb
Normal file
34
app/logical/downloads/strategies/deviant_art.rb
Normal 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
|
||||
Reference in New Issue
Block a user