From 0a5652178f9d50b568bbe6ee83a63612db7883dc Mon Sep 17 00:00:00 2001 From: Foxlet Date: Thu, 15 Jan 2015 21:24:47 -0500 Subject: [PATCH] books.py - Handling missing authors. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug fix for the few books that don’t have an author for one reason or another. --- plugins/books.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/books.py b/plugins/books.py index 722a86017..ca260bbfd 100644 --- a/plugins/books.py +++ b/plugins/books.py @@ -32,7 +32,13 @@ def books(text): book = json['items'][0]['volumeInfo'] title = book['title'] - author = book['authors'][0] + try: + author = book['authors'][0] + except KeyError: + try: + author = book['publisher'] + except KeyError: + author = "Unknown Author" try: description = formatting.truncate_str(book['description'], 130)