View Single Post
Old 03-17-2025, 05:55 PM   #1441
fidvo
Addict
fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.fidvo ought to be getting tired of karma fortunes by now.
 
Posts: 309
Karma: 1645952
Join Date: Jun 2012
Device: none
Need help with module to add empty book

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.
fidvo is offline   Reply With Quote