There is no really clean solution for this. The device subsystem assumes that book == single file. Changing that would require changes in the guts of calibre's devices subsystem.
The cleanest approach I can come up with is to have your plugin simply add the data to an existing azw3 file as a new record type, XRAY, see for example, the SRCS record in kindlegen produced files. Then the driver can look for this record and extract the info in it into the asc file the kindle needs when sending.
Unfortunately, this will require you to write code to modify existing mobi/azw3 files and add a record to them. That is not exactly trivial.
A more hackish solution is to create an altogether new filetype, say .xray which is basically a zip file containing the original azw3 and the xray information. Then the driver could be modified as before to extract both the xray and the azw3 files during send. The downsides to this are data duplication -- the book will be present twice in the book record and you would also need to write simple wrappers to read/write metadata from the new xray files in calibre.
Regarding your suggestions:
1) Is really not safe since the driver runs in a separate thread from the rest of calibre and is not supposed to be accessing the calibre library at all
2) You can certainly do this, plugins can have arbitrarily complex configuration. But it will be somewhat hard to use for your plugin users.
|