apprenticeharper / DeDRM_tools

DeDRM tools for ebooks
14.56k stars 1.52k forks source link

Calibre plugin on Linux fails to find python.exe #720

Open sorsasampo opened 5 years ago

sorsasampo commented 5 years ago

winetricks python26 by defaults installs python.exe to C:\python26\python.exe.

However, DeDRM runs it without path:

DeDRM v6.6.1: Command line: 'WINEPREFIX="/prefix/adobe-digital-editions-2.0" wine python.exe "/home/user/.config/calibre/plugins/DeDRM/libraryfiles/adobekey.py" "/home/user/.config/calibre/plugins/DeDRM/libraryfiles/winekeysdir"'
...
wine: cannot find L"C:\\windows\\system32\\python.exe"

This should be easy to to fix, by setting WINEPATH to contain all usual directories where python.exe is installed. For example:

export WINEPATH='C:\python26;C:\windows\system32'
wine python.exe

BTW, there is now a Lutris installer script for ADE 2.0.1: https://lutris.net/games/adobe-digital-editions/

dakeryas commented 5 years ago

Hello there,

I have tried editing the wineutils.py code of the DeDRM.zip file before re-importing the plugin as a .zip into calibre, without success. My addition was:

if wineprefix != "" and os.path.exists(wineprefix):
         cmdline = u"WINEPREFIX=\"{2}\" WINEPATH='C:\Python26;C:\windows\system32' wine python.exe \"{0}\" \"{1}\"".format(scriptpath,outdirpath,wineprefix)
    else:

EDIT: manual success by following what is below: Because the plugin seems to force the current folder prefix, I manually ran (without a second argument, as it fails to find the output path, so I have let it choose one):

$ wine python.exe "/home/name/.config/calibre/plugins/DeDRM/libraryfiles/kindlekey.py"

searching for kinfoFiles in C:\users\name\Local Settings\Application Data
Found K4PC 1.9+ kinf2011 file: C:\users\name\Local Settings\Application Data\Amazon\Kindle\storage\.kinf2011
Decrypted key file using IDString '123456789...' and UserName 'abcdef12356...'       

which put a kindlekey1.k4i file as in

/home/name/.config/calibre/plugins/DeDRM/libraryfiles/kindlekey1.k4i

I have moved the decrypted key into the folder expected by the plugin:

cp /home/name/.config/calibre/plugins/DeDRM/libraryfiles/kindlekey1.k4i /home/name/.config/calibre/plugins/DeDRM/libraryfiles/winekeysdir

and re-ran calibre on the new book (remove the book from calibre before):

$ calibre book.azw3                                                                                                               
...
DeDRM v6.6.1: Command line: 'wine python.exe "/home/name/.config/calibre/plugins/DeDRM/libraryfiles/kindlekey.py" "/home/name/.config/calibre/plugins/DeDRM/libraryfiles/winekeysdir"'
wine: cannot find L"C:\\windows\\system32\\python.exe"
DeDRM v6.6.1: Found and decrypted 1 key file
DeDRM v6.6.1: Found 1 new key
MobiDeDrm v0.42.
...
Got DSN key from database default_key_1
Found 4 keys to try after 0.6 seconds
Crypto Type is: 2
File is encoded with PID xxxxxxxx.
Decrypting. Please wait . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . done
Decryption succeeded after 4.4 seconds
DeDRM v6.6.1: Saving 1 new key
DeDRM v6.6.1: Finished after 4.5 seconds
sorsasampo commented 5 years ago

WINEPATH='C:\Python26;C:\windows\system32'

Shouldn't the backslashes be quoted here (\\)?

apprenticeharper commented 5 years ago

setting WINEPATH sounds like a good idea. Can you do a pull request with this addition to the code?

dakeryas commented 5 years ago

WINEPATH='C:\Python26;C:\windows\system32'

Shouldn't the backslashes be quoted here (\\)?

That could be, I thought that the single slashes were enough, but I may be wrong. I do not have the software to check at the moment.