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

Fix parsing datetimes with timezone not specified #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

spicefather
Copy link

Some books include datetimes in their metadata without a timezone specified, causing the plugin to fail to download them with the following log:

Traceback (most recent call last):
  File "calibre\gui2\threaded_jobs.py", line 82, in start_work
  File "calibre_plugins.overdrive_libby.ebook_download", line 59, in __call__
  File "calibre_plugins.overdrive_libby.download", line 253, in add
  File "calibre_plugins.overdrive_libby.download", line 97, in update_metadata
  File "calibre_plugins.overdrive_libby.libby.client", line 337, in parse_datetime
ValueError: time data '2009-10-13T00:00:00' does not match known formats ('%Y-%m-%dT%H:%M:%SZ', '%Y-%m-%dT%H:%M:%S.%fZ', '%Y-%m-%dT%H:%M:%S%z', '%Y-%m-%dT%H:%M:%S.%f%z', '%m/%d/%Y')

This change allows parsing these datetimes as though they are UTC.

@p1nkyy
Copy link

p1nkyy commented Feb 6, 2024

Hi, I need this fix, can you kindly show me how I can implement this in my plugin or how do I download your version? Thanks so much before.

@spicefather
Copy link
Author

Hi, I need this fix, can you kindly show me how I can implement this in my plugin or how do I download your version? Thanks so much before.

The "plugin" is just a zip file containing the contents of the repo's calibre-plugin folder. Just download my repo and zip that folder up into OverDrive Libby.zip. Put that into your Calibre plugins folder -- for me, %APPDATA%\Calibre\plugins -- and overwrite the old version.

@p1nkyy
Copy link

p1nkyy commented Feb 6, 2024

Got this error message:

calibre, version 7.4.0
ERROR: Unhandled exception: <b>InvalidPlugin</b>:The plugin in 'D:\\Documents\\libby-calibre-plugin-main.zip' is invalid. It does not contain a top-level __init__.py file

calibre 7.4  embedded-python: True
Windows-10-10.0.19045-SP0 Windows ('64bit', 'WindowsPE')
('Windows', '10', '10.0.19045')
Python 3.11.5
Windows: ('10', '10.0.19045', 'SP0', 'Multiprocessor Free')
Interface language: None
Successfully initialized third party plugins: ACSM Input (0, 1, 0) && DeDRM (10, 0, 3) && ACSM Input Plugin GUI Extension (0, 1, 0) && Find Duplicates (1, 10, 8) && KindleUnpack - The Plugin (0, 83, 1) && Modify ePub (1, 8, 2) && OverDrive Libby (0, 1, 9)
Traceback (most recent call last):
  File "calibre\gui2\preferences\plugins.py", line 325, in add_plugin
  File "calibre\customize\ui.py", line 513, in add_plugin
  File "calibre\customize\ui.py", line 64, in load_plugin
  File "calibre\customize\zipplugin.py", line 299, in load
  File "calibre\customize\zipplugin.py", line 394, in _locate_code
calibre.customize.InvalidPlugin: The plugin in 'D:\\Documents\\libby-calibre-plugin-main.zip' is invalid. It does not contain a top-level __init__.py file

@spicefather
Copy link
Author

Seems like you might be using the repo zip directly, you do need to unzip that and re-zip it as noted in my comment above. Once unzipped, go into the calibre-plugin folder, select everything, and create zip (7-zip or Windows' "Send to > Compressed folder" should both be fine).

@p1nkyy
Copy link

p1nkyy commented Feb 6, 2024

Seems like you might be using the repo zip directly, you do need to unzip that and re-zip it as noted in my comment above. Once unzipped, go into the calibre-plugin folder, select everything, and create zip (7-zip or Windows' "Send to > Compressed folder" should both be fine).

Thanks finally managed to make it work. Hopefully @ping would come by soon and implement the fix.

Copy link

@davdittrich davdittrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes fix the reported issue.

sgmoore added a commit to sgmoore/libby-calibre-plugin that referenced this pull request Sep 9, 2024
sgmoore added a commit to sgmoore/libby-calibre-plugin that referenced this pull request Sep 11, 2024
This is an unofficial release.

Changes:

- Fix: Uses libbyapp.com domain rather than svc.overdrive.com which fixes ping#33
- Fix: Applied spicefather's fix for date time formats (see ping#17)

Also includes unreleased changes by ping including the following

- New: Rename a card
- Fix: Use a regex validator instead of input mask for Libby setup code due to wonkiness, ref ping#14
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

Successfully merging this pull request may close these issues.

3 participants