From 89c23c3e0c20424295ce0afd8fc34ea7f3abf173 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 5 Dec 2021 09:07:17 -0800 Subject: [PATCH] More thoroughly checking if title is set to avoid error --- bookwyrm/utils/isni.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bookwyrm/utils/isni.py b/bookwyrm/utils/isni.py index 65d20c85c..180c5e388 100644 --- a/bookwyrm/utils/isni.py +++ b/bookwyrm/utils/isni.py @@ -104,12 +104,14 @@ def find_authors_by_name(name_string, description=False): # otherwise just grab the first title listing titles.append(element.find(".//title")) - if titles is not None: + if titles: # some of the "titles" in ISNI are a little ...iffy # '@' is used by ISNI/OCLC to index the starting point ignoring stop words # (e.g. "The @Government of no one") title_elements = [ - e for e in titles if not e.text.replace("@", "").isnumeric() + e + for e in titles + if hasattr(e, "text") and not e.text.replace("@", "").isnumeric() ] if len(title_elements): author.bio = title_elements[0].text.replace("@", "")