kevinhendricks / KindleUnpack

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

Issues Unpacking .azw4 in Calibre #13

Closed nix416 closed 7 years ago

nix416 commented 8 years ago

Hello,

I am having issues unpacking an .azw4 ebook.

I know the ebook was deDRM'd as the Calibre debug log stated it was successful. I am unable to unpack in Calibre, receiving almost the same memory message as the other user:

calibre, version 2.65.1 ERROR: KindleUnpack - The Plugin v0.81.2:

Traceback (most recent call last): File "calibre_plugins.kindleunpack_plugin.action", line 267, in unpack_ebook File "calibre_plugins.kindleunpack_plugin.mobi_stuff", line 123, in unpackMOBI File "calibre_plugins.kindleunpack_plugin.kindleunpack.kindleunpack", line 869, in unpackBook File "calibre_plugins.kindleunpack_plugin.kindleunpack.mobi_sectioner", line 50, in init MemoryError

Following your advice on helping the other user, I downloaded Python 64 and the standalone Unpacker, but get this message:

Conversion Log

Input Path = "C:\Users\416\Documents\Calibre Library\Peter Raven\Biology, 10E, With Access Code For C (15)\Biology, 10E, With Access Code - Peter Raven.azw4" Output Path = "C:\Users\416\Desktop\Calibre Decrypted\New folder" WriteRawML = True Epub Output Type Set To: Auto-detect Use HD Images If Present = True

Please Wait ...

Error: Unpacking Failed

Here is the debug log from Calibre:

calibre Debug log calibre 2.65.1 embedded-python: True is64bit: False Windows-8-6.2.9200 Windows ('32bit', 'WindowsPE') 32bit process running on 64bit windows ('Windows', '8', '6.2.9200') Python 2.7.9 Windows: ('8', '6.2.9200', '', 'Multiprocessor Free') Successfully initialized third party plugins: DeDRM (6, 5, 1) && KindleUnpack - The Plugin (0, 81, 2) Starting up... Started up in 7.36 seconds with 3 books stdout+stderr from file dialog helper: ['', ''] piped data from file dialog helper: ['\x02A\xce\x19\xa5\x8a\xa7^\x9b\x8d\x9f>tp\x14s\xb6a\xbb\x9e\xb5n\xa1Cz\xcb\xc8\xc3>\x8de\x8b', 'C:\Users\416\Documents\My Kindle Content\B00WN44PZM_EBOK.azw4'] DeDRM v6.5.1: Trying to decrypt B00WN44PZM_EBOK.azw4 Using Library AlfCrypto DLL/DYLIB/SO MobiDeDrm v0.41. Copyright © 2008-2012 The Dark Reverser et al. MOBI header version 4, header length 248 Decrypting Mobipocket 4 ebook: Biology, 10E, With Access Code For Connect Plus Found 4 keys to try after 1.0 seconds Crypto Type is: 2 File is encoded with PID xCy04K2pVR. Decrypting. Please wait . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . done Decryption succeeded after 16.9 seconds DeDRM v6.5.1: Finished after 17.6 seconds Added Biology, 10E, With Access Code For Connect Plus to db in: 0.5 Added 1 books in 18.7 seconds

Any insight you could offer would be greatly appreciated.

Thank you,

nix416

dougmassay commented 8 years ago

Make sure the stand-alone KindleUnpack can successfully unpack ANY (none azw4) KindleBooks first; Just to rule out any config problems.

I would then try to drastically simplify the input path: something like "c:\book.azw4".

Also try bypassing the gui and running kindleunpack directly from the command line, if possible. You might at least get some better output to interpret that way.

kevinhendricks commented 8 years ago

Yes, that kindleunpack error means an exception was thrown and caught (posiibly the same memory error if you the total amount of memory in the machine is unchanged. Hopefully the command line version will give a better error message.

nix416 commented 8 years ago

Thank you very much for your help, gentlemen.

It looks like there might be a config issue as the standalone was unable to unpack a .azw3 file.

I also did simplify the path and put both my test .azw3 file and my newly shortened priority .azw4 directly into the C:\ directory.

Unfortunately, I am not a coder like you guys and I am having some issues using the command line. I shift + right click to open a CL in the LIB folder where the kindleunpack file is located. When I run the command given:

python kindleunpack.py [-r -s -d -h -i] INPUT_FILE OUTPUT_FOLDER

I receive this error:

C:\Users\416\Downloads\KindleUnpack-080\KindleUnpack-080\lib>python kindleunpack.py [-r -s -d -h -i] C:\BIO.azw4 C:\ KindleUnpack v0.80 Traceback (most recent call last): File "kindleunpack.py", line 1016, in sys.exit(main()) File "kindleunpack.py", line 951, in main print(" Based on initial mobipocket version Copyright \xa9 2009 Charles M. Hannum root@ihack.net") File "C:\Users\416\AppData\Local\Programs\Python\Python35\lib\encodings\cp437.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\xa9' in position 49: character maps to

Any additional guidance you guys have would be GREATLY appreciated. Thanks gents, have a good day.

kevinhendricks commented 8 years ago

That error is a unicode decode error. Please try running kindleunpack with Python 3 (3.5 is the latest) not Python 2.7 as it defaults to thinking strings are ascii encoded even through the code is utf-8 encoded.

Kevin

On Aug 28, 2016, at 2:43 PM, nix416 notifications@github.com wrote:

Thank you very much for your help, gentlemen.

It looks like there might be a config issue as the standalone was unable to unpack a .azw3 file.

I also did simplify the path and put both my test .azw3 file and my newly shortened priority .azw4 directly into the C:\ directory.

Unfortunately, I am not a coder like you guys and I am having some issues using the command line. I shift + right click to open a CL in the LIB folder where the kindleunpack file is located. When I run the command given:

python kindleunpack.py [-r -s -d -h -i] INPUT_FILE OUTPUT_FOLDER

I receive this error:

C:\Users\416\Downloads\KindleUnpack-080\KindleUnpack-080\lib>python kindleunpack.py [-r -s -d -h -i] C:\BIO.azw4 C:\ KindleUnpack v0.80 Traceback (most recent call last): File "kindleunpack.py", line 1016, in sys.exit(main()) File "kindleunpack.py", line 951, in main print(" Based on initial mobipocket version Copyright \xa9 2009 Charles M. Hannum root@ihack.net") File "C:\Users\416\AppData\Local\Programs\Python\Python35\lib\encodings\cp437.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\xa9' in position 49: character maps to

Any additional guidance you guys have would be GREATLY appreciated. Thanks gents, have a good day.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

dougmassay commented 8 years ago

I think he did use Python 3 (according to the error message, anyway).

pdurrant commented 8 years ago

I think this is a problem with his machine's default character set. My guess is that his machine's default charcater set is one that doesn't contain the copyright character and so the print command can't convert the unicode character to a display character.

dougmassay commented 8 years ago

What would be your suggestion, Paul? I don't really feel comfortable advising someone to alter their default character set, so I'd be tempted to have @nix416 carefully remove the copyright symbols from lines 951 & 952 of the lib/kindleunpack.py file and see what happens (probably even suggest using the gui again).

It may barf again, though, if some special characters from the book's metadata try to get printed. But it might be worth a shot. There's been some changes to mobi_header and mobi_opf since the last release to hopefully handle encoding issues more robustly, but they wouldn't help this particular issue.

nix416 commented 8 years ago

That is correct, gentlemen, I did actually use the latest stable version, Python 3.5.

The least I can say is thank you very much, the three of you for trying. I will be making a donation later this week.

Of course, I would also be grateful for any additional guidance.

Thanks,

nix416

dougmassay commented 8 years ago

I would try removing the copyright symbols from the two lines I mentioned above in the lib/kindleunpack.py file and see if it makes a difference. Let me know if you need more specific directions than that. I'm talking about opening the file in some sort of text editor and deleting just those two characters from line 951, 952.

You're running Windows 8 (or 8.1), right?

We probably need to make sure that missing characters from console fonts won't trip up kindleunpack.py's output (like we've done with the metadata contents in other files).

nix416 commented 8 years ago

Doug,

Which specific characters are we talking about that need deleted? I have opened the file in notepad but am unable to distinguish line numbers.

I am running Windows 10.

Thanks,

nix416

dougmassay commented 8 years ago

Sorry I didn't respond to this sooner, but it's the copyright symbol. The little "c" with a circle around it. It appears in two consecutive lines near the end of the file.

print(" Based on initial mobipocket version Copyright © 2009 Charles M. Hannum <root@ihack.net>")

print(" Extensive Extensions and Improvements Copyright © 2009-2014 ")

kevinhendricks commented 7 years ago

Closing this issue as inactive, can not recreate. @nix416 please re-open this issue if you have additional information.