Skip to content

Commit

Permalink
Handle error when downloading bundled content (audiobook attachments)…
Browse files Browse the repository at this point in the history
…, ref #54
  • Loading branch information
ping committed Sep 14, 2023
1 parent 1650ca7 commit deef5e0
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions odmpy/odm.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,18 @@ def extract_bundled_contents(
)
if not libby_client.is_downloadable_ebook_loan(bundled_media):
continue
# patch in cardId from parent loan details
bundled_media["cardId"] = selected_loan["cardId"]
extract_loan_file(libby_client, bundled_media, args)
try:
# patch in cardId from parent loan details
bundled_media["cardId"] = selected_loan["cardId"]
extract_loan_file(libby_client, bundled_media, args)
except ClientError:
# Oddly having a valid loan to the audiobook does not always mean
# having access to the bundled content? Ref https://github.com/ping/odmpy/issues/54
# Let this fail without affecting the main download since it's not critical
logger.exception(
'Unable to download bundled content for "%s"',
bundled_media.get("title", ""),
)


def extract_loan_file(
Expand Down Expand Up @@ -1206,7 +1215,11 @@ def run(custom_args: Optional[List[str]] = None, be_quiet: bool = False) -> None
cleanup_odm_license=not args.keepodm,
)
extract_bundled_contents(
libby_client, overdrive_client, selected_loan, cards, args
libby_client,
overdrive_client,
selected_loan,
cards,
args,
)
continue
elif libby_client.is_downloadable_ebook_loan(
Expand Down

0 comments on commit deef5e0

Please sign in to comment.