Hello,
This is a follow up of two points in a previous discussion in this thread.
Quote:
Originally Posted by capink
Unfortuantely no. Someone will have to write it.
|
I wrote it, or at least I wrote a module which delete the epub format without further prompting, leaving only the AZW3 format I wanted. Should I post the code here if it can be useful to someone?
Quote:
Originally Posted by capink
I am not sure what you mean by cover based on custom column content. Anyway, check if this custom action does what you want (you need to copy paste it into the module editor). This action will extract the cover from the book.
|
I tried to implement a module from the custom action capnik mentioned, using the code to select the correct ebooks from the ones selected in the Library view. I also located the Calibre code behind the button I am clicking on manually: it is in
https://github.com/kovidgoyal/calibr...dgets.py#L1228 on line 1135.
With this information, I wrote:
Code:
from calibre.ebooks.covers import generate_cover
from calibre.ebooks.metadata.meta import metadata_from_formats
from calibre_plugins.action_chains.actions.base import ChainAction
class CustomCover(ChainAction):
# replace with the name of your action
name = 'Custom cover'
def run(self, gui, settings, chain):
db = gui.current_db.new_api
rows = gui.current_view().selectionModel().selectedRows()
book_ids = [ gui.library_view.model().db.id(row.row()) for row in rows ]
for book_id in book_ids:
mi = metadata_from_formats(paths)
cdata_before_generate = current_val
current_val = generate_cover(mi)
which does... nothing! Could someone point me in the good direction? (If it is too much of a request, let me know, I am not sure yet about the rules on this forum

)
Thank you!