[IQDB] Remove dead code

This commit is contained in:
Earlopain 2021-10-02 21:15:48 +02:00
parent 389bc04c7e
commit bdeb4b3501
No known key found for this signature in database
GPG Key ID: 6CFB948E15246897
4 changed files with 0 additions and 60 deletions

1
.env
View File

@ -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=

View File

@ -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

View File

@ -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

View File

@ -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