@@ -197,7 +197,7 @@ def get_chapter_info(bookId):
197
197
return None
198
198
199
199
200
- def insert_to_notion (bookName , bookId , cover , sort , author ,isbn ,rating ):
200
+ def insert_to_notion (bookName , bookId , cover , sort , author ,isbn ,rating , categories ):
201
201
"""插入到notion"""
202
202
time .sleep (0.3 )
203
203
parent = {
@@ -214,12 +214,14 @@ def insert_to_notion(bookName, bookId, cover, sort, author,isbn,rating):
214
214
"Rating" : {"number" : rating },
215
215
"Cover" : {"files" : [{"type" : "external" , "name" : "Cover" , "external" : {"url" : cover }}]},
216
216
}
217
+ if (categories != None ):
218
+ multi_select = [{"name" : x } for x in categories ]
219
+ properties ["Categories" ] = {"multi_select" :multi_select }
217
220
read_info = get_read_info (bookId = bookId )
218
221
if read_info != None :
219
222
markedStatus = read_info .get ("markedStatus" , 0 )
220
223
readingTime = read_info .get ("readingTime" , 0 )
221
224
readingProgress = read_info .get ("readingProgress" , 0 )
222
- print (f"readingProgress = { readingProgress } " )
223
225
format_time = ""
224
226
hour = readingTime // 3600
225
227
if hour > 0 :
@@ -416,10 +418,13 @@ def calculate_book_str_id(book_id):
416
418
cover += ".jpg"
417
419
bookId = book .get ("bookId" )
418
420
author = book .get ("author" )
421
+ categories = book .get ("categories" )
422
+ if (categories != None ):
423
+ categories = [x ["title" ] for x in categories ]
419
424
print (f"正在同步 { title } ,一共{ len (books )} 本,当前是第{ i } 本。" )
420
425
check (bookId )
421
426
isbn ,rating = get_bookinfo (bookId )
422
- id = insert_to_notion (title , bookId , cover , sort , author ,isbn ,rating )
427
+ id = insert_to_notion (title , bookId , cover , sort , author ,isbn ,rating , categories )
423
428
chapter = get_chapter_info (bookId )
424
429
bookmark_list = get_bookmark_list (bookId )
425
430
summary , reviews = get_review_list (bookId )
0 commit comments