From ec907bf9b3835a744a348f0099287d52db398748 Mon Sep 17 00:00:00 2001 From: malinkang Date: Sun, 7 Apr 2024 09:36:49 +0800 Subject: [PATCH] fix bug --- scripts/book.py | 31 +++++++++++++++---------------- scripts/notion_helper.py | 2 +- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/scripts/book.py b/scripts/book.py index b8f76484e410..de72198cd332 100644 --- a/scripts/book.py +++ b/scripts/book.py @@ -56,20 +56,6 @@ def insert_book_to_notion(books, index, bookId): readInfo.update(readInfo.get("readDetail", {})) readInfo.update(readInfo.get("bookInfo", {})) book.update(readInfo) - cover = book.get("cover") - if cover.startswith("http"): - if not cover.endswith(".jpg"): - cover = utils.upload_cover(cover) - else: - cover = cover.replace("/s_", "/t7_") - else: - cover = BOOK_ICON_URL - isbn = book.get("isbn") - if isbn and isbn.strip(): - douban_url = get_douban_url(isbn) - if douban_url: - book["douban_url"] = douban_url - book["封面"] = cover book["阅读进度"] = ( 100 if (book.get("markedStatus") == 4) else book.get("readingProgress", 0) ) / 100 @@ -98,6 +84,20 @@ def insert_book_to_notion(books, index, bookId): book["开始阅读时间"] = book.get("beginReadingDate") book["最后阅读时间"] = book.get("lastReadingDate") if bookId not in notion_books: + cover = book.get("cover") + if cover.startswith("http"): + if not cover.endswith(".jpg"): + cover = utils.upload_cover(cover) + else: + cover = cover.replace("/s_", "/t7_") + else: + cover = BOOK_ICON_URL + book["封面"] = cover + isbn = book.get("isbn") + if isbn and isbn.strip(): + douban_url = get_douban_url(isbn) + if douban_url: + book["douban_url"] = douban_url book["书名"] = book.get("title") book["BookId"] = book.get("bookId") book["ISBN"] = book.get("isbn") @@ -129,8 +129,7 @@ def insert_book_to_notion(books, index, bookId): if bookId in notion_books: result = notion_helper.update_page( page_id=notion_books.get(bookId).get("pageId"), - properties=properties, - icon=utils.get_icon(book.get("封面")), + properties=properties ) else: result = notion_helper.create_page( diff --git a/scripts/notion_helper.py b/scripts/notion_helper.py index 7030eb5fd91f..fb4f47854587 100644 --- a/scripts/notion_helper.py +++ b/scripts/notion_helper.py @@ -331,7 +331,7 @@ def update_book_page(self, page_id, properties): @retry(stop_max_attempt_number=3, wait_fixed=5000) def update_page(self, page_id, properties, icon): return self.client.pages.update( - page_id=page_id, icon=icon, properties=properties + page_id=page_id, properties=properties ) @retry(stop_max_attempt_number=3, wait_fixed=5000)