Connoisseur
Posts: 94
Karma: 10
Join Date: Feb 2014
Location: Japan
Device: Kindle PaperWhite, Kobo Aura HD
|
Hi Kevin,
These are errors of the latest nlb code.
1. test1.azw3 with python 3 (fixed):
Spoiler:
Unpacking raw markup language
Traceback (most recent call last):
File "kindleunpack.py", line 1016, in <module>
sys.exit(main())
File "kindleunpack.py", line 1004, in main
unpackBook(infile, outdir, apnxfile, epubver, use_hd)
File "kindleunpack.py", line 918, in unpackBook
process_all_mobi_headers(files, apnxfile, sect, mhlst, K8Boundary, False, ep
ubver, use_hd)
File "kindleunpack.py", line 835, in process_all_mobi_headers
processMobi8(mh, metadata, sect, files, imgnames, pagemapproc, k8resc, obfus
cate_data, apnxfile, epubver)
File "kindleunpack.py", line 493, in processMobi8
linktgt += '#' + idtext
TypeError: Can't convert 'bytes' object to str implicitly
2. test1.azw3 with python 3:
Spoiler:
Traceback (most recent call last):
File "kindleunpack.py", line 1016, in <module>
sys.exit(main())
File "kindleunpack.py", line 1004, in main
unpackBook(infile, outdir, apnxfile, epubver, use_hd)
File "kindleunpack.py", line 918, in unpackBook
process_all_mobi_headers(files, apnxfile, sect, mhlst, K8Boundary, False, ep
ubver, use_hd)
File "kindleunpack.py", line 835, in process_all_mobi_headers
processMobi8(mh, metadata, sect, files, imgnames, pagemapproc, k8resc, obfus
cate_data, apnxfile, epubver)
File "kindleunpack.py", line 531, in processMobi8
usedmap = htmlproc.buildXHTML()
File "mobi_html.py", line 337, in bu
ildXHTML
replacement = b'"../' + utf8_str(pdir) + b'/' + utf8_str(fnm) + b'"'
TypeError: can't concat bytes to NoneType
3. test5.azw3
with python3:
Spoiler:
Unpacking raw markup language
Processing ncx / toc
Building an epub-like structure
Building proper xhtml for each file
Traceback (most recent call last):
File "kindleunpack.py", line 1016, in <module>
sys.exit(main())
File "kindleunpack.py", line 1004, in main
unpackBook(infile, outdir, apnxfile, epubver, use_hd)
File "kindleunpack.py", line 918, in unpackBook
process_all_mobi_headers(files, apnxfile, sect, mhlst, K8Boundary, False, ep
ubver, use_hd)
File "kindleunpack.py", line 835, in process_all_mobi_headers
processMobi8(mh, metadata, sect, files, imgnames, pagemapproc, k8resc, obfus
cate_data, apnxfile, epubver)
File "kindleunpack.py", line 531, in processMobi8
usedmap = htmlproc.buildXHTML()
File "\mobi_html.py", line 281, in bu
ildXHTML
replacement = b'"../' + pdir + b'/' + fnm + b'"'
TypeError: can't concat bytes to str
python 2:
Spoiler:
Unpacking raw markup language
Processing ncx / toc
Building an epub-like structure
Building proper xhtml for each file
Error: 'ascii' codec can't decode byte 0xe3 in position 79: ordinal not in range
(128)
Traceback (most recent call last):
File "kindleunpack.py", line 1004, in main
unpackBook(infile, outdir, apnxfile, epubver, use_hd)
File "kindleunpack.py", line 918, in unpackBook
process_all_mobi_headers(files, apnxfile, sect, mhlst, K8Boundary, False, ep
ubver, use_hd)
File "kindleunpack.py", line 835, in process_all_mobi_headers
processMobi8(mh, metadata, sect, files, imgnames, pagemapproc, k8resc, obfus
cate_data, apnxfile, epubver)
File "kindleunpack.py", line 531, in processMobi8
usedmap = htmlproc.buildXHTML()
File "mobi_html.py", line 286, in bu
ildXHTML
flowpart = b"".join(srcpieces)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 79: ordinal
not in range(128)
4. test2.azw3 with python 3(fixed):
Spoiler:
Unpacking raw markup language
Processing ncx / toc
Building an epub-like structure
Building proper xhtml for each file
Traceback (most recent call last):
File "kindleunpack.py", line 1016, in <module>
sys.exit(main())
File "kindleunpack.py", line 1004, in main
unpackBook(infile, outdir, apnxfile, epubver, use_hd)
File "kindleunpack.py", line 918, in unpackBook
process_all_mobi_headers(files, apnxfile, sect, mhlst, K8Boundary, False, ep
ubver, use_hd)
File "kindleunpack.py", line 835, in process_all_mobi_headers
processMobi8(mh, metadata, sect, files, imgnames, pagemapproc, k8resc, obfus
cate_data, apnxfile, epubver)
File "kindleunpack.py", line 557, in processMobi8
guidetext += cover.guide_toxml()
TypeError: Can't convert 'bytes' object to str implicitly
I have modied to intent to fix case 1 and 4.
Followings is the patch.
Spoiler:
diff -u nlib_3/kindleunpack.py nlib/kindleunpack.py
--- nlib_3/kindleunpack.py Wed Oct 8 18:37:26 2014
+++ nlib/kindleunpack.py Thu Oct 9 19:07:33 2014
@@ -473,7 +473,7 @@
k8proc.buildParts(rawML)
# collect information for the guide first
- guidetext = k8proc.getGuideText()
+ guidetext = unicode_str(k8proc.getGuideText())
# if the guide was empty, add in any guide info from metadata, such as StartOffset
if not guidetext and 'StartOffset' in metadata:
@@ -488,9 +488,9 @@
last_start = 0
seq, idtext = k8proc.getFragTblInfo(last_start)
filename, idtext = k8proc.getIDTagByPosFid(toBase32(seq), b'0000000000')
- linktgt = filename
- if idtext != '':
- linktgt += '#' + idtext
+ linktgt = unicode_str(filename)
+ if unicode_str(idtext) != '':
+ linktgt += '#' + unicode_str(idtext)
guidetext += '<reference type="text" href="Text/%s" />\n' % linktgt
# if apnxfile is passed in use it for page map information
diff -u nlib_3/mobi_cover.py nlib/mobi_cover.py
--- nlib_3/mobi_cover.py Wed Oct 8 18:37:26 2014
+++ nlib/mobi_cover.py Thu Oct 9 19:49:40 2014
@@ -233,4 +233,4 @@
text_dir = os.path.relpath(files.k8text, files.k8oebps)
data = '<reference type="cover" title="Cover" href="{:s}/{:s}" />\n'.format(\
text_dir, self.cover_page)
- return data.encode('utf-8')
+ return data #.encode('utf-8') Changed to unicode
diff -u nlib_3/mobi_k8proc.py nlib/mobi_k8proc.py
--- nlib_3/mobi_k8proc.py Wed Oct 8 18:37:26 2014
+++ nlib/mobi_k8proc.py Thu Oct 9 19:25:45 2014
@@ -246,7 +246,7 @@
m = re.search(svg_tag_pattern, flowpart)
if m is not None:
# svg
- type = b'svg'
+ type = 'svg'
start = m.start()
m2 = re.search(image_tag_pattern, flowpart)
if m2 is not None:
Take care,
|