diff --git a/src/calibre/customize/conversion.py b/src/calibre/customize/conversion.py index 4f2b279f85..273bb9ebf7 100644 --- a/src/calibre/customize/conversion.py +++ b/src/calibre/customize/conversion.py @@ -109,6 +109,10 @@ class InputFormatPlugin(Plugin): #: convenience method, :method:`get_image_collection`. is_image_collection = False + #: If set to True, the input plugin will perform special processing + #: to make its output suitable for viewing + for_viewer = False + #: Options shared by all Input format plugins. Do not override #: in sub-classes. Use :member:`options` instead. Every option must be an #: instance of :class:`OptionRecommendation`. diff --git a/src/calibre/ebooks/epub/input.py b/src/calibre/ebooks/epub/input.py index 3f8b563d96..fd1e4733e1 100644 --- a/src/calibre/ebooks/epub/input.py +++ b/src/calibre/ebooks/epub/input.py @@ -53,7 +53,6 @@ class EPUBInput(InputFormatPlugin): traceback.print_exc() return False - @classmethod def rationalize_cover(self, opf, log): guide_cover, guide_elem = None, None for guide_elem in opf.iterguide(): @@ -78,7 +77,8 @@ class EPUBInput(InputFormatPlugin): # Remove from spine as covers must be treated # specially - spine[0].getparent().remove(spine[0]) + if not self.for_viewer: + spine[0].getparent().remove(spine[0]) guide_elem.set('href', 'calibre_raster_cover.jpg') from calibre.ebooks.oeb.base import OPF t = etree.SubElement(elem[0].getparent(), OPF('item'), diff --git a/src/calibre/ebooks/oeb/iterator.py b/src/calibre/ebooks/oeb/iterator.py index 4910bf4e10..9b9158b37e 100644 --- a/src/calibre/ebooks/oeb/iterator.py +++ b/src/calibre/ebooks/oeb/iterator.py @@ -134,6 +134,7 @@ class EbookIterator(object): if hasattr(plumber.opts, 'no_process'): plumber.opts.no_process = True + plumber.input_plugin.for_viewer = True self.pathtoopf = plumber.input_plugin(open(plumber.input, 'rb'), plumber.opts, plumber.input_fmt, self.log, {}, self.base)