From d2ed3045df0fab50623dc8f4cf28ebc5dfe39340 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 5 Dec 2019 18:18:05 +0530 Subject: [PATCH] Ignore empty/missing media-types in manifest --- src/calibre/ebooks/oeb/polish/container.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/oeb/polish/container.py b/src/calibre/ebooks/oeb/polish/container.py index fffcd93603..4c17fb0902 100644 --- a/src/calibre/ebooks/oeb/polish/container.py +++ b/src/calibre/ebooks/oeb/polish/container.py @@ -300,9 +300,10 @@ class Container(ContainerBase): # {{{ for item in self.opf_xpath('//opf:manifest/opf:item[@href and @media-type]'): href = item.get('href') name = self.href_to_name(href, self.opf_name) - if name in self.mime_map and name != self.opf_name: + mt = item.get('media-type') + if name in self.mime_map and name != self.opf_name and mt: # some epubs include the opf in the manifest with an incorrect mime type - self.mime_map[name] = item.get('media-type') + self.mime_map[name] = mt def data_for_clone(self, dest_dir=None): dest_dir = dest_dir or self.root