From b19169d1927093c002e82dbd2b2d1db6512e7c95 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 28 Feb 2012 11:21:46 +0530 Subject: [PATCH] EPUB Input: Remove non XML documents from the spine automatically, instead of erroring out --- src/calibre/ebooks/oeb/reader.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/calibre/ebooks/oeb/reader.py b/src/calibre/ebooks/oeb/reader.py index a458df5a83..7cea0ac75c 100644 --- a/src/calibre/ebooks/oeb/reader.py +++ b/src/calibre/ebooks/oeb/reader.py @@ -321,6 +321,12 @@ class OEBReader(object): if len(spine) == 0: raise OEBError("Spine is empty") self._spine_add_extra() + for item in spine: + if item.media_type.lower() not in OEB_DOCS: + if not hasattr(item.data, 'xpath'): + self.oeb.log.warn('The item %s is not an XML document.' + ' Removing it from spine.'%item.href) + spine.remove(item) def _guide_from_opf(self, opf): guide = self.oeb.guide