mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-27 09:28:08 +00:00
Don't produce error is author is unset in import
This commit is contained in:
parent
fec1827302
commit
79af354dfd
1 changed files with 3 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue