kevinhendricks / KindleUnpack

python based software to unpack Amazon / Kindlegen generated ebooks
GNU General Public License v3.0
978 stars 105 forks source link

except error: Processing ncx / toc #28

Open duzhor opened 5 years ago

duzhor commented 5 years ago

chcp 65001 > nul python kindleunpack.py --epub_version=3 E:\Downloads\files.azw3 E:\Downloads\tmp

KindleUnpack v0.80 Based on initial mobipocket version Copyright © 2009 Charles M. Hannum root@ihack.net Extensive Extensions and Improvements Copyright © 2009-2014 by: P. Durrant, K. Hendricks, S. Siebert, fandrieu, DiapDealer, nickredding, tkeo. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3. Unpacking Book... Palm DB type: BOOKMOBI, 13727 sections. Warning: Bad key, size, value combination detected in EXTH 406 16 0000000000000000 Unpacking a KF8 book... Processing K8 section of book... Mobi Version: 8 Codec: utf-8 Title: 中国古典文学荟萃(全36册) EXTH Title: 中国古典文学荟萃【全36册】(精选先秦以来的优秀文学作品,涵盖诗、词、曲、小说、戏剧、随笔等体裁,权威版本,名家译注,文学爱好者案头必备丛书) Palmdoc compression Unpacking images, resources, fonts, etc Extracting image: image11510.jpeg from section 11510 Extracting image: image11511.jpeg from section 11511 Extracting image: image11512.jpeg from section 11512 ...... Extracting image: image13504.gif from section 13504 Extracting image: image13505.gif from section 13505 Extracting image: image13507.jpeg from section 13507 Warning: Section 13509 does not contain a recognised resource Warning: Section 13510 does not contain a recognised resource Warning: Section 13511 does not contain a recognised resource ...... Warning: Section 13710 does not contain a recognised resource Warning: Section 13711 does not contain a recognised resource Warning: Section 13712 does not contain a recognised resource Unpacking raw markup language Processing ncx / toc Traceback (most recent call last): File "kindleunpack.py", line 1016, in sys.exit(main()) File "kindleunpack.py", line 1004, in main unpackBook(infile, outdir, apnxfile, epubver, use_hd) File "kindleunpack.py", line 919, in unpackBook process_all_mobi_headers(files, apnxfile, sect, mhlst, K8Boundary, False, epubver, use_hd) File "kindleunpack.py", line 836, in process_all_mobi_headers processMobi8(mh, metadata, sect, files, rscnames, pagemapproc, k8resc, obfuscate_data, apnxfile, epubver) File "kindleunpack.py", line 522, in processMobi8 ncx_data = ncx.parseNCX() File ".\mobi_ncx.py", line 45, in parseNCX outtbl, ctoc_text = self.mi.getIndexData(self.ncxidx, "NCX") File ".\mobi_index.py", line 38, in getIndexData ctocdict = self.readCTOC(cdata) File ".\mobi_index.py", line 131, in readCTOC pos, ilen = getVariableWidthValue(txtdata, offset) File ".\mobi_index.py", line 157, in getVariableWidthValue if ord(v) & 0x80: TypeError: ord() expected a character, but string of length 0 found

duzhor commented 5 years ago

This azw3 file from amazon kindle ebook, only through nodrm.

duzhor commented 5 years ago

--epub_version use 2, 3, A, F, same error.

duzhor commented 5 years ago

DEBUG=True Traceback: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128)

kevinhendricks commented 5 years ago

There should be no "ascii-codec" being used anymore. So do you get the same error running kindleunpack with python3 instead of python 2.X?

duzhor commented 5 years ago

There should be no "ascii-codec" being used anymore. So do you get the same error running kindleunpack with python3 instead of python 2.X?

I tested nearly 100 different .azw3 files. Only one of them has this error message. I am sure that this file is only processed by nodrm and can be used normally by sending it to Kindle via USB. Both python2 and python3, the same error.

duzhor commented 5 years ago

There should be no "ascii-codec" being used anymore. So do you get the same error running kindleunpack with python3 instead of python 2.X?

I tested nearly 100 different .azw3 files. Only one of them has this error message. I am sure that this file is only processed by nodrm and can be used normally by sending it to Kindle via USB. Both python2 and python3, the same error.

There should be no "ascii-codec" being used anymore. So do you get the same error running kindleunpack with python3 instead of python 2.X?

I don't know if I can share this file. https://drive.google.com/open?id=1mDUWyRguVcVTjkbItxf-tDwVCrjGMu_e

duzhor commented 5 years ago

This is bat script what I use. md "%~dp1%~n1" && cd /d "%~dp1" chcp 65001 && D:\Develop\Python36\python.exe "%~dp0lib\KindleUnpack\kindleunpack.py" --epub_version=3 %* "%~dp1%~n1\source"