Hi Nick,
Great catch! We currently do not make use of the othtbl (guide?) elements. That said, it is nasty they changed the tag keys on us.
Exactly which version of kindlegen are you using? Mine reports:
./kindlegen
**************************************************
* Amazon.com kindlegen(MAC OSX) V2.3 build 36043 *
* A command line e-book compiler *
* Copyright Amazon.com 2011 *
************************************************** *
Are you using an earlier or later version? Were these guide elements in the original? If the same version, perhaps we simply have to support both tags and that they indicate something slightly different.
I will change the code to support either for the moment until we learn more.
Quote:
Originally Posted by nickredding
Using the latest to unpack a KF8 generated by kindlegen from an OEB generated by calibre, I get a trap in mobi_k8proc.py/K8processor
Code:
# read / process other index, looks like a partial <guide> of <toc> but not too sure.
# Not being used yet
othtbl = []
if self.othidx != 0xffffffff:
outtbl, ctoc_text = self.mi.getIndexData(self.othidx)
for [text, tagMap] in outtbl:
# text, ctoc text, file num
ctocoffset = tagMap[1][0]
ctocdata = ctoc_text[ctocoffset]
othtbl.append([text, ctocdata, tagMap[6][0]])
self.othtbl = othtbl
That tagMap doesn't have a key 6. Upon investigation it looks like the tagMap key is 3 as in
Code:
# read / process other index, looks like a partial <guide> of <toc> but not too sure.
# Not being used yet
# KF8: tagMap[6] key error, think it's tagMap[3]
othtbl = []
if self.othidx != 0xffffffff:
outtbl, ctoc_text = self.mi.getIndexData(self.othidx)
for [text, tagMap] in outtbl:
# text, ctoc text, file num
ctocoffset = tagMap[1][0]
ctocdata = ctoc_text[ctocoffset]
othtbl.append([text, ctocdata, tagMap[3][0]])
## othtbl.append([text, ctocdata, tagMap[6][0]])
self.othtbl = othtbl
which works because the info in question is the masthead coordinates. Following is the console output from the corrected code
Code:
0 Masthead Image
name length is 9
15 image/jpg
IndexCount is 1
TagTable: [(1, 1, 1, 0), (2, 1, 2, 0), (3, 1, 4, 0), (0, 0, 0, 1)]
parsed INDX header:
len C0 nul1 0 type 1 gen 0 start D0 count 1 code FFFFFFFF lng FFFFFFFF total 0 ordt 0 ligt 0 nligt 0 nctoc 0
208 1
>>tagMap
{1: [0], 2: [1], 3: [15]}
masthead
other table: text_type, ctoc data, file number
[['masthead', 'Masthead Image', 15]]
I added the >>tagMap dump investigating this.
|