[books] Fix date lookup and literal string title search
This commit is contained in:
@ -7,7 +7,7 @@ from django.conf import settings
|
||||
|
||||
API_KEY = settings.GOOGLE_API_KEY
|
||||
GOOGLE_BOOKS_URL = (
|
||||
"https://www.googleapis.com/books/v1/volumes?q={title}&key={key}"
|
||||
"https://www.googleapis.com/books/v1/volumes?q=\"{title}\"&key={key}"
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -52,6 +52,8 @@ def lookup_book_from_google(title: str) -> dict:
|
||||
book_dict["isbn_13"] = isbn_13
|
||||
book_dict["isbn_10"] = isbn_10
|
||||
book_dict["publish_date"] = google_result.get("publishedDate")
|
||||
if len(book_dict["publish_date"]) == 4:
|
||||
book_dict["publish_date"] = f"{book_dict['publish_date']}-1-1"
|
||||
book_dict["language"] = google_result.get("language")
|
||||
book_dict["summary"] = google_result.get("description")
|
||||
book_dict["genres"] = google_result.get("categories")
|
||||
|
||||
Reference in New Issue
Block a user