@@ -83,16 +83,11 @@ 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
89
+ print (cover )
86
90
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
91
isbn = book .get ("isbn" )
97
92
if isbn and isbn .strip ():
98
93
douban_url = get_douban_url (isbn )
@@ -129,13 +124,14 @@ def insert_book_to_notion(books, index, bookId):
129
124
if bookId in notion_books :
130
125
result = notion_helper .update_page (
131
126
page_id = notion_books .get (bookId ).get ("pageId" ),
132
- properties = properties
127
+ properties = properties ,
128
+ cover = utils .get_icon (cover ),
133
129
)
134
130
else :
135
- result = notion_helper .create_page (
131
+ result = notion_helper .create_book_page (
136
132
parent = parent ,
137
133
properties = properties ,
138
- icon = utils .get_icon (book . get ( "封面" ) ),
134
+ icon = utils .get_icon (cover ),
139
135
)
140
136
page_id = result .get ("id" )
141
137
if book .get ("readDetail" ) and book .get ("readDetail" ).get ("data" ):
@@ -171,7 +167,11 @@ def insert_to_notion(page_id, timestamp, duration, book_database_id):
171
167
"标题" : utils .get_title (
172
168
pendulum .from_timestamp (timestamp , tz = tz ).to_date_string ()
173
169
),
174
- "日期" : utils .get_date (start = pendulum .from_timestamp (timestamp , tz = tz ).format ("YYYY-MM-DD HH:mm:ss" )),
170
+ "日期" : utils .get_date (
171
+ start = pendulum .from_timestamp (timestamp , tz = tz ).format (
172
+ "YYYY-MM-DD HH:mm:ss"
173
+ )
174
+ ),
175
175
"时长" : utils .get_number (duration ),
176
176
"时间戳" : utils .get_number (timestamp ),
177
177
"书架" : utils .get_relation ([book_database_id ]),
@@ -206,9 +206,7 @@ def insert_to_notion(page_id, timestamp, duration, book_database_id):
206
206
or value .get ("readingTime" ) == bookProgress .get (key ).get ("readingTime" )
207
207
)
208
208
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" ))
209
+ and (value .get ("cover" ) is not None )
212
210
and (
213
211
value .get ("status" ) != "已读"
214
212
or (value .get ("status" ) == "已读" and value .get ("myRating" ))
0 commit comments