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

Update kindlekey for Python 3 #1732

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Knio
Copy link

@Knio Knio commented Jun 13, 2021

Because it's 2021. No attempt was made for readability/backwards compatibility/etc, I just wanted to dump my books.

Tested on Windows 10 and it successfully got my keys from Kindle PC 1.17.1

I assume this won't be merged, but maybe someone can use it as a starting point for a real change, or just see this PR and be able to read their books 🤷

Because it's 2021. No attempt was made for readability/backwards compatibility/etc, I just wanted to dump my books.

Tested on Windows 10 and it successfully got my keys from Kindle PC  1.17.1
@ElleKayEm
Copy link

The kindlekey script from the plugin is Python 3.

@ableeker
Copy link
Contributor

This is somewhat confusing, the kindlekey script referred to here isn't the script from the plugin, it's the kindlkey.pyw script from the Other_Tools folder. Note the extra 'w' in the file name, this means it's a python script that won't start a DOS console window. As ElleKayEm has stated quite correctly, the script from the plugin is already Python 3. However, it's also true that this older version of the script in Other_Tools is indeed still Python 2. So we could convert this script to Python 3 as well, but I'm not sure we should. What's the purpose of the scripts from Other_Tools? Are they an archive of an older version? If so, are they meant to be Python 2, and ought to stay as such? Or should they be updated to Python 3 too? That shouldn't even be necessary, because the update already has been done to the plugin script, and updating this script would mean doing the same work again.

I recommend using the plugin, because that's tested, and in the case of 7.2.1, updated to Python 3. Actually, most of the Python scripts can be used in a DOS console. If you're using Python 2, you could use the current version in Other_Tools. And if you're using Python 3, and still want to use a script in a console, you could just use the one from from the plugin (get it from the zip). I've tried it, it works that way. If you don't want to open a DOS console, you could even rename it to kindlekey.pyw first. It works that way too.

@ElleKayEm
Copy link

Presumably the key scripts are just in Other_Tools so you don't have to dig them out from all the other scripts in the plugin if you want to run them on a virtual machine or something. But seems they've been forgotten and not kept in sync with the plugin. If someone wanted the Python 2 versions, they could get them from DeDRM 6.8.1.

@Knio
Copy link
Author

Knio commented Jun 29, 2021

The plugin didn't actually work for me, until I did this and got the key and entered it into the plugin preferences, so I thought this was a separate tool and a extra required step to installing the plugin.

If this is shared code, it should be linked as such properly and not copy pasted like this in a file that will bitrot and confuse people.

@acotor
Copy link

acotor commented Nov 4, 2022

This commit works for me at this moment! Thanks!
Windows 11 with Python 3.9 & old version Kindle PC 1.17.1

@ElleKayEm
Copy link

@acotor Why? Didn't the plugin work on it's own without this extra step?

@acotor
Copy link

acotor commented Nov 4, 2022

@ElleKayEm The plugin supposed to work with this script according to this wiki. To my test, without the key file being configured, the plugin won't remove DRM for *.awz file at adding books from files.

or maybe I'm wrong, since Calibre and Kindle4PC are runing on the same system.

Anyway, I got 'syntax error' after running the latest script. I don't use python often but this commit succeed in getting the key file.

PS C:\proj>  c:; cd 'c:\proj'; & 'C:\Python310\python.exe' 'c:\Users\<user>\.vscode\extensions\ms-python.python-2022.16.1\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '7967' '--' 'c:\proj\kindlekey.pyw'
  File "c:\proj\kindlekey.pyw", line 292
    raise DecryptNotBlockAlignedError, 'Data not block aligned on decrypt'
                                     ^
SyntaxError: invalid syntax

@ElleKayEm
Copy link

That wiki along with this whole repo is no longer maintained. As mentioned above, the scripts in the Other_Tools folder here are old Python 2 ones. If for whatever reason, you need to run the key script on its own, you can use the one from inside the plugin. The latest DeDRM plugin is available from this repo: https://github.com/noDRM/DeDRM_tools

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

Successfully merging this pull request may close these issues.

4 participants