Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
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: 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'.
carmenchu is offline   Reply With Quote
Old 05-05-2020, 07:28 AM   #2
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,763
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.
JSWolf is offline   Reply With Quote
Advert
Old 05-06-2020, 04:28 AM   #3
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: 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...
carmenchu is offline   Reply With Quote
Old 05-06-2020, 05:30 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,360
Karma: 27182818
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.
kovidgoyal is online now   Reply With Quote
Old 05-06-2020, 07:42 AM   #5
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: 191
Karma: 266070
Join Date: Dec 2010
Location: Spain
Device: Win10,Win11,Ubuntu,PockbookLux44
Quote:
Originally Posted by kovidgoyal View Post
Look at the quality check plug in for an example of modifying epub files in bulk.
Thanks! Looking into it.
BTW, I assume you mean the 'Modify epub' plugin?
carmenchu is offline   Reply With Quote
Advert
Old 05-06-2020, 09:37 AM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,360
Karma: 27182818
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
kovidgoyal is online now   Reply With Quote
Reply


Forum Jump

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


All times are GMT -4. The time now is 09:56 PM.


MobileRead.com is a privately owned, operated and funded community.