EPUB3 Input: Fix cover image not being correctly detected in EPUB 3 files that use a deprecated <guide> 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)

This commit is contained in:
Kovid Goyal 2018-02-02 08:43:49 +05:30
parent 500a1e00c0
commit fe0e9a18bb
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -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()