nomnoms12 / saucenao_api

Wrapper for SauceNAO JSON API
https://pypi.org/project/saucenao-api
GNU General Public License v3.0
64 stars 14 forks source link

No URLs #13

Closed rVnPower closed 3 years ago

rVnPower commented 3 years ago

I got this error when I am trying to find the URL.

Error

Traceback (most recent call last):
  File "ExtDel.py", line 7, in <module>
    print(best.urls[0])
IndexError: list index out of range

Code

from saucenao_api import SauceNao

sauce = SauceNao('18007b616a0808aa80ae9e17e3a8d110e53b081c')
results = sauce.from_url('https://cdn.discordapp.com/attachments/746709460709277707/871381898298019870/228101990_1241039109669568_5485442942218520916_n.png')

best = results[0]
print(best.urls[0])

Other images works just fine.

nomnoms12 commented 3 years ago

@rVnPower Hi!

I made same request. This isn't library bug. SauceNao doesn't return any urls for this request, so urls list is empty. Before printing first url, you must check that it exists. For example:

if best.urls:
    print(best.urls[0])
else:
    print('URL not found')
nomnoms12 commented 3 years ago

This is server full response:

best.raw = {
    'header': {
        'similarity': '95.67',
        'thumbnail': 'https://img3.saucenao.com/ehentai/...',
        'index_id': 38,
        'index_name': 'Index #38: H-Misc (E-Hentai) - da3e4bcf3836a484032d86c35f5072d1f8555045.jpg',
        'dupes': 0,
    },
    'data': {
        'source': 'Rangu',
        'creator': [
            'rangu',
        ],
        'eng_name': '[Pixiv] Rangu (33844486)',
        'jp_name': '[Pixiv] らんぐ (33844486)',
    }
}
nomnoms12 commented 3 years ago

Result on site also doesn't contain urls:

SauceNao site response