forked from e621ng/e621ng
[IQDB] Remove dead code
This commit is contained in:
parent
389bc04c7e
commit
bdeb4b3501
1
.env
1
.env
@ -78,7 +78,6 @@
|
||||
# export DANBOORU_AWS_ACCESS_KEY_ID=
|
||||
# export DANBOORU_AWS_SECRET_ACCESS_KEY=
|
||||
# export DANBOORU_AWS_SQS_REGION=
|
||||
# export DANBOORU_IQDBS_AUTH_KEY=
|
||||
# export DANBOORU_IQDBS_SERVER=
|
||||
# export DANBOORU_CLOUDFLARE_KEY=
|
||||
# export DANBOORU_CLOUDFLARE_EMAIL=
|
||||
|
@ -1,47 +0,0 @@
|
||||
module Iqdb
|
||||
class Download
|
||||
class Error < StandardError; end
|
||||
|
||||
def self.enabled?
|
||||
Danbooru.config.iqdbs_server.present? && Danbooru.config.iqdbs_auth_key.present?
|
||||
end
|
||||
|
||||
def self.get_referer(url)
|
||||
headers = {}
|
||||
datums = {}
|
||||
|
||||
strategy = Sources::Strategies.find(url)
|
||||
|
||||
[strategy.image_url, strategy.headers["Referer"]]
|
||||
end
|
||||
|
||||
def self.find_similar(source)
|
||||
raise NotImplementedError, "the IQDBs service isn't configured. Similarity searches are not available." unless enabled?
|
||||
|
||||
url, ref = get_referer(source)
|
||||
params = {
|
||||
"key" => Danbooru.config.iqdbs_auth_key,
|
||||
"url" => url,
|
||||
"ref" => ref
|
||||
}
|
||||
uri = URI.parse("#{Danbooru.config.iqdbs_server}/similar")
|
||||
uri.query = URI.encode_www_form(params)
|
||||
|
||||
resp = HTTParty.get(uri, Danbooru.config.httparty_options)
|
||||
raise "HTTP error code: #{resp.code} #{resp.message}" unless resp.success?
|
||||
|
||||
json = JSON.parse(resp.body)
|
||||
raise "IQDB error: #{json["error"]}" unless json.is_a?(Array)
|
||||
|
||||
post_ids = json.map { |match| match["post_id"] }
|
||||
posts = Post.find(post_ids)
|
||||
|
||||
json.map do |match|
|
||||
post = posts.find { |post| post.id == match["post_id"] }
|
||||
match.with_indifferent_access.merge({ post: post })
|
||||
end
|
||||
rescue => e
|
||||
raise Error, { message: e.message, iqdb_response: json }
|
||||
end
|
||||
end
|
||||
end
|
@ -118,13 +118,6 @@ fart'
|
||||
true
|
||||
end
|
||||
|
||||
# What method to use to store images.
|
||||
# local_flat: Store every image in one directory.
|
||||
# local_hierarchy: Store every image in a hierarchical directory, based on the post's MD5 hash. On some file systems this may be faster.
|
||||
def image_store
|
||||
:local_flat
|
||||
end
|
||||
|
||||
# This allows using statically linked copies of ffmpeg in non default locations. Not universally supported across
|
||||
# the codebase at this time.
|
||||
def ffmpeg_path
|
||||
@ -867,10 +860,6 @@ fart'
|
||||
false
|
||||
end
|
||||
|
||||
# iqdbs options - see https://github.com/r888888888/iqdbs
|
||||
def iqdbs_auth_key
|
||||
end
|
||||
|
||||
def iqdbs_server
|
||||
end
|
||||
|
||||
|
@ -18,7 +18,6 @@ module IqdbTestHelper
|
||||
Post.stubs(:iqdb_sqs_service).returns(service)
|
||||
Post.stubs(:iqdb_enabled?).returns(true)
|
||||
|
||||
Danbooru.config.stubs(:iqdbs_auth_key).returns("hunter2")
|
||||
Danbooru.config.stubs(:iqdbs_server).returns("http://localhost:3004")
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user