Skip to content

Commit faef1b6

Browse files
author
Foxlet
committed
books.py - Check if API is off
1 parent c57f6fc commit faef1b6

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

plugins/books.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ def books(text):
2121

2222
json = requests.get(book_search_api, params={"q": text, "key": dev_key}).json()
2323

24-
if 'error' in json:
25-
return 'Error performing search.'
24+
if json.get('error'):
25+
if json['error']['code'] == 403:
26+
return "The Books API is off in the Google Developers Console."
27+
else:
28+
return 'Error performing search.'
2629

2730
if json['totalItems'] == 0:
2831
return 'No results found.'

0 commit comments

Comments
 (0)