From f49cbe24897cf6fb2a2a2c295c03c181f783bf99 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 18 Apr 2014 17:21:31 +0530 Subject: [PATCH] EPUB Input: Ignore guide element marking the first spine item as a cover if the spine contains only a single item --- src/calibre/ebooks/conversion/plugins/epub_input.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/conversion/plugins/epub_input.py b/src/calibre/ebooks/conversion/plugins/epub_input.py index b40f76a78e..50bb8f1a6d 100644 --- a/src/calibre/ebooks/conversion/plugins/epub_input.py +++ b/src/calibre/ebooks/conversion/plugins/epub_input.py @@ -105,8 +105,15 @@ class EPUBInput(InputFormatPlugin): # Remove from spine as covers must be treated # specially if not self.for_viewer: - spine[0].getparent().remove(spine[0]) - removed = guide_cover + if len(spine) == 1: + log.warn('There is only a single spine item and it is marked as the cover. Removing cover marking.') + for guide_elem in tuple(opf.iterguide()): + if guide_elem.get('type', '').lower() == 'cover': + guide_elem.getparent().remove(guide_elem) + return + else: + spine[0].getparent().remove(spine[0]) + removed = guide_cover else: # Ensure the cover is displayed as the first item in the book, some # epub files have it set with linear='no' which causes the cover to