@@ -83,16 +83,10 @@ def insert_book_to_notion(books, index, bookId):
8383 book ["时间" ] = date
8484 book ["开始阅读时间" ] = book .get ("beginReadingDate" )
8585 book ["最后阅读时间" ] = book .get ("lastReadingDate" )
86+ cover = book .get ("cover" ).replace ("/s_" , "/t7_" )
87+ if not cover .startswith ("http" ):
88+ cover = BOOK_ICON_URL
8689 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
9690 isbn = book .get ("isbn" )
9791 if isbn and isbn .strip ():
9892 douban_url = get_douban_url (isbn )
@@ -129,13 +123,14 @@ def insert_book_to_notion(books, index, bookId):
129123 if bookId in notion_books :
130124 result = notion_helper .update_page (
131125 page_id = notion_books .get (bookId ).get ("pageId" ),
132- properties = properties
126+ properties = properties ,
127+ cover = utils .get_icon (cover ),
133128 )
134129 else :
135- result = notion_helper .create_page (
130+ result = notion_helper .create_book_page (
136131 parent = parent ,
137132 properties = properties ,
138- icon = utils .get_icon (book . get ( "封面" ) ),
133+ icon = utils .get_icon (cover ),
139134 )
140135 page_id = result .get ("id" )
141136 if book .get ("readDetail" ) and book .get ("readDetail" ).get ("data" ):
@@ -171,7 +166,11 @@ def insert_to_notion(page_id, timestamp, duration, book_database_id):
171166 "标题" : utils .get_title (
172167 pendulum .from_timestamp (timestamp , tz = tz ).to_date_string ()
173168 ),
174- "日期" : utils .get_date (start = pendulum .from_timestamp (timestamp , tz = tz ).format ("YYYY-MM-DD HH:mm:ss" )),
169+ "日期" : utils .get_date (
170+ start = pendulum .from_timestamp (timestamp , tz = tz ).format (
171+ "YYYY-MM-DD HH:mm:ss"
172+ )
173+ ),
175174 "时长" : utils .get_number (duration ),
176175 "时间戳" : utils .get_number (timestamp ),
177176 "书架" : utils .get_relation ([book_database_id ]),
@@ -206,9 +205,7 @@ def insert_to_notion(page_id, timestamp, duration, book_database_id):
206205 or value .get ("readingTime" ) == bookProgress .get (key ).get ("readingTime" )
207206 )
208207 and (archive_dict .get (key ) == value .get ("category" ))
209- and value .get ("cover" )
210- and (not value .get ("cover" ).endswith ("/0.jpg" ))
211- and (not value .get ("cover" ).endswith ("parsecover" ))
208+ and (value .get ("cover" ) is not None )
212209 and (
213210 value .get ("status" ) != "已读"
214211 or (value .get ("status" ) == "已读" and value .get ("myRating" ))
0 commit comments