Quote:
Originally Posted by davidfor
Alternatively, it might be possible do this using the Actions Chains plugin. It might be able to run the commands and it has ways to update the metadata for a book. I haven't explored it, so I am not sure if it would work.
|
As David points out, you can run your code through the Action Chains plugin to process multiple books. There is an action called "Run Python Code" that allows you to do just that:
- Create a chain that contains a single "Run Python Code" action.
- Click the settings button next to the action, a window will pop up where you can copy the following code:
Code:
def tags_from_epub(path_to_epub):
# the code you posted in your post should go
# here. The run() function below will pass
# path_to_epub, so modify it use this instead
# of the hardcoded epub path
def run(gui, settings, chain):
db = gui.current_db
for book_id in chain.scope().get_book_ids():
fmts = [ fmt.strip() for fmt in db.formats(book_id, index_is_id=True).split(',') ]
if 'EPUB' in fmts:
path_to_epub = db.format_abspath(book_id, 'EPUB', index_is_id=True)
tags_from_epub(path_to_epub)
As you can see, you have to include your code in the the first function and modify it to use path_to_epub
- Now, you should find a menu entry with the name of your chain in the Action Chains menu. You can even bind it to a keyboard shortcut if you want.
Edit: The chain you created will only act on books selected in the list view.