This commit is contained in:
r888888888
2014-04-25 17:15:09 -07:00
parent ceddf792f1
commit 9e2c664a41
10 changed files with 56 additions and 16 deletions

View File

@@ -7,6 +7,10 @@ module Iqdb
attr_reader :hostname, :port, :socket
def self.default
new(*Danbooru.config.iqdb_hostname_and_port)
end
def initialize(hostname, port)
@hostname = hostname
@port = port
@@ -45,6 +49,15 @@ module Iqdb
end
end
def similar(post_id, results, flags = FLAG_DISCARD_COMMON_COEFFS)
request do
hex_id = post_id.to_s(16)
socket.puts "sim 0 #{flags} #{results} #{hex_id}"
socket.puts "done"
responses = Responses::Collection.new(@socket.read)
end
end
def query(results, filename, flags = FLAG_DISCARD_COMMON_COEFFS)
request do
socket.puts "query 0 #{flags} #{results} #{filename}"