|  05-05-2020, 05:04 AM | #1 | 
| Addict            Posts: 201 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'.   | 
|   |   | 
|  05-05-2020, 07:28 AM | #2 | 
| Resident Curmudgeon            Posts: 80,746 Karma: 150249619 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.
		 | 
|   |   | 
|  05-06-2020, 04:28 AM | #3 | 
| Addict            Posts: 201 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... | 
|   |   | 
|  05-06-2020, 05:30 AM | #4 | 
| creator of calibre            Posts: 45,604 Karma: 28548974 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.
		 | 
|   |   | 
|  05-06-2020, 07:42 AM | #5 | 
| Addict            Posts: 201 Karma: 266070 Join Date: Dec 2010 Location: Spain Device: Win10,Win11,Ubuntu,PockbookLux44 | |
|   |   | 
|  05-06-2020, 09:37 AM | #6 | 
| creator of calibre            Posts: 45,604 Karma: 28548974 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 Tools | Search this Thread | 
| 
 | 
|  Similar Threads | ||||
| 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 |