Files
danbooru/app/logical/downloads/strategies/base.rb
Toks 0507064004 #1866: Add nico seiga support and fix various seiga bugs
* 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
2014-04-29 11:46:08 -04:00

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