From d34451b6d1bcd27d89c6dcbccadaa3c5bb0c079f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 31 Jan 2011 15:45:17 -0700 Subject: [PATCH] EPUB Input: Filter made media tytpes from the spine, currently only filter Adobe page templates --- src/calibre/ebooks/epub/input.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/calibre/ebooks/epub/input.py b/src/calibre/ebooks/epub/input.py index ec2004d81c..e22ed27371 100644 --- a/src/calibre/ebooks/epub/input.py +++ b/src/calibre/ebooks/epub/input.py @@ -175,6 +175,19 @@ class EPUBInput(InputFormatPlugin): raise ValueError( 'EPUB files with DTBook markup are not supported') + for x in list(opf.iterspine()): + ref = x.get('idref', None) + if ref is None: + x.getparent().remove(x) + continue + for y in opf.itermanifest(): + if y.get('id', None) == ref and y.get('media-type', None) in \ + ('application/vnd.adobe-page-template+xml',): + p = x.getparent() + if p is not None: + p.remove(x) + break + with open('content.opf', 'wb') as nopf: nopf.write(opf.render())