fix it better
This commit is contained in:
parent
217ae78374
commit
d47f57850e
|
@ -63,6 +63,7 @@ module YiffRest
|
|||
|
||||
def query_iqdb
|
||||
@sp = search_iqdb_params
|
||||
@sp[:image_id] ||= @sp[:md5]
|
||||
@sc = (@sp[:score_cutoff].presence || 60).to_i
|
||||
if @sp[:file].present?
|
||||
@results = Iqdb.query_file(@sp[:file], @sc)
|
||||
|
@ -92,7 +93,7 @@ module YiffRest
|
|||
end
|
||||
|
||||
def search_iqdb_params
|
||||
permit_search_params(%i[file url image_id score_cutoff])
|
||||
permit_search_params(%i[file url image_id md5 score_cutoff])
|
||||
end
|
||||
|
||||
def create_params
|
||||
|
|
|
@ -54,13 +54,13 @@ module Iqdb
|
|||
end
|
||||
|
||||
def query_file(file, score_cutoff)
|
||||
Tempfile.open("yiffy2-#{file.md5}") do |tempfile|
|
||||
Tempfile.open("yiffy2-queryfile") do |tempfile|
|
||||
file.binmode
|
||||
tempfile.binmode
|
||||
tempfile.write(file.read)
|
||||
tempfile.rewind
|
||||
thumb = generate_thumbnail(tempfile.path)
|
||||
raise(Error, "failed to generate thumb for #{file.md5}") unless thumb
|
||||
raise(Error, "failed to generate thumb for file") unless thumb
|
||||
|
||||
response = make_request("/query", :post, get_channels_data(thumb))
|
||||
raise(Error, "iqdb request failed") if response.status != 200
|
||||
|
|
Loading…
Reference in New Issue
Block a user