Neurrone / beets-audible

Organize Your Audiobook Collection With Beets
MIT License
110 stars 19 forks source link

Requests to audnex API returning 504 error (in command 'beet import <path>') #32

Closed trustosas closed 4 days ago

trustosas commented 2 years ago

This issue has been talked about here. Basically my attempts to tag books with audnex API are not working. Anyone else facing this challenge?

More details on the command and result:

!beet import "/content/Animal Farm"

/usr/local/lib/python3.7/dist-packages/beets/mediafile.py:19: UserWarning: beets.mediafile is deprecated; use mediafile instead
  warnings.warn("beets.mediafile is deprecated; use mediafile instead")
Error: MusicBrainz not reachable in release search with query {'release': 'animal farm', 'artist': 'george orwell', 'tracks': '1'}
Error while requesting https://api.audnex.us/books/B002V5H6F4/chapters, attempt 1/3: status code 504, Gateway Timeout
Error while requesting https://api.audnex.us/books/B002V5H6F4/chapters, attempt 2/3: status code 504, Gateway Timeout
Error while requesting https://api.audnex.us/books/B002V5H6F4/chapters, attempt 3/3: status code 504, Gateway Timeout
audible: Error while fetching book information from Audnex
Traceback (most recent call last):
  File "/content/beets-audible/audible.py", line 291, in get_albums
    return [self.get_album_info(p["asin"]) for p in products_without_unreleased_entries]
  File "/content/beets-audible/audible.py", line 291, in <listcomp>
    return [self.get_album_info(p["asin"]) for p in products_without_unreleased_entries]
  File "/content/beets-audible/audible.py", line 300, in get_album_info
    (book, chapters) = get_book_info(asin)
  File "/content/beets-audible/api.py", line 36, in get_book_info
    chapter_response = json.loads(make_request(f"{AUDNEX_ENDPOINT}/books/{asin}/chapters"))
  File "/content/beets-audible/api.py", line 61, in make_request
    raise e
  File "/content/beets-audible/api.py", line 53, in make_request
    with request.urlopen(req) as response:
  File "/usr/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.7/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.7/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 504: Gateway Timeout

/content/Animal Farm (1 items)
No matching release found for 1 tracks.
For help, see: https://beets.readthedocs.org/en/latest/faq.html#nomatch
[S]kip, Use as-is, as Tracks, Group albums, Enter search, enter Id, aBort,
eDit? 
VeteraNovis commented 2 years ago

I don't know what's happening with the chapter searching on Audnexus, but it's always returning a 504 error. The API documentation seems to match the call being made, but I can't see why it doesn't respond blank if no chapters are detected.

I've also disabled chapter matching in my config file, and it Beets doesn't seem to be respecting that setting.

Regardless, your issue appears to be an uncaught error due to the API not responding when being asked for chapter information.

The ASIN of your book is correct though, and so I'm unsure as to why there is no match at all.

djdembeck commented 2 years ago

The HTTPError needs to be caught and handled properly. Chapters are arguably non-essential, so I think it should warn and show a match for the release.

Neurrone commented 4 days ago

Closing this to clean up old issues. Let me know if this is still relevant.