I'm trying to create a module that adds an empty book and fills in some default metadata. Everything works except that the book doesn't show up in the book list until I reload the library (for example by restarting Calibre or switching to a different library and back). Here is my code:
Code:
from calibre_plugins.action_chains.actions.base import ChainAction
from calibre.ebooks.metadata.book.base import Metadata
class TestAddEmpty(ChainAction):
name = 'Add Empty'
def run(self, gui, settings, chain):
db = gui.current_db
ids, duplicates = db.new_api.add_books([(Metadata(None), {})])
# What do I put here?
newid = ids[0]
gui.library_view.select_rows([newid])
I assume I have to add something at the # What do I put here? marker in order to make the new book show up, but I don't know what it is. Any ideas?
Thanks.