Module: SaucenaoAPI::READ

Defined in:
lib/saucenao.rb

Constant Summary collapse

SITES =
{ 5 => 'http://www.pixiv.net/member_illust.php?mode=medium&illust_id=' }.freeze

Class Method Summary collapse

Class Method Details

.all(saucehash) ⇒ Object


38
39
40
# File 'lib/saucenao.rb', line 38

def all(saucehash)
  saucehash['results'].map { |e| e['data']['pixiv_id'] }
end

.first(saucehash, minsim = 80) ⇒ Object


26
27
28
29
30
31
32
33
34
35
36
# File 'lib/saucenao.rb', line 26

def first(saucehash, minsim = 80)
  id = saucehash['results'][0]['data']['pixiv_id']
  index_id = saucehash['results'][0]['header']['index_id']
  url = SITES[index_id]
  unless index_id.nil?
    results = "#{url}#{id}"
    results = 'no results' if saucehash['results'][0]['header']['similarity'].to_i < minsim
  end
  results = 'no results' if index_id.nil?
  return results
end