diff --git a/fedireads/openlibrary.py b/fedireads/openlibrary.py index 49b1e3bc..5a7fd799 100644 --- a/fedireads/openlibrary.py +++ b/fedireads/openlibrary.py @@ -19,11 +19,12 @@ def book_search(query): for doc in data['docs'][:5]: key = doc['key'] key = key.split('/')[-1] + author = doc.get('author_name') or ['Unknown'] results.append({ 'title': doc.get('title'), 'olkey': key, 'year': doc.get('first_publish_year'), - 'author': doc.get('author_name')[0], + 'author': author[0], }) return results @@ -68,7 +69,7 @@ def get_or_create_book(olkey, user=None, update=False): author_id = author_id.split('/')[-1] book.authors.add(get_or_create_author(author_id)) - if data['covers'] and len(data['covers']): + if data.get('covers') and len(data['covers']): book.cover.save(*get_cover(data['covers'][0]), save=True) return book diff --git a/fedireads/templates/author.html b/fedireads/templates/author.html new file mode 100644 index 00000000..7c54361e --- /dev/null +++ b/fedireads/templates/author.html @@ -0,0 +1,15 @@ +{% extends 'layout.html' %} +{% load fr_display %} +{% block content %} +
by {{ book.authors.first.data.name }}
+by {{ book.authors.first.data.name }}
{% if rating %} {{ rating | stars }} {{ rating }} diff --git a/fedireads/urls.py b/fedireads/urls.py index 390f6e63..7105089b 100644 --- a/fedireads/urls.py +++ b/fedireads/urls.py @@ -29,6 +29,7 @@ urlpatterns = [ re_path(r'^user/(?P