View Single Post
Old 05-23-2011, 08:24 PM   #1
kiwidude
Calibre Plugins Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,635
Karma: 2162064
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Modify ePub plugin dev thread

I'm working on the "Modify ePub" plugin which has various manipulations of an ePub to partner Quality Check, such as removing spurious files, legacy jackets etc.

I decided to use the Container class from calibre/books/epub/fix/container.py as the basis for my manipulations. It is fairly basic but that is to the advantage for this plugin where the intent is to apply as minimal change to the ePub files as possible, taking care not to touch the CSS etc.

With a little extension I have that working pretty well, so where necessary I can remove items from the manifest and the spine of the opf, as well as the actual file.

However that does leave one aspect of the ePub file that I am not currently handling - that being the ncx TOC file. At this point the scope of my changes is only a potential desire to remove items from the TOC.

Looking in the Calibre codebase it seems there are several "TOC" type classes around the place (such as metadata/toc.py and in oeb/base.py).

Would any of those be appropriate/useful for what I want to do? Basically I want to parse an ncx file, have an ability to remove an item from the TOC based on the @src attribute matching a value and then get the new structure back so I can persist it with the container.set() function.

Any suggestions appreciated.
kiwidude is offline   Reply With Quote