@@ -361,7 +361,7 @@ def _refresh_book_cache(self):
361361 # Problem 2: Cache Key 'fname' is lowercase, but real filename is in book_info['fileName'].
362362
363363 live_book = live_map [str (bid )]
364- raw_live_filename = live_book .get ('fileName' , '' )
364+ raw_live_filename = live_book .get ('primaryFile' , {}). get ( ' fileName' , live_book . get ( 'fileName' , '' ) )
365365 # Clean filename to ensure we don't treat whitespace/control chars as valid names
366366 live_filename = str (raw_live_filename ).strip () if raw_live_filename else ''
367367
@@ -451,7 +451,10 @@ def _process_book_detail(self, detail):
451451 if lid is not None and str (lid ) != str (self .target_library_id ):
452452 return None
453453
454- filename = detail .get ('fileName' , '' )
454+ primary_file = detail .get ('primaryFile' , {})
455+ filename = primary_file .get ('fileName' , detail .get ('fileName' , '' ))
456+ filepath = primary_file .get ('filePath' , detail .get ('filePath' , '' ))
457+ book_type = primary_file .get ('bookType' , detail .get ('bookType' , '' ))
455458 if not filename :
456459 return
457460
@@ -473,11 +476,11 @@ def _process_book_detail(self, detail):
473476 book_info = {
474477 'id' : detail .get ('id' ),
475478 'fileName' : filename ,
476- 'filePath' : detail . get ( 'filePath' ) ,
479+ 'filePath' : filepath ,
477480 'title' : title ,
478481 'subtitle' : subtitle ,
479482 'authors' : author_str ,
480- 'bookType' : detail . get ( 'bookType' ) ,
483+ 'bookType' : book_type ,
481484 'epubProgress' : detail .get ('epubProgress' ),
482485 'pdfProgress' : detail .get ('pdfProgress' ),
483486 'cbxProgress' : detail .get ('cbxProgress' ),
@@ -651,7 +654,7 @@ def get_progress(self, ebook_filename):
651654 response = self ._make_request ("GET" , f"/api/v1/books/{ book ['id' ]} " )
652655 if response and response .status_code == 200 :
653656 data = response .json ()
654- book_type = data .get ('bookType' , '' ).upper ()
657+ book_type = data .get ('primaryFile' , {}). get ( ' bookType' , data . get ( 'bookType' , '' ) ).upper ()
655658 if book_type == 'EPUB' :
656659 progress = data .get ('epubProgress' ) or {}
657660 pct = progress .get ('percentage' , 0 )
0 commit comments