theducks, wallcraft, transmitthis: thank you for your comments.
There is some progress. The example plugin is called before the book is
imported and contains the full file path to the book.
Tags work like this. There is a tag table is defined as(id int, name text), each
entry is a tag. Each book also has an entry in the books table with a unique
id int. books_tags_link table links the two table with (id int, book int, tag int).
I can update the tags and books_tags_link table from the plugin.
But, here is the problem: when the plugin is called, the book has not been
entered into the book table yet and therefore does not have an id. Without the
book id, it is not possible to make an entry into the books_tags_link table.
I thought of getting the max(id) from books table and incrementing it, but the
system rejects the request because the book ID is not in the known books range.
It also is not reliable that the next ID will always be exactly one more from the
previous one. What is needed is that the calibre calls the plugin after the book
is entered into the books table (as well as before).
I don't know how to go from here. If the book titles are unique, then it is
possible to build a file with two columns: path and book title. and then
run an external program to generate tags and update books_tags_link table.
|