From 2cdd281e98509d5e38134e330a45d50c085bbb55 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 31 Oct 2020 10:50:00 -0700 Subject: [PATCH] Prevent error on serializing book cover --- bookwyrm/models/book.py | 2 ++ bookwyrm/models/import_job.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bookwyrm/models/book.py b/bookwyrm/models/book.py index 0920a931..b993ef5e 100644 --- a/bookwyrm/models/book.py +++ b/bookwyrm/models/book.py @@ -61,6 +61,8 @@ class Book(ActivitypubMixin, BookWyrmModel): @property def ap_cover(self): ''' an image attachment ''' + if not self.cover or not hasattr(self.cover, 'url'): + return [] return [activitypub.Image( url='https://%s%s' % (DOMAIN, self.cover.url), )] diff --git a/bookwyrm/models/import_job.py b/bookwyrm/models/import_job.py index f7b5e8a2..891bfd1b 100644 --- a/bookwyrm/models/import_job.py +++ b/bookwyrm/models/import_job.py @@ -72,7 +72,7 @@ class ImportItem(models.Model): def get_book_from_isbn(self): ''' search by isbn ''' search_result = books_manager.first_search_result( - self.isbn, min_confidence=0.992 + self.isbn, min_confidence=0.995 ) if search_result: try: @@ -90,7 +90,7 @@ class ImportItem(models.Model): self.data['Author'] ) search_result = books_manager.first_search_result( - search_term, min_confidence=0.992 + search_term, min_confidence=0.995 ) if search_result: try: