The next release (0.7.36) of calibre will have some new APIs that might be of interest to plugin developers.
1) custom per-book data.
Three methods:
db.add_custom_book_data(book_id, name, val)
db.def get_custom_book_data(book_id, name, default=None)
db.delete_custom_book_data(book_id, name)
book_id must be the DB book id, not the cache index. name is an arbitrary string. No name reservation is done. val must be a string, integer, bool, datetime, bytestring, dict, or list; or be recursively made from these types. For example, my test dict is
Code:
d = {'date': datetime.datetime.today(),
'dict': {'a': True, 'b':'sss'},
'list': [1, 2, 3]
}
add_custom_book_data throws ValueError if book_id does not exist. It can also throw JSON exceptions.
get_custom_book_data does not throw exceptions. It returns 'default' if the data is not there or if any db or JSON exceptions are tossed.
delete_custom_book_data does what you expect. It shouldn't throw exceptions.
Data is automatically removed when a book is deleted.
2) Tag browser:
a) tags_view.model().find_node(key, txt, start_path)
Search for an item (a node) in the tags browser list that matches both the key (exact case-insensitive match) and txt (contains case-insensitive match). Returns the path to the node. Note that paths are to a location (second item, then fourth item, then 25th item), not to a node. If start_path is None, the search starts with the topmost node. If the tree is changed subsequent to calling this method, the path can easily refer to a different node or to no node at all.
b) tags_view.model().show_item_at_path(path, box=False)
Scroll the browser and open categories to show the item referenced by path. If possible, the item is placed in the center. If box=True, a box is drawn around the item. Intended to be used with the result of find_node, but any path will do.
c) tags_view.model().clear_boxed()
Remove all boxes from items in the tag browser.
d) tags_view.set_new_model(filter_categories_by=None)
Redisplay the tags pane, showing only items with name containing the string 'filter_categories_by'. This has no effect on the library view.