From 9ac5ef8f59e52c6bc11700f5919ca4190c54dd76 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Sun, 12 Mar 2023 13:31:28 -0400 Subject: [PATCH] Fix metadata scrapper for books --- vrobbler/apps/books/models.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vrobbler/apps/books/models.py b/vrobbler/apps/books/models.py index a572046..cc13974 100644 --- a/vrobbler/apps/books/models.py +++ b/vrobbler/apps/books/models.py @@ -91,15 +91,18 @@ class Book(LongPlayScrobblableMixin): def fix_metadata(self, force_update=False): if not self.openlibrary_id or force_update: book_dict = lookup_book_from_openlibrary(self.title, self.author) + if not book_dict: + logger.warn(f"Book not found in OL {self.title}") + return cover_url = book_dict.pop("cover_url", "") ol_author_id = book_dict.pop("ol_author_id", "") ol_author_name = book_dict.pop("ol_author_name", "") - # Don't want to overwrite KoReader's pages if OL is ignorant - if not book_dict.get("pages"): + if book_dict.get("pages") == None: book_dict.pop("pages") ol_title = book_dict.get("title") + if ol_title.lower() != self.title.lower(): logger.warn( f"OL and KoReader disagree on this book title {self.title} != {ol_title}"