View Single Post
Old 05-05-2020, 05:04 AM   #1
carmenchu
Groupie
carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.carmenchu ought to be getting tired of karma fortunes by now.
 
Posts: 192
Karma: 266070
Join Date: Dec 2010
Location: Spain
Device: Win10,Win11,Ubuntu,PockbookLux44
Edit epub2 .opf file through calibre plug-in...?

I wish to know if it is possible to do the following modifications to the <metadata> section of content.opf through a calibre plug-in, to be run automatically after conversion and/or
polish book -> update metadata in book file

1. retrieve the 'value' (integer) from field #custom_date and
* add it as <dc:date opf:event="creation">'value'</dc:date>
* delete any existing <dc:date>...</dc:date> (no opf:event)

2. for all existing <dc:subject>...</dc:subject>, coming from my calibre tags or already in the original epub:
* if of the form <dc:subject>[item_in_list1]</dc:subject>, change to <dc:source>item_in_list1</dc:source>
* delete the rest if not of the form <dc:subject>item_in_list2</dc:subject> (my genres)

3. delete all <<meta name="calibre:user_ .../>

I am currently doing this through a (personal) sigil plug-in: chiefly a magnified search&replace along the beautiful soup 'meta tag', but I cannot see how to do the same 'at source' in calibre.
The 'mi' object doesn't seem to provide the ability to substitute/delete <tag>...</tag>, and I haven't seen in the documentation any other way likely to work.

Any help would be appreciated--even if it is on the lines 'you cannot do that'.
carmenchu is offline   Reply With Quote