From 2188514cdbaaa841405da6e893ed42956154b282 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 3 May 2015 06:51:59 +0530 Subject: [PATCH] ... --- src/calibre/ebooks/mobi/debug/mobi8.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/mobi/debug/mobi8.py b/src/calibre/ebooks/mobi/debug/mobi8.py index 9098ed81d3..c8bbeb4f89 100644 --- a/src/calibre/ebooks/mobi/debug/mobi8.py +++ b/src/calibre/ebooks/mobi/debug/mobi8.py @@ -125,8 +125,7 @@ class MOBIFile(object): text = self.raw_text self.files = [] for skel in self.skel_index.records: - sects = [x for x in self.sect_index.records if x.file_number - == skel.file_number] + sects = [x for x in self.sect_index.records if x.file_number == skel.file_number] skeleton = text[skel.start_position:skel.start_position+skel.length] ftext = skeleton first_aid = sects[0].toc_text @@ -199,7 +198,10 @@ class MOBIFile(object): prefix, ext = 'hd-images', q resource_index = len(container.resources) elif sig == b'\xa0\xa0\xa0\xa0' and len(payload) == 4: - container.resources.append(None) + if container is None: + print ('Found an end of container record with no container, ignoring') + else: + container.resources.append(None) continue elif sig not in known_types: if container is not None and len(container.resources) == container.num_of_resource_records: