Hi DiapDealer,
Yes, this is a bug. It only happens using the Furigana related Exth values that are only generated by Japanese versions of kindlegen. The bug in this case only happens when the book is an epub 2 book, and not an epub 3. I would guess we have never tested this case before ;-).
We should check if the key is in the metadata under epub 2 just like we do when it is an epub3.
Here is the original problem code in mobi_opf.py (starting at line 605)
Code:
if create_refines_metadata:
for [EXTH, id, attrib, defaultid] in refines_list:
if self.target_epubver == '3':
for i, value in id.items():
attrib[i] = ' id="%s"' % value
if EXTH in metadata.keys():
if len(metadata[EXTH]) == 1 and len(id) == 1:
self.createMetaTag(self.exth_solved_refines_metadata, 'file-as', metadata[EXTH][0], id[0])
else:
for i, value in enumerate(metadata[EXTH]):
self.createMetaTag(self.exth_refines_metadata, 'file-as', value, id.get(i, defaultid))
else:
if len(metadata[EXTH]) == 1 and len(id) == 1:
attr = ' opf:file-as="%s"' % metadata[EXTH][0]
attrib[0] = attr
else:
for i, value in enumerate(metadata[EXTH]):
attr = ' id="#%s" opf:file-as="%s"\n' % (id.get(i, defaultid), value)
self.extra_attributes.append(attr)
It should instead look like the following to at least prevent the KeyError (in other words - to make the else clause mirror the if-then when it comes to Key checking:
Code:
if create_refines_metadata:
for [EXTH, id, attrib, defaultid] in refines_list:
if self.target_epubver == '3':
for i, value in id.items():
attrib[i] = ' id="%s"' % value
if EXTH in metadata.keys():
if len(metadata[EXTH]) == 1 and len(id) == 1:
self.createMetaTag(self.exth_solved_refines_metadata, 'file-as', metadata[EXTH][0], id[0])
else:
for i, value in enumerate(metadata[EXTH]):
self.createMetaTag(self.exth_refines_metadata, 'file-as', value, id.get(i, defaultid))
else:
if EXTH in metadata.keys():
if len(metadata[EXTH]) == 1 and len(id) == 1:
attr = ' opf:file-as="%s"' % metadata[EXTH][0]
attrib[0] = attr
else:
for i, value in enumerate(metadata[EXTH]):
attr = ' id="#%s" opf:file-as="%s"\n' % (id.get(i, defaultid), value)
self.extra_attributes.append(attr)
Please ask the reporter to give that change a try. If it works, I will commit it to the tree and its equivalent to the python2and3 branch as well.
Hope this does the trick.
KevinH