* Support rewriting source when user uploads from a thumbnail url or html page url * Fix bug where site did not log in correctly * Fix bug where the image url couldn't be extracted from the page if the image was rated as adults only on seiga * Normalize direct image url to html page url so tags, etc., can be extracted
28 lines
594 B
Ruby
28 lines
594 B
Ruby
module Downloads
|
|
module Strategies
|
|
class Base
|
|
def self.strategies
|
|
[Pixiv, NicoSeiga, Twitpic, DeviantArt, Tumblr]
|
|
end
|
|
|
|
def rewrite(url, headers)
|
|
return [url, headers]
|
|
end
|
|
|
|
protected
|
|
def http_exists?(url, headers)
|
|
exists = false
|
|
uri = URI.parse(url)
|
|
Net::HTTP.start(uri.host, uri.port) do |http|
|
|
http.request_head(uri.request_uri, headers) do |res|
|
|
if res.is_a?(Net::HTTPSuccess)
|
|
exists = true
|
|
end
|
|
end
|
|
end
|
|
exists
|
|
end
|
|
end
|
|
end
|
|
end
|