From c4ed54aaf133b03eecb0207419630084174fefe5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 16 Mar 2012 09:02:18 +0530 Subject: [PATCH] ... --- src/calibre/ebooks/mobi/debug.py | 28 +++++++++++++++++++++++-- src/calibre/ebooks/mobi/reader/index.py | 8 ++++--- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/calibre/ebooks/mobi/debug.py b/src/calibre/ebooks/mobi/debug.py index b03448a63b..5d3c73518c 100644 --- a/src/calibre/ebooks/mobi/debug.py +++ b/src/calibre/ebooks/mobi/debug.py @@ -652,9 +652,26 @@ class Tag(object): # {{{ INTERPRET_MAP = { 'subchapter': { - 21 : ('Parent chapter index', 'parent_index') + 21 : ('Parent chapter index', 'parent_index'), + 5 : ('Unknown (koffs)', 'koffs'), }, + 'section' : { + 6 : ('File Index', 'pos_fid'), + }, + + 'section_with_subsections' : { + 6 : ('File Index', 'pos_fid'), + 22 : ('First subsection index', 'first_child_index'), + 23 : ('Last subsection index', 'last_child_index'), + + }, + 'subsection' : { + 6 : ('File Index', 'pos_fid'), + 21 : ('Parent section index', 'parent_index'), + }, + + 'article' : { 5 : ('Class offset in cncx', 'class_offset'), 21 : ('Parent section index', 'parent_index'), @@ -707,13 +724,17 @@ class Tag(object): # {{{ try: self.desc, self.attr = td[tag_type] except: - print ('Unknown tag value: %d'%tag_type) + print ('Unknown tag value: %d in entry type: %s'%(tag_type, + entry_type)) self.desc = '??Unknown (tag value: %d type: %s)'%( tag_type, entry_type) self.attr = 'unknown' if '_offset' in self.attr: self.cncx_value = cncx[self.value] + if self.attr == 'pos_fid': + print (1111111, vals) + def __str__(self): if self.cncx_value is not None: return '%s : %r [%r]'%(self.desc, self.value, self.cncx_value) @@ -738,6 +759,9 @@ class IndexEntry(object): # {{{ 0x0f : 'chapter', 0x6f : 'chapter_with_subchapters', 0x1f : 'subchapter', + 0x8f : 'section', + 0xef : 'section_with_subsections', + 0x9f : 'subsection', # Present in periodicals 0xdf : 'periodical', 0xff : 'section', diff --git a/src/calibre/ebooks/mobi/reader/index.py b/src/calibre/ebooks/mobi/reader/index.py index 41177873b7..b292d55c13 100644 --- a/src/calibre/ebooks/mobi/reader/index.py +++ b/src/calibre/ebooks/mobi/reader/index.py @@ -105,9 +105,11 @@ def get_tag_map(control_byte_count, tags, data, start, end): if value != 0: if value == mask: if count_set_bits(mask) > 1: - # If all bits of masked value are set and the mask has more than one bit, a variable width value - # will follow after the control bytes which defines the length of bytes (NOT the value count!) - # which will contain the corresponding variable width values. + # If all bits of masked value are set and the mask has more + # than one bit, a variable width value will follow after + # the control bytes which defines the length of bytes (NOT + # the value count!) which will contain the corresponding + # variable width values. value, consumed = decint(data[data_start:]) data_start += consumed ptags.append((tag, None, value, values_per_entry))