From 0a2d762d3bd4eb9b05d43defe15ff00c121621cd Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 12 Nov 2020 13:16:26 -0800 Subject: [PATCH] Fixes error state when there are author duplicates there shouldn't be, but it shouldn't crash a goodreads import either --- bookwyrm/connectors/openlibrary.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bookwyrm/connectors/openlibrary.py b/bookwyrm/connectors/openlibrary.py index 9b8afaa6a..5c26ad45b 100644 --- a/bookwyrm/connectors/openlibrary.py +++ b/bookwyrm/connectors/openlibrary.py @@ -177,10 +177,9 @@ class Connector(AbstractConnector): ''' load that author ''' if not re.match(r'^OL\d+A$', olkey): raise ValueError('Invalid OpenLibrary author ID') - try: - return models.Author.objects.get(openlibrary_key=olkey) - except models.Author.DoesNotExist: - pass + author = models.Author.objects.filter(openlibrary_key=olkey).first() + if author: + return author url = '%s/authors/%s.json' % (self.base_url, olkey) data = get_data(url)