jbbandos / calibre-comicvine

Comicvine calibre metadata source for comic-books and Graphic Novels
MIT License
12 stars 1 forks source link

Error 401 Unauthorized #3

Closed cam1170 closed 1 year ago

cam1170 commented 1 year ago

When I try running it with my API key it fails. Any advice?

calibre, version 6.13.0
ERROR: No matches found: <p>Failed to find any books that match your search. Try making the search <b>less specific</b>. For example, use only the author's last name and a single distinctive word from the title.<p>To see the full log, click "Show details".

Running identify query with parameters: 
{'title': 'Star Wars Insider 199', 'authors': None, 'identifiers': {}, 'timeout': 30} 
Using plugins: Comicvine (0, 14, 1) 
The log from individual plugins is below 

****************************** Comicvine (0, 14, 1) ****************************** 
Found 0 results 
Downloading from Comicvine took 1.0651111602783203 
Searching for ['star', 'wars', 'insider'] #199
Looking up volume: star AND wars AND insider AND 199
Looking up volume: star AND wars AND insider AND 199
Plugin Comicvine failed
Traceback (most recent call last):
  File "calibre\ebooks\metadata\sources\identify.py", line 47, in run
  File "calibre_plugins.comicvine.source", line 164, in identify
  File "calibre_plugins.comicvine.utils", line 220, in find_title
  File "calibre_plugins.comicvine.utils", line 88, in retry_function
  File "calibre_plugins.comicvine.utils", line 145, in find_volumes
  File "calibre_plugins.comicvine.pycomicvine.__init__", line 516, in search
  File "calibre_plugins.comicvine.pycomicvine.__init__", line 982, in __init__
  File "calibre_plugins.comicvine.pycomicvine.__init__", line 385, in __init__
  File "calibre_plugins.comicvine.pycomicvine.__init__", line 372, in _request_object
  File "calibre_plugins.comicvine.pycomicvine.__init__", line 202, in _request
  File "urllib\request.py", line 216, in urlopen
  File "urllib\request.py", line 525, in open
  File "urllib\request.py", line 634, in http_response
  File "urllib\request.py", line 557, in error
  File "urllib\request.py", line 496, in _call_chain
  File "urllib\request.py", line 749, in http_error_302
  File "urllib\request.py", line 525, in open
  File "urllib\request.py", line 634, in http_response
  File "urllib\request.py", line 563, in error
  File "urllib\request.py", line 496, in _call_chain
  File "urllib\request.py", line 643, in http_error_default
urllib.error.HTTPError: HTTP Error 401: Unauthorized 

******************************************************************************** 
The identify phase took 1.22 seconds 
The longest time (1.065111) was taken by: Comicvine 
Merging results from different sources 
We have 0 merged results, merging took: 0.00 seconds 
jbbandos commented 1 year ago

I'm sorry for only coming back to this now, but I am unable to reproduce this. I've tried a few times in the last few months, but it never fails with 401

cam1170 commented 1 year ago

Okay I tried it again, with the same result. Steps to reproduce: install the plugin, put my API key in the source configuration menu (worker_threads=3, API Requests per second=1, Maximum # of volumes returned=2), edit book, Download metadata with comicvine being the only source.

calibre, version 6.28.0 ERROR: No matches found:

Failed to find any books that match your search. Try making the search less specific. For example, use only the author's last name and a single distinctive word from the title.

To see the full log, click "Show details".

Running identify query with parameters: {'title': 'Star Wars: Rebels', 'authors': None, 'identifiers': {}, 'timeout': 30} Using plugins: Comicvine (0, 14, 1) The log from individual plugins is below

** Comicvine (0, 14, 1) ** Found 0 results Downloading from Comicvine took 0.998483419418335 Searching for ['star', 'wars:', 'rebels'] #None Looking up volume: star AND wars: AND rebels AND None Looking up volume: star AND wars: AND rebels AND None Plugin Comicvine failed Traceback (most recent call last): File "calibre\ebooks\metadata\sources\identify.py", line 47, in run File "calibre_plugins.comicvine.source", line 164, in identify File "calibre_plugins.comicvine.utils", line 220, in find_title File "calibre_plugins.comicvine.utils", line 88, in retry_function File "calibre_plugins.comicvine.utils", line 145, in find_volumes File "calibre_plugins.comicvine.pycomicvine.init", line 516, in search File "calibre_plugins.comicvine.pycomicvine.init", line 982, in init File "calibre_plugins.comicvine.pycomicvine.init", line 385, in init File "calibre_plugins.comicvine.pycomicvine.init", line 372, in _request_object File "calibre_plugins.comicvine.pycomicvine.init", line 202, in _request File "urllib\request.py", line 216, in urlopen File "urllib\request.py", line 525, in open File "urllib\request.py", line 634, in http_response File "urllib\request.py", line 557, in error File "urllib\request.py", line 496, in _call_chain File "urllib\request.py", line 749, in http_error_302 File "urllib\request.py", line 525, in open File "urllib\request.py", line 634, in http_response File "urllib\request.py", line 563, in error File "urllib\request.py", line 496, in _call_chain File "urllib\request.py", line 643, in http_error_default urllib.error.HTTPError: HTTP Error 401: Unauthorized


The identify phase took 1.02 seconds The longest time (0.998483) was taken by: Comicvine Merging results from different sources We have 0 merged results, merging took: 0.00 seconds

cam1170 commented 1 year ago

The same error occurs with a dummy API key, and when I use the plugin with calibre-debug.

cam1170 commented 1 year ago

I fixed it! I opened comicvine.json and there was a space at the end of my API key, deleting that fixed it. Maybe there was an issue with copying it from the website. If you want to avoid this in the future, maybe allow for a space at the end.

jbbandos commented 1 year ago

I fixed it! I opened comicvine.json and there was a space at the end of my API key, deleting that fixed it. Maybe there was an issue with copying it from the website. If you want to avoid this in the future, maybe allow for a space at the end.

Thank you! I was really scratching my head here as I couldn't reproduce the issue. Since API keys don't have spaces, I'll see if I can trim the input string to remove spaces from both ends. Good catch!

jbbandos commented 1 year ago

Added a trim to the input, now the API key will have extraneous whitespace removed.