From 79af354dfd6dfc6696b794c5c3bb6e67e7a92727 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 14 Dec 2021 11:27:13 -0800 Subject: [PATCH] Don't produce error is author is unset in import --- bookwyrm/models/import_job.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bookwyrm/models/import_job.py b/bookwyrm/models/import_job.py index c4679585..8b6599e8 100644 --- a/bookwyrm/models/import_job.py +++ b/bookwyrm/models/import_job.py @@ -25,7 +25,7 @@ def construct_search_term(title, author): # Strip brackets (usually series title from search term) title = re.sub(r"\s*\([^)]*\)\s*", "", title) # Open library doesn't like including author initials in search term. - author = re.sub(r"(\w\.)+\s*", "", author) + author = re.sub(r"(\w\.)+\s*", "", author) if author else "" return " ".join([title, author]) @@ -114,6 +114,8 @@ class ImportItem(models.Model): def get_book_from_title_author(self): """search by title and author""" + if not self.title: + return None, 0 search_term = construct_search_term(self.title, self.author) search_result = connector_manager.first_search_result( search_term, min_confidence=0.1