Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

odmpy libby download issue #54

Closed
joshuatly opened this issue Sep 14, 2023 · 2 comments
Closed

odmpy libby download issue #54

joshuatly opened this issue Sep 14, 2023 · 2 comments

Comments

@joshuatly
Copy link

joshuatly commented Sep 14, 2023

Describe the problem
Sometimes I will have the following error on download:

Some personal data redacted.
I think this might have to do with when the book is close to return, odmpy is still trying to download a book which might had been returned?

Also when this happen, this will fail completely. Is there a way to not fail completely, instead will continue to download the next title instead? Thanks

An unexpected error has occurred
Traceback (most recent call last):
  File "/home/joshua/.local/lib/python3.9/site-packages/odmpy/libby.py", line 358, in make_request
    res.raise_for_status()
  File "/home/joshua/.local/lib/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://sentry-read.svc.overdrive.com/open/book/card/1234/title/1234

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/joshua/.local/lib/python3.9/site-packages/odmpy/odm.py", line 952, in run
    extract_bundled_contents(
  File "/home/joshua/.local/lib/python3.9/site-packages/odmpy/odm.py", line 327, in extract_bundled_contents
    extract_loan_file(libby_client, bundled_media, args)
  File "/home/joshua/.local/lib/python3.9/site-packages/odmpy/odm.py", line 375, in extract_loan_file
    _, openbook, rosters = libby_client.process_ebook(selected_loan)
  File "/home/joshua/.local/lib/python3.9/site-packages/odmpy/libby.py", line 822, in process_ebook
    download_base, meta = self.prepare_loan(loan)
  File "/home/joshua/.local/lib/python3.9/site-packages/odmpy/libby.py", line 786, in prepare_loan
    meta = self.open_loan(loan_type, card_id, title_id)
  File "/home/joshua/.local/lib/python3.9/site-packages/odmpy/libby.py", line 767, in open_loan
    res: Dict = self.make_request(
  File "/home/joshua/.local/lib/python3.9/site-packages/odmpy/libby.py", line 367, in make_request
    ErrorHandler.process(http_err)
  File "/home/joshua/.local/lib/python3.9/site-packages/odmpy/libby_errors.py", line 103, in process
    raise ClientError(
odmpy.libby_errors.ClientError: <odmpy.libby_errors.ClientError; http_status=404, msg='404 Client Error: Not Found for url: https://sentry-read.svc.overdrive.com/open/book/card/64855467/title/984832', error_response='{"result":"upstream_failure","upstream":{"errorCode":"PatronDoesNotHaveTitleCheckedOut","service":"THUNDER","httpStatus":404,"userExplanation":"Patron does not have title checked out.","correlationId":"d37redactede"}}''>
Traceback (most recent call last):
  File "/home/joshua/.local/lib/python3.9/site-packages/odmpy/libby.py", line 358, in make_request
    res.raise_for_status()
  File "/home/joshua/.local/lib/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://sentry-read.svc.overdrive.com/open/book/card/1234/title/1234

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/joshua/.local/bin/odmpy", line 8, in <module>
    sys.exit(main())
  File "/home/joshua/.local/lib/python3.9/site-packages/odmpy/__main__.py", line 27, in main
    run()
  File "/home/joshua/.local/lib/python3.9/site-packages/odmpy/odm.py", line 952, in run
    extract_bundled_contents(
  File "/home/joshua/.local/lib/python3.9/site-packages/odmpy/odm.py", line 327, in extract_bundled_contents
    extract_loan_file(libby_client, bundled_media, args)
  File "/home/joshua/.local/lib/python3.9/site-packages/odmpy/odm.py", line 375, in extract_loan_file
    _, openbook, rosters = libby_client.process_ebook(selected_loan)
  File "/home/joshua/.local/lib/python3.9/site-packages/odmpy/libby.py", line 822, in process_ebook
    download_base, meta = self.prepare_loan(loan)
  File "/home/joshua/.local/lib/python3.9/site-packages/odmpy/libby.py", line 786, in prepare_loan
    meta = self.open_loan(loan_type, card_id, title_id)
  File "/home/joshua/.local/lib/python3.9/site-packages/odmpy/libby.py", line 767, in open_loan
    res: Dict = self.make_request(
  File "/home/joshua/.local/lib/python3.9/site-packages/odmpy/libby.py", line 367, in make_request
    ErrorHandler.process(http_err)
  File "/home/joshua/.local/lib/python3.9/site-packages/odmpy/libby_errors.py", line 103, in process
    raise ClientError(
odmpy.libby_errors.ClientError: <odmpy.libby_errors.ClientError; http_status=404, msg='404 Client Error: Not Found for url: https://sentry-read.svc.overdrive.com/open/book/card/1234/title/1234', error_response='{"result":"upstream_failure","upstream":{"errorCode":"PatronDoesNotHaveTitleCheckedOut","service":"THUNDER","httpStatus":404,"userExplanation":"Patron does not have title checked out.","correlationId":"d37redactede"}}''>

To Reproduce
odmpy libby -c -k -d Folder/ --opf --direct --latest 99 --bookfolderformat "%(Title)s - %(Author)s - %(ID)s" --setting setting_folder/

Version/Environment
odmpy 0.8.0 [Python 3.9.2-linux]

@ping
Copy link
Owner

ping commented Sep 14, 2023

This issue is due to an access error when downloading an audiobook attachment ("bundled content"). In my previous testing, having an audiobook loan granted access to the attachment as well, but it seems like that's not true in your case.

I've modified it so that errors during attachment downloads will not abort the entire command. You can test this by updating from master.

@joshuatly
Copy link
Author

I tested the master branch, and indeed the error does not block the script from downloading books after that. Thank you very much.

@ping ping closed this as completed Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants