View Single Post
Old 04-23-2011, 01:06 PM   #1
Junior Member
dino8352 is on a distinguished road
Posts: 2
Karma: 72
Join Date: Oct 2008
Device: T-Mobile MyTouch 4G running Aldiko reader
Announcing: epub-tools software

For a couple of reasons I found myself running into limitations using the Calibre tools for working with epubs. One issue has been performance and the other is being able to more comprehensively interact with the OPF Package fields specific to epub.

This led me to work on a library and some command-line utilities for working specifically with epub files (and only epub files). My software is compiled into native code and is not only extremely performant but also doesn't carry dependencies to any VM or interpreter.

The programs in epub-tools are:

a command-line utility for examining and editing epub book metadata. With it you can export, import and edit the raw OPF Package XML document for a given book. Or simply dump the metadata to stdout for viewing in a friendly format.

here's an example of epubmeta output:

   $ epubmeta Kelly_Kessel_Lethem-NinetyPercentOfEverything.epub 

      version: 2.0
      unique-identifier: calibre_id
   title: Ninety Percent of Everything
      role: aut
      file-as: Kelly, James Patrick
      creator: James Patrick Kelly
      role: aut
      creator: John Kessel
      role: aut
      creator: Jonathan Lethem
      role: bkp
      file-as: calibre
      creator: calibre (0.5.1) []
   date: 2001-03-25T00:00:00
      id: calibre_id
      scheme: calibre
      identifier: b1026732-69a5-4a05-a8d9-a1701685f6fa
      id: [WARNING: missing required id attribute]
      scheme: ISBN
      identifier: 1-590620-00-3
   subject: Science Fiction/Fantasy
   language: en-us
a command-line utility for renaming epub ebook files based on their OPF Package metadata. It tries to use author names and title info to construct a sensible name.

Using it looks like this:

$ epubname poorly-named-book.epub 

poorly-named-book.epub -> WattsPeter-Blindsight_2006.epub

$ epubname another-poorly-named-book.epub 

another-poorly-named-book.epub -> Kelly_Kessel_Lethem-NinetyPercentOfEverything.epub
a handy utility for zipping up the files that comprise an epub into an .epub zip file. Using the same technology as epubname, it can try to make a meaningful filename for the book.

I ran a time comparison of using epubmeta (from epub-tools) and ebook-meta (from Calibre) side-by-side against a random sample of 50 epub files (mostly purchased from Fictionwise). The results of a simple dump of book metadata using these tools looks like this:

$ time for F in *.epub ; do ebook-meta $F ; done

real  2m15.550s
user  2m7.352s
sys   0m5.480s

$ time for F in *.epub ; do epubmeta $F ; done

real  0m0.767s
user  0m0.530s
sys   0m0.163s

This software is open-source and is available for UNIX-like operating systems and in Windows binary form, downloadable at its home:

One thing I would be open to is more switches for epubmeta to allow you to script changes to books. At the moment, you can edit or export/import the OPF XML document in the book with it, which has been enough for my needs.

Any feedback would be welcome:
dino8352 is offline   Reply With Quote