Skip to content

Commit ec27e69

Browse files
committed
Merge pull request #72 from FurCode/python3.4
books.py - Handling missing authors.
2 parents f0e2248 + 0a56521 commit ec27e69

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

plugins/books.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ def books(text):
3232

3333
book = json['items'][0]['volumeInfo']
3434
title = book['title']
35-
author = book['authors'][0]
35+
try:
36+
author = book['authors'][0]
37+
except KeyError:
38+
try:
39+
author = book['publisher']
40+
except KeyError:
41+
author = "Unknown Author"
3642

3743
try:
3844
description = formatting.truncate_str(book['description'], 130)

0 commit comments

Comments
 (0)