kiwidude68 / calibre_plugins

All kiwidude's plugins for calibre
GNU General Public License v3.0
199 stars 33 forks source link

Goodreads Sync parse error #93

Open ahegel opened 2 hours ago

ahegel commented 2 hours ago

I have seen this error on 2 books when clicking the book and selecting "Link to Goodreads". I don't see anything distinctive about those 2 books that sets them apart from the hundreds I also linked that worked fine.

calibre, version 7.18.0
ERROR: Unhandled exception: <b>ParseError</b>:syntax error: line 1, column 0

calibre 7.18  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
EXE path: C:\Program Files\Calibre2\calibre.exe
Successfully initialized third party plugins: Goodreads (1, 8, 2) && Goodreads Sync (1, 16, 8)
Traceback (most recent call last):
  File "calibre_plugins.goodreads_sync.action", line 436, in search_goodreads_to_link_book
  File "calibre_plugins.goodreads_sync.action", line 460, in search_to_link_books
  File "calibre_plugins.goodreads_sync.core", line 530, in get_goodreads_book_for_id
  File "calibre_plugins.goodreads_sync.core", line 179, in _request_get
  File "calibre_plugins.goodreads_sync.core", line 195, in _handle_failure
  File "xml\etree\ElementTree.py", line 1338, in XML
xml.etree.ElementTree.ParseError: syntax error: line 1, column 0
kiwidude68 commented 2 hours ago

Hi - can you please provide more details of the specific book you were after. Normally that sort of error can happen when the Goodreads website is having a "moment", but it is possible there is some edge case the plugin isn't handling if I can replicate it. For that I need the exact book details of the title and author, if it already has a goodreads id value as an identifier then tell me that value too...

ahegel commented 1 hour ago

Book 1

Book 2

kiwidude68 commented 56 minutes ago

Both of those are working perfectly fine for me - the dialog appears with a list of options, I select one and job done. Was the dialog not appearing when you tried before? Have you tried again since then? This really looks like a Goodreads connectivity issue on your side.

ahegel commented 49 minutes ago

Thank you for checking! I've been linking hundreds of books in the last few hours and these are the only ones that have given me trouble, and the error has been consistent as I've tried and retried them, so I don't think it's an issue with my Goodreads connectivity. I just found 2 more I've listed below. Either way, I feel that the error should be handled. It's inconvenient to bulk-link 20 books, select the correct match for 19 of them, then hit the error on the 20th book and lose all the links I've been making in that bulk action and have to re-do them all.

Book 3:

Book 4:

ETA: The error appears as soon as I hit "Link to Goodreads" - the dialog never appears.

kiwidude68 commented 41 minutes ago

Ok, I just managed to replicate with the first of your books above. The key difference being with those ones you mention an ISBN value. I assume the problem is that the ISBN doesn't match anything in Goodreads. To get going in the meantime just remove that ISBN from the IDs field on those books you are having the issue with until I get a moment to check what the actual response from Goodreads is and how to handle it more gracefully.

You didnt mention an ISBN on the previous two books, however your error stack you put in the first post shows that it also was in the code path where the book has an ISBN so it attempts to match based on that first (before falling back to title/author). Not sure if you just overlooked that or whatever...

ahegel commented 35 minutes ago

You're right, there is an ISBN for both of the first books I linked but I gave you the URL that Calibre creates under the Ids field for them instead of the actual ISBN, sorry about that! Thank you for the workaround, that makes sense and will address my issue for now.

kiwidude68 commented 1 minute ago

Aha - I thought that would be the case.

It is actually succeeding in finding a match for that ISBN but then failing to retrieve the book data for it. The plugin bug is that it is getting a 404 error but the plugin is expecting something else and falling over.

What is strange is if I put the same url that it is failing to retrieve from into a web browser it works, yet it is consistently failing when called from the plugin. On the two books you gave me the ISBN for there is a big warning at the top of the Goodreads page for the corresponding book, you can see an example here: https://www.goodreads.com/book/show/2287744.The_McKinsey_Mind

So it seems they are ISBN values that Goodreads doesn't like - at least for that book they have other editions without the warning message.

The plugin fix I will publish shortly, but you have the workaround now you know, thanks for reporting the issue.