From fe0e9a18bb7b43c2b87ff848e5a3bad5349d30f8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 2 Feb 2018 08:43:49 +0530 Subject: [PATCH] EPUB3 Input: Fix cover image not being correctly detected in EPUB 3 files that use a deprecated element that incorrectly identifies the titlepage as the cover. Fixes #1746794 [EPUB -> MOBI conversion removes entire frontmatter, and also drops cover image](https://bugs.launchpad.net/calibre/+bug/1746794) --- src/calibre/ebooks/conversion/plugins/epub_input.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/conversion/plugins/epub_input.py b/src/calibre/ebooks/conversion/plugins/epub_input.py index b6f857ef1f..46a3c11387 100644 --- a/src/calibre/ebooks/conversion/plugins/epub_input.py +++ b/src/calibre/ebooks/conversion/plugins/epub_input.py @@ -80,14 +80,14 @@ class EPUBInput(InputFormatPlugin): return False def set_guide_type(self, opf, gtype, href=None, title=''): - # Set the titlepage guide entry + # Set the specified guide entry for elem in list(opf.iterguide()): - if elem.get('type', '').lower() == 'titlepage': + if elem.get('type', '').lower() == gtype: elem.getparent().remove(elem) if href is not None: t = opf.create_guide_item(gtype, title, href) - for guide in opf.root.iterchildren('guide'): + for guide in opf.root.xpath('./*[local-name()="guide"]'): guide.append(t) return guide = opf.create_guide_element()