Check if Google Books API key is present.
This commit is contained in:
@@ -42,16 +42,17 @@ def get_details(book_object):
|
|||||||
book_object["description"] = BeautifulSoup(description).text
|
book_object["description"] = BeautifulSoup(description).text
|
||||||
else:
|
else:
|
||||||
book_object["description"] = ""
|
book_object["description"] = ""
|
||||||
# Attempt to use Google Book API
|
if GOOGLE_BOOK_API_KEY.strip(" "):
|
||||||
url = "https://www.googleapis.com/books/v1/volumes?q={}+inauthor:{}&key={}".format(
|
# Attempt to use Google Book API
|
||||||
book_object["title"], book_object["author"], GOOGLE_BOOK_API_KEY,
|
url = "https://www.googleapis.com/books/v1/volumes?q={}+inauthor:{}&key={}".format(
|
||||||
)
|
book_object["title"], book_object["author"], GOOGLE_BOOK_API_KEY,
|
||||||
response = requests.request("GET", url)
|
)
|
||||||
|
response = requests.request("GET", url)
|
||||||
|
|
||||||
for item in response.json()["items"]:
|
for item in response.json()["items"]:
|
||||||
if "description" in item["volumeInfo"]:
|
if "description" in item["volumeInfo"]:
|
||||||
book_object["description"] = item["volumeInfo"]["description"]
|
book_object["description"] = item["volumeInfo"]["description"]
|
||||||
break
|
break
|
||||||
|
|
||||||
print("Fetching amazon link")
|
print("Fetching amazon link")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user