![]() |
#1 |
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 191
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'. ![]() |
![]() |
![]() |
![]() |
#2 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,771
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
There is no plugin to do all this. But you can do it all manually using Calibre's eBook editor.
|
![]() |
![]() |
![]() |
#3 |
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 191
Karma: 266070
Join Date: Dec 2010
Location: Spain
Device: Win10,Win11,Ubuntu,PockbookLux44
|
Of course there isn't such a plugin--that's why I ask for help towards making one.
As I make those changes to every single book, I am slightly feed up with the manual procedure--thus the sigil plugin, which already works--and the wish for a calibre one, which I hoped would be simpler, besides avoiding fishing among 'calibre:user_...' tags and providing for changes between old/new conversions (I have spotted already two different ways in which my custom field gets into the .opf file). My notion was rather to get the fields/tags values directly from calibre and fit them into the opf meta, deleting all the information I don't want in the epub--a kind of 'customized polishing', in fact. Very grateful for any hints... |
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,364
Karma: 27230406
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Look at the quality check plug in for an example of modifying epub files in bulk.
|
![]() |
![]() |
![]() |
#5 |
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 191
Karma: 266070
Join Date: Dec 2010
Location: Spain
Device: Win10,Win11,Ubuntu,PockbookLux44
|
|
![]() |
![]() |
![]() |
#6 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,364
Karma: 27230406
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
IIRC both do modifications to EPUB but yeah modify epub is probably a better place to start
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Calibre see's OPF file as a book when importing books | userpaul | Library Management | 2 | 04-19-2020 02:34 PM |
Calibre OPF File help | Eagleone 55 | Calibre | 10 | 11-21-2014 10:49 PM |
When adding books, Calibre is loading OPF file | toomuchreading | Library Management | 2 | 11-18-2014 04:09 PM |
Bulk edit OPF file? | rhino79 | Conversion | 0 | 08-23-2013 02:44 AM |
TWO OPF files or something like Media Queries in the OPF file for KF8 and MOBI? | DHahn | Kindle Formats | 3 | 04-17-2012 04:06 AM |