Skip to content

Commit e8ce984

Browse files
committed
fix cover
1 parent 9f74ff4 commit e8ce984

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

scripts/book.py

+15-16
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,6 @@ def insert_book_to_notion(books, index, bookId):
5656
readInfo.update(readInfo.get("readDetail", {}))
5757
readInfo.update(readInfo.get("bookInfo", {}))
5858
book.update(readInfo)
59-
cover = book.get("cover")
60-
if cover.startswith("http"):
61-
if not cover.endswith(".jpg"):
62-
cover = utils.upload_cover(cover)
63-
else:
64-
cover = cover.replace("/s_", "/t7_")
65-
else:
66-
cover = BOOK_ICON_URL
67-
isbn = book.get("isbn")
68-
if isbn and isbn.strip():
69-
douban_url = get_douban_url(isbn)
70-
if douban_url:
71-
book["douban_url"] = douban_url
72-
book["封面"] = cover
7359
book["阅读进度"] = (
7460
100 if (book.get("markedStatus") == 4) else book.get("readingProgress", 0)
7561
) / 100
@@ -98,6 +84,20 @@ def insert_book_to_notion(books, index, bookId):
9884
book["开始阅读时间"] = book.get("beginReadingDate")
9985
book["最后阅读时间"] = book.get("lastReadingDate")
10086
if bookId not in notion_books:
87+
cover = book.get("cover")
88+
if cover.startswith("http"):
89+
if not cover.endswith(".jpg"):
90+
cover = utils.upload_cover(cover)
91+
else:
92+
cover = cover.replace("/s_", "/t7_")
93+
else:
94+
cover = BOOK_ICON_URL
95+
book["封面"] = cover
96+
isbn = book.get("isbn")
97+
if isbn and isbn.strip():
98+
douban_url = get_douban_url(isbn)
99+
if douban_url:
100+
book["douban_url"] = douban_url
101101
book["书名"] = book.get("title")
102102
book["BookId"] = book.get("bookId")
103103
book["ISBN"] = book.get("isbn")
@@ -129,8 +129,7 @@ def insert_book_to_notion(books, index, bookId):
129129
if bookId in notion_books:
130130
result = notion_helper.update_page(
131131
page_id=notion_books.get(bookId).get("pageId"),
132-
properties=properties,
133-
icon=utils.get_icon(book.get("封面")),
132+
properties=properties
134133
)
135134
else:
136135
result = notion_helper.create_page(

scripts/notion_helper.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,9 @@ def update_book_page(self, page_id, properties):
329329
return self.client.pages.update(page_id=page_id, properties=properties)
330330

331331
@retry(stop_max_attempt_number=3, wait_fixed=5000)
332-
def update_page(self, page_id, properties, icon):
332+
def update_page(self, page_id, properties):
333333
return self.client.pages.update(
334-
page_id=page_id, icon=icon, properties=properties
334+
page_id=page_id, properties=properties
335335
)
336336

337337
@retry(stop_max_attempt_number=3, wait_fixed=5000)

0 commit comments

Comments
 (0)