diff --git a/src/calibre/ebooks/mobi/writer.py b/src/calibre/ebooks/mobi/writer.py index 5bd75d5e9a..04fd835c96 100644 --- a/src/calibre/ebooks/mobi/writer.py +++ b/src/calibre/ebooks/mobi/writer.py @@ -1963,6 +1963,11 @@ class MobiWriter(object): self._oeb.logger.warn(' Ignoring TOC entry with no href:', child.title) continue + if h not in self._id_offsets: + self._oeb.logger.warn(' Ignoring missing TOC entry:', + child) + continue + currentOffset = self._id_offsets[h] # print "_generate_ctoc: child offset: 0x%X" % currentOffset diff --git a/src/calibre/ebooks/oeb/iterator.py b/src/calibre/ebooks/oeb/iterator.py index 2b68b6cf57..03c09262d4 100644 --- a/src/calibre/ebooks/oeb/iterator.py +++ b/src/calibre/ebooks/oeb/iterator.py @@ -41,9 +41,12 @@ class SpineItem(unicode): def __new__(cls, *args): args = list(args) - args[0] = args[0].partition('#')[0] - obj = super(SpineItem, cls).__new__(cls, *args) path = args[0] + ppath = path.partition('#')[0] + if not os.path.exists(path) and os.path.exists(ppath): + path = ppath + args[0] = path + obj = super(SpineItem, cls).__new__(cls, *args) raw = open(path, 'rb').read() raw, obj.encoding = xml_to_unicode(raw) obj.character_count = character_count(raw)