View Single Post
Old 08-29-2014, 02:59 PM   #1
rpspringuel
Enthusiast
rpspringuel began at the beginning.
 
Posts: 40
Karma: 10
Join Date: Feb 2014
Device: Kindle 4
Sending multiple files from a single book

As part of my playing around with apnx files it occurred to me that it would be nice if when you send a book to the device, calibre could be configured to send multiple files from the library, not just the ebook itself.

For instance, when using an ebook purchased from Amazon that comes with an apnx file with real page numbers, it would be nice if I could add that apnx file to my calibre library (in addition to the book itself). Further, when sending that book to the Kindle that apnx file should be sent along with it, instead of calibre calculating a new one.

To implement this my thought was to change the Kindle driver so that when it gets to the point where its ready to calculate the apnx file, it first looks into the library to see if there is apnx file there that it should use. If there is, rather than calculating one, it copies over that file instead. If there isn't, then it calculates an apnx file as normal.

However, upon examining the Kindle driver code, it appears that the function which is in charge of ordering up apnx generation (upload_cover) is not aware of the path to the book in the library (at least in its arguments). The book has already been sent to the device and it is the filename and path for that copy of the book which are used in this process.

Thus, it appears that I would have to modify the USBMS driver (where upload_cover is called) to add an argument specifying the path back to the library entry for the book. Of course, more than the Kindle driver depends on the USBMS driver, so this modification would have cascading effects through the source code for other device drivers (changes I can't check myself because I don't own those devices).

Is there a less intrusive way of getting the library path information in order to check for the apnx file?

Alternatively, and this could be done more generally, would it be possible to tell Calibre that when sending a book to a particular device, it should upload multiple files? This would be a sort of inverse of what currently happens when deleting a book from a device. Upon deleting, Calibre knows to look for and also delete the appropriate companion files on the device. Each driver has the DELETE_EXTS property which contains a list of the file extentions which should be deleted in addition to the book file. A similar LOAD_EXTS property could similarly specify the file extensions of files which are to be loaded to the device along with each book (assuming said files have been loaded into the library).
rpspringuel is offline   Reply With Quote