From 42c13ae135463ce1e28668cdb112460c6061e0ff Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Fri, 20 Nov 2020 20:35:07 +0100 Subject: [PATCH] Fix for #1718 (fetch of metadata from google without cover leads to exception) --- cps/editbooks.py | 13 ++++++++----- cps/static/js/get_meta.js | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cps/editbooks.py b/cps/editbooks.py index 105995f6..80cb4dc8 100644 --- a/cps/editbooks.py +++ b/cps/editbooks.py @@ -652,12 +652,15 @@ def edit_book(book_id): if to_save["cover_url"]: if not current_user.role_upload(): return "", (403) - result, error = helper.save_cover_from_url(to_save["cover_url"], book.path) - if result is True: - book.has_cover = 1 - modif_date = True + if to_save["cover_url"].endswith('/static/generic_cover.jpg'): + book.has_cover = 0 else: - flash(error, category="error") + result, error = helper.save_cover_from_url(to_save["cover_url"], book.path) + if result is True: + book.has_cover = 1 + modif_date = True + else: + flash(error, category="error") # Add default series_index to book modif_date |= edit_book_series_index(to_save["series_index"], book) diff --git a/cps/static/js/get_meta.js b/cps/static/js/get_meta.js index b14283fe..d3e0eb46 100644 --- a/cps/static/js/get_meta.js +++ b/cps/static/js/get_meta.js @@ -108,7 +108,7 @@ $(function () { tags: result.volumeInfo.categories || [], rating: result.volumeInfo.averageRating || 0, cover: result.volumeInfo.imageLinks ? - result.volumeInfo.imageLinks.thumbnail : "/static/generic_cover.jpg", + result.volumeInfo.imageLinks.thumbnail : location + "/../../../static/generic_cover.jpg", url: "https://books.google.com/books?id=" + result.id, source: { id: "google",