Merge pull request #1658 from bookwyrm-social/isni-check

More thoroughly checking if title is set to avoid error
This commit is contained in:
Mouse Reeve 2021-12-05 10:16:10 -08:00 committed by GitHub
commit 9b0b771a40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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("@", "")