Fixes error state when there are author duplicates

there shouldn't be, but it shouldn't crash a goodreads import either
This commit is contained in:
Mouse Reeve 2020-11-12 13:16:26 -08:00
parent ffeed6047e
commit 0a2d762d3b

View file

@ -177,10 +177,9 @@ class Connector(AbstractConnector):
''' load that author ''' ''' load that author '''
if not re.match(r'^OL\d+A$', olkey): if not re.match(r'^OL\d+A$', olkey):
raise ValueError('Invalid OpenLibrary author ID') raise ValueError('Invalid OpenLibrary author ID')
try: author = models.Author.objects.filter(openlibrary_key=olkey).first()
return models.Author.objects.get(openlibrary_key=olkey) if author:
except models.Author.DoesNotExist: return author
pass
url = '%s/authors/%s.json' % (self.base_url, olkey) url = '%s/authors/%s.json' % (self.base_url, olkey)
data = get_data(url) data = get_data(url)