From 0f56822a070007ffdd5abeb140e81fe7759705b1 Mon Sep 17 00:00:00 2001 From: "Marshall T. Vandegrift" Date: Mon, 19 Jan 2009 20:54:34 -0500 Subject: [PATCH] Fix #1652: - Ignore duplicate entries and attempt to continue. --- src/calibre/ebooks/oeb/base.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index 892d7c507e..ac6fb1e5dd 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -803,12 +803,20 @@ class OEBBook(object): def _manifest_from_opf(self, opf): self.manifest = manifest = Manifest(self) for elem in xpath(opf, '/o2:package/o2:manifest/o2:item'): + id = elem.get('id') href = elem.get('href') + media_type = elem.get('media-type') + fallback = elem.get('fallback') + if href in manifest.hrefs: + self.logger.warn(u'Duplicate manifest entry for %r.' % href) + continue if not self.container.exists(href): self.logger.warn(u'Manifest item %r not found.' % href) continue - manifest.add(elem.get('id'), href, elem.get('media-type'), - elem.get('fallback')) + if id in manifest.ids: + self.logger.warn(u'Duplicate manifest id %r.' % id) + id, href = manifest.generate(id, href) + manifest.add(id, href, media_type, fallback) def _spine_from_opf(self, opf): self.spine = spine = Spine(self)