Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 03-16-2017, 12:31 PM   #1
sbin
Voracious reader
sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.
 
sbin's Avatar
 
Posts: 56
Karma: 14644
Join Date: Oct 2009
Device: Kobo Aura One, Sony PRS T2, iPhone 6, Cybook Orizon, Cybook Gen3
how to automatize routine modifications to epubs?

I'm always performing the same fixes to my epubs before reading them, and I was wondering if there's a way to automatize all the work (or at least part of it).

The operations I normally do manually within calibre's editor are:
— "beautify" all the files (this is needed mainly for the searches&replaces to work properly)
— fix the ellipsis in all text files
— remove line-height and text-alignment: justify in all the css
— set all non-zero values for text-indent to 1em
— some other stuff very similar to the previous points


I already have a bunch of saved searches, but given that all these operations don't require discretion, is there a plugin or a smarter way to manage all this?

Thanks
sbin is offline   Reply With Quote
Advert
Old 03-16-2017, 01:47 PM   #2
dickloraine
Fanatic
dickloraine ought to be getting tired of karma fortunes by now.dickloraine ought to be getting tired of karma fortunes by now.dickloraine ought to be getting tired of karma fortunes by now.dickloraine ought to be getting tired of karma fortunes by now.dickloraine ought to be getting tired of karma fortunes by now.dickloraine ought to be getting tired of karma fortunes by now.dickloraine ought to be getting tired of karma fortunes by now.dickloraine ought to be getting tired of karma fortunes by now.dickloraine ought to be getting tired of karma fortunes by now.dickloraine ought to be getting tired of karma fortunes by now.dickloraine ought to be getting tired of karma fortunes by now.
 
Posts: 595
Karma: 7507886
Join Date: Apr 2013
Location: Berlin
Device: PRS 350, Kobo Aura
I changed the modifyEpub plugin for similar things. If you know a little bit of python, this is quite easy.
dickloraine is offline   Reply With Quote
Old 03-16-2017, 02:33 PM   #3
sbin
Voracious reader
sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.
 
sbin's Avatar
 
Posts: 56
Karma: 14644
Join Date: Oct 2009
Device: Kobo Aura One, Sony PRS T2, iPhone 6, Cybook Orizon, Cybook Gen3
Quote:
Originally Posted by dickloraine View Post
I changed the modifyEpub plugin for similar things. If you know a little bit of python, this is quite easy.
Nope, I don't speak python

I was hoping for something similar to the "polish book" plugin, But I haven't been able to find it.
sbin is offline   Reply With Quote
Old 03-16-2017, 10:40 PM   #4
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 11,511
Karma: 17600947
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo: Touch, Glo, Aura H2O, Glo HD
Quote:
Originally Posted by sbin View Post
Nope, I don't speak python

I was hoping for something similar to the "polish book" plugin, But I haven't been able to find it.
The Modify ePub plugin is probably the closest thing. You might be able to convince someone to update it and add these.

Something you can do is to put all the searches a group and run the group. That still means you need to open the book in the editor, but it reduces the steps involved.

A thought would be to find someone to write a plugin that can execute saved searches on a set of books without opening the books in the editor. I have no idea if there is support in the calibre framework to do this, so I don't know how possible it is. If you are lucky, just this suggestion will prompt someone to do it. I'm just hoping I can resist the urge.
davidfor is offline   Reply With Quote
Old 03-17-2017, 12:39 AM   #5
icallaci
Addict
icallaci ought to be getting tired of karma fortunes by now.icallaci ought to be getting tired of karma fortunes by now.icallaci ought to be getting tired of karma fortunes by now.icallaci ought to be getting tired of karma fortunes by now.icallaci ought to be getting tired of karma fortunes by now.icallaci ought to be getting tired of karma fortunes by now.icallaci ought to be getting tired of karma fortunes by now.icallaci ought to be getting tired of karma fortunes by now.icallaci ought to be getting tired of karma fortunes by now.icallaci ought to be getting tired of karma fortunes by now.icallaci ought to be getting tired of karma fortunes by now.
 
Posts: 396
Karma: 6443938
Join Date: Sep 2012
Device: Kobo Aura One, Kobo Aura H20, Samsung Galaxy Note 4 and Galaxy S2 8.0
Quote:
Originally Posted by sbin View Post
I'm always performing the same fixes to my epubs before reading them, and I was wondering if there's a way to automatize all the work (or at least part of it).

The operations I normally do manually within calibre's editor are:
— "beautify" all the files (this is needed mainly for the searches&replaces to work properly)
— fix the ellipsis in all text files
— remove line-height and text-alignment: justify in all the css
— set all non-zero values for text-indent to 1em
— some other stuff very similar to the previous points


I already have a bunch of saved searches, but given that all these operations don't require discretion, is there a plugin or a smarter way to manage all this?

Thanks
I have no idea how to answer your question, but I just wanted to say, "OMG, there's someone out there besides me who fixes ellipses!" (I also remove line-heights and set non-zero text-indents to 1em unless it's a hanging indent with a negative value), but it was your comment on ellipses that got me. Poorly formatted and inconsistent ellipses drive me crazy, and now I feel better because I'm not the only person in the world who fixes them.
icallaci is offline   Reply With Quote
Old 03-17-2017, 02:33 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: 30,186
Karma: 7723401
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You can use the Look & Feel->Transform styles tool to accomplish the CSS changes automatically during a conversion. And the Search & Replace tool to do the ellipses also in the conversion dialog.

The transform Styles tool is also available in the editor.
kovidgoyal is offline   Reply With Quote
Old 03-17-2017, 11:46 AM   #7
sbin
Voracious reader
sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.
 
sbin's Avatar
 
Posts: 56
Karma: 14644
Join Date: Oct 2009
Device: Kobo Aura One, Sony PRS T2, iPhone 6, Cybook Orizon, Cybook Gen3
Quote:
Originally Posted by kovidgoyal View Post
You can use the Look & Feel->Transform styles tool to accomplish the CSS changes automatically during a conversion. And the Search & Replace tool to do the ellipses also in the conversion dialog.

The transform Styles tool is also available in the editor.
I hadn't thought about doing a conversion from epub to epub. It doesn't automatize everything but it can fix a good amount of issues beforehand. Thank you Kovid
sbin is offline   Reply With Quote
Old 03-26-2017, 06:56 AM   #8
Rev. Bob
Wizard
Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.
 
Rev. Bob's Avatar
 
Posts: 1,416
Karma: 7117502
Join Date: Feb 2013
Location: Here on the perimeter, there are no stars
Device: Kobo Glo, Kobo H2O, Kindle Touch
Along similar lines, is it possible for a user to modify/replace the code that Calibre uses to generate the titlepage.xhtml file when converting a Kindle book to EPUB?

I'm currently handling this by storing my preferred code in a snippet so I can replace the stock XHTML with relative ease, but that still means opening every book in the editor, one by one by one. I'm looking for a way to automate the process.
Rev. Bob is offline   Reply With Quote
Old 03-26-2017, 11:19 AM   #9
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 20,074
Karma: 19444856
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Astak Pocket Pro, K4NT,Galaxy Tab 2
Quote:
Originally Posted by Rev. Bob View Post
Along similar lines, is it possible for a user to modify/replace the code that Calibre uses to generate the titlepage.xhtml file when converting a Kindle book to EPUB?

I'm currently handling this by storing my preferred code in a snippet so I can replace the stock XHTML with relative ease, but that still means opening every book in the editor, one by one by one. I'm looking for a way to automate the process.
Any standard Calibre 'template' or code (py) can have a Modified version in the Configuration Folder (same relative placement as IN Calibre2).
those take precedence
theducks is offline   Reply With Quote
Old 03-26-2017, 11:23 AM   #10
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 20,074
Karma: 19444856
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Astak Pocket Pro, K4NT,Galaxy Tab 2
BTW those (titlepage and jacket) will also be used when 'sending to device', so no pressing need to convert/edit
theducks is offline   Reply With Quote
Old 03-26-2017, 06:59 PM   #11
Rev. Bob
Wizard
Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.
 
Rev. Bob's Avatar
 
Posts: 1,416
Karma: 7117502
Join Date: Feb 2013
Location: Here on the perimeter, there are no stars
Device: Kobo Glo, Kobo H2O, Kindle Touch
Quote:
Originally Posted by theducks View Post
BTW those (titlepage and jacket) will also be used when 'sending to device', so no pressing need to convert/edit
Some of us don't use Calibre for that function. Personally, I only use the metadata lookup, format conversion, and editing features.
Rev. Bob is offline   Reply With Quote
Old 03-26-2017, 08:51 PM   #12
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 20,074
Karma: 19444856
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Astak Pocket Pro, K4NT,Galaxy Tab 2
Quote:
Originally Posted by Rev. Bob View Post
Some of us don't use Calibre for that function. Personally, I only use the metadata lookup, format conversion, and editing features.
Then Polish. That will use some of the same features.
theducks is offline   Reply With Quote
Old 03-27-2017, 10:44 AM   #13
Rev. Bob
Wizard
Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.
 
Rev. Bob's Avatar
 
Posts: 1,416
Karma: 7117502
Join Date: Feb 2013
Location: Here on the perimeter, there are no stars
Device: Kobo Glo, Kobo H2O, Kindle Touch
Quote:
Originally Posted by theducks View Post
Then Polish. That will use some of the same features.
The Polish feature, by the look of it, has nothing to do with what I'm after. I don't know why this is such a hard concept to communicate.

I don't want to make a new cover image - based on metadata or anything else.
I don't want to add a new HTML page or jacket to the book.
I don't want to have to repeat some process for every book, one at a time, as a manual step.

I simply want to replace the standard XHTML code that Calibre uses in the first place when it generates a cover page. I want to change that default page's formula so that whenever I convert a Kindle book to EPUB, Calibre will use my HTML instead of whatever it's using now. By definition, that page has to be stored somewhere in Calibre. I just want to know where.

This shouldn't involve using a plugin - just learning the location of an existing file or script. Unless, that is, the XHTML in question is hardcoded into a combiled binary, such that changing it would require recompiling the software... which would be a weird choice.
Rev. Bob is offline   Reply With Quote
Old 03-27-2017, 10:58 AM   #14
jackie_w
Wizard
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 3,886
Karma: 7424156
Join Date: Sep 2009
Location: UK
Device: Sony PRS-350, Kobo AuraHD/Aura6"/AuraH2O/GloHD/AuraOne
Quote:
Originally Posted by Rev. Bob View Post
By definition, that page has to be stored somewhere in Calibre. I just want to know where.
I think the code you're after is stored in the CoverManager class in calibre.ebooks.oeb.transforms.cover if you're running from source.
jackie_w is offline   Reply With Quote
Old 03-28-2017, 04:07 AM   #15
Rev. Bob
Wizard
Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.Rev. Bob ought to be getting tired of karma fortunes by now.
 
Rev. Bob's Avatar
 
Posts: 1,416
Karma: 7117502
Join Date: Feb 2013
Location: Here on the perimeter, there are no stars
Device: Kobo Glo, Kobo H2O, Kindle Touch
Quote:
Originally Posted by jackie_w View Post
I think the code you're after is stored in the CoverManager class in calibre.ebooks.oeb.transforms.cover if you're running from source.
I am unfortunately not running from source; depending on the machine, I'm running either a Portable build or the Win64 compile. Any idea what file that module ends up in?
Rev. Bob is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic routine when sending book to device (Kobo) Doonge Development 4 11-14-2014 08:20 PM
What’s your “image rehab” routine? GrannyGrump Workshop 58 11-23-2013 03:01 AM
K5 help with some modifications moller Kindle Developer's Corner 3 10-12-2012 02:31 PM
Different Send to Device routine based on the library. iatheia Library Management 10 01-24-2012 12:06 PM
iLiad Registry modifications Martijn iRex Developer's Corner 7 03-27-2008 05:37 PM


All times are GMT -4. The time now is 08:27 PM.


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