mkb79 / audible-cli

A command line interface for audible package. With the cli you can download your Audible books, cover, chapter files.
GNU Affero General Public License v3.0
423 stars 45 forks source link

The download command should only process downloadable items #160

Closed lchiocca closed 9 months ago

lchiocca commented 9 months ago

Audible has these weird promotions where you can add a audiobook for free to your libary but after an unknown period of time you no longer have access to it. It is still in the libary but "locked" (you actually see a lock icon on the offical audible app). I've changed the code locally to check if the item is downloadable and that works like a charm. Here the condensed version of the change in the cmd_download.cli() method:

for job in jobs:
  [...]
  for item in items:
    if item.is_downloadable(): # added this
      queue_job(...)
    else:
      logger.error(f"Skip title {item.title}: This library item cannot be downloaded")
mkb79 commented 9 months ago

@lchiocca Thank you for opening this issue.

What error was displayed before changing your code when you downloaded the title?

When downloading a title in aax format, item.is_downloadable is called. For aaxc titles audible-cli makes a license request and check, if the license was denied and will you shown this error.

Implementing your code has the disadvantage, that downloading cover, chapter and annotations will skipped also (although they are possible). So I would suggest to refactor the method audible_cli.models.LibraryItem.get_license to check for item.is_downloadable before requesting the license. This would speed up the running time in such cases a little bit.

lchiocca commented 9 months ago

I'm using audible-cli to make a backup of the items in my libary. I didn't have a clear instinct on which format to download so I chose aaxc. The error i was getting was error: {item.title} is not downloadable.. All in all, correct. The problem I was facing is that I had multiple non-downloadable items and at some point the queue stopped working and hence never terminated. I'm not 100% sure, but I think three exceptions will "halt" the queue. That's where I started to investigate the issue and wanted to branch off as quickly as possible as to not even get into that situation. Using the --ignore-errors allows it to continue, though.

Anyways, I see your points and agree on all of them. As mentioned, I modified the download command locally to do some other stuff (e.g. take only the best cover, customizable output location, decrypting the aaxc using ffmpeg and finally creating a portable, smaller opus file). I'll close this issue since the root cause isn't what I described.

mkb79 commented 9 months ago

I think I know why the queue is not terminated correctly when an error occurs and --ignore-errors is not provided. I'll check this out.