Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: decoding with 'hex' codec failed (ValueError: string argument should contain only ASCII characters) #109

Open
FKuerten opened this issue Jul 23, 2022 · 6 comments

Comments

@FKuerten
Copy link

Question / bug report

Trying to import ebup from Tolino, get this exception in console.
I tried to remove personal information from the log, but please advise if I removed too much.
(I have not yet been able to remove any drm yet)

Which version of Calibre are you running?

5.12.0

Which version of the DeDRM plugin are you running?

v10.0.3

If applicable, which version of the Kindle software are you running?

No response

Log output

DeDRM v10.0.3: Trying to decrypt *************.epub
DeDRM v10.0.3: Verifying zip archive integrity
DeDRM v10.0.3: ************.epub is a secure Adobe Adept ePub for UUID *************
Running file type plugin DeDRM failed with traceback:
Traceback (most recent call last):
  File "/usr/lib/python3.9/encodings/hex_codec.py", line 19, in hex_decode
    return (binascii.a2b_hex(input), len(input))
ValueError: string argument should contain only ASCII characters

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/calibre/calibre/customize/ui.py", line 172, in _run_filetype_plugins
    nfp = plugin.run(nfp) or nfp
  File "calibre_plugins.dedrm.__init__", line 1067, in run
    decrypted_ebook = self.ePubDecrypt(path_to_ebook)
  File "calibre_plugins.dedrm.__init__", line 533, in ePubDecrypt
    userkey = codecs.decode(userkeyhex, 'hex')
ValueError: decoding with 'hex' codec failed (ValueError: string argument should contain only ASCII characters)

@ElleKayEm
Copy link

Try going into DeDRM's customization and delete the Adobe Digital Editions key. Then restart calibre and re-add the book to see if ADE can automatically retrieve the correct key.

This is assuming ADE used to download the book is authorized with your Adobe ID and on the same user and machine as calibre with DeDRM.

@andrisengelis
Copy link

@ElleKayEm steps worked for me. I was experiencing the same error but from another epub provider for ADE content. Thanks

@noDRM
Copy link
Owner

noDRM commented Aug 3, 2022

Partially fixed with 9a11f48.

The general issue of a key being corrupted for whatever reason can only be fixed by re-importing (as it was the case here), but the plugin also shouldn't throw an exception and stop trying subsequent keys, this bug is fixed with this commit. With this bug fixed the plugin would probably have attempted to re-import the ADE key automatically.

Closing the issue as it seems to be resolved.

@noDRM noDRM closed this as completed Aug 3, 2022
@notEthan
Copy link

notEthan commented Aug 3, 2022

I am relieved to have found this and fixed the same issue. thanks @ElleKayEm

@noDRM
Copy link
Owner

noDRM commented Aug 14, 2022

Re-opening this issue for now. There seems to be a bug in the plugin that sometimes causes malformed Adobe keys to be written to the config JSON. The fix in 9a11f48 just made it no longer crash when encountering such a malformed key, but the real fix would be not writing malformed keys.

I've received logs (and the malformed key) from one of the affected users so I should be able to test this myself and implement a real fix soon-ish.

@xinluh
Copy link

xinluh commented Aug 26, 2022

I'm getting the same error, except reloading/restarting doesn't solve the problem (the key is still corrupted when I look at the dedrm.json file). Loading the key manually exported by DeACSM plugin worked for me though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants