szarroug3 / X-Ray_Calibre_Plugin

X-Ray Creator plugin for Calibre
http://www.mobileread.com/forums/showthread.php?t=273189
GNU General Public License v3.0
57 stars 12 forks source link

Thumbnail images not updated on OSX/linux #58

Closed stoduk closed 8 years ago

stoduk commented 8 years ago

Samreen questioned in the pull request #54 whether the new code would work for linux - and having tested it doesn't. Pretty obvious really, given we'll have a book path such as /Volumes/Kindle/documents/SomeAuthor/SomeBook.mobi, we can't trivially just pull out the mountpoint (which is easier on Windows, where the mountpoint is given a drive letter - eg. K:\documents]\SomeAuthor\SomeBook.mobi).

The depth of the mount point isn't fixed, so safest way is to look for documents element - and then to make sure do the check for the version.txt file.

Rather than doing this for every single book, we can cache the result.

stoduk commented 8 years ago

Made the change to find the device root just before we walk all the devices on the book - verified with print statements that we are getting sane values out here and as we later handle each book. Plus the thumbnail file seems to be renamed - verified by deleting a book from device, resending, then doing an xray create.

Device root from book path  <---- XXX here is where we cache the value, looks good
/Volumes/Kindle/
/Volumes/Kindle/documents/Oxford Dictionary of English_B0053VMNYW.azw
Job: 7 Send metadata to device finished
No details available.
[u'MOBI', u'AZW3']
['mobi', 'azw3']
[{'local_xray': u'/Users/anthony/Calibre Library/Charles Dickens/A Christmas Carol (406)/A Christmas Carol - Charles Dickens.sdr/mobi', 'format': u'MOBI', 'status': 0, 'local_book': u'/Users/anthony/Calibre Library/Charles Dickens/A Christmas Carol (406)/A Christmas Carol - Charles Dickens.mobi', 'parsed_book_data': <calibre_plugins.xray_creator.lib.book_parser.BookParser object at 0x12a47af90>, 'status_message': None}]
[{'local_xray': u'/Users/anthony/Calibre Library/Charles Dickens/A Christmas Carol (406)/A Christmas Carol - Charles Dickens.sdr/mobi', 'format': u'MOBI', 'status': 0, 'local_book': u'/Users/anthony/Calibre Library/Charles Dickens/A Christmas Carol (406)/A Christmas Carol - Charles Dickens.mobi', 'parsed_book_data': <calibre_plugins.xray_creator.lib.book_parser.BookParser object at 0x12a47af90>, 'status_message': None}]
{'device_xray': u'/Volumes/Kindle/documents/Dickens, Charles/Christmas Carol, A - Charles Dickens.sdr', 'device_book': u'/Volumes/Kindle/documents/Dickens, Charles/Christmas Carol, A - Charles Dickens.mobi', 'device_root': u'/Volumes/Kindle/'}
/Volumes/Kindle/ <----- XXX here is where we use the value, looks good, new/old filenames sane, and os.path.exists(thumbname_orig) returns True
/Volumes/Kindle/system/thumbnails/thumbnail_B00Q0LB318_EBOK_portrait.jpg
/Volumes/Kindle/system/thumbnails/thumbnail_B00Q0LB318_mobi_EBOK_portrait.jpg
True
[{'device_xray': u'/Volumes/Kindle/documents/Dickens, Charles/Christmas Carol, A - Charles Dickens.sdr', 'device_book': u'/Volumes/Kindle/documents/Dickens, Charles/Christmas Carol, A - Charles Dickens.mobi', 'local_xray': u'/Users/anthony/Calibre Library/Charles Dickens/A Christmas Carol (406)/A Christmas Carol - Charles Dickens.sdr/mobi', 'format': u'MOBI', 'status': 0, 'local_book': u'/Users/anthony/Calibre Library/Charles Dickens/A Christmas Carol (406)/A Christmas Carol - Charles Dickens.mobi', 'send_status': 0, 'parsed_book_data': <calibre_plugins.xray_creator.lib.book_parser.BookParser object at 0x12a47af90>, 'status_message': None}]
[<calibre_plugins.xray_creator.lib.book.Book object at 0x11c7b1f10>]
[(0, None)]