@@ -83,16 +83,10 @@ def insert_book_to_notion(books, index, bookId):
83
83
book ["时间" ] = date
84
84
book ["开始阅读时间" ] = book .get ("beginReadingDate" )
85
85
book ["最后阅读时间" ] = book .get ("lastReadingDate" )
86
+ cover = book .get ("cover" ).replace ("/s_" , "/t7_" )
87
+ if not cover .startswith ("http" ):
88
+ cover = BOOK_ICON_URL
86
89
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
90
isbn = book .get ("isbn" )
97
91
if isbn and isbn .strip ():
98
92
douban_url = get_douban_url (isbn )
@@ -129,13 +123,14 @@ def insert_book_to_notion(books, index, bookId):
129
123
if bookId in notion_books :
130
124
result = notion_helper .update_page (
131
125
page_id = notion_books .get (bookId ).get ("pageId" ),
132
- properties = properties
126
+ properties = properties ,
127
+ cover = utils .get_icon (cover ),
133
128
)
134
129
else :
135
- result = notion_helper .create_page (
130
+ result = notion_helper .create_book_page (
136
131
parent = parent ,
137
132
properties = properties ,
138
- icon = utils .get_icon (book . get ( "封面" ) ),
133
+ icon = utils .get_icon (cover ),
139
134
)
140
135
page_id = result .get ("id" )
141
136
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):
171
166
"标题" : utils .get_title (
172
167
pendulum .from_timestamp (timestamp , tz = tz ).to_date_string ()
173
168
),
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
+ ),
175
174
"时长" : utils .get_number (duration ),
176
175
"时间戳" : utils .get_number (timestamp ),
177
176
"书架" : utils .get_relation ([book_database_id ]),
@@ -206,9 +205,7 @@ def insert_to_notion(page_id, timestamp, duration, book_database_id):
206
205
or value .get ("readingTime" ) == bookProgress .get (key ).get ("readingTime" )
207
206
)
208
207
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 )
212
209
and (
213
210
value .get ("status" ) != "已读"
214
211
or (value .get ("status" ) == "已读" and value .get ("myRating" ))
0 commit comments