apprenticeharper / DeDRM_tools

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

Python3 support #979

Open norbusan opened 4 years ago

norbusan commented 4 years ago

Kovid Goyal announced that Calibre will switch to Python3 in the near future, and plugins need to be adjusted to work with Python 3: https://www.mobileread.com/forums/showthread.php?t=325721

Are there any plans or activities to port this plugin to Python 3?

lalmeras commented 4 years ago

My files has the flag_bits to 00 as expected (can be seen with hexdump).

hexdump -c file.epub
0000000 4b50 0403 000a 0000 0000 a0f7 50b9 0000
[...]
------------------------^----------------------

I can reproduce the ziprugged issue with one of my encrypted epub by unzipping, adding a file with a special characters and zip it again.

hexdump -c file.epub
0000000 4b50 0403 000a 0800 0000 a0f7 50b9 0000
[...]
------------------------^----------------------

Decryption fails with the same stack. Book is added to the library, but it is the encrypted version.

I work on a fix.

lalmeras commented 4 years ago

@innir I just push a fix for this issue. Can you give it a try ?

innir commented 4 years ago

@lalmeras Yes, it works now, thanks!

innir commented 4 years ago

@lalmeras but Adobe PDFs don't work:

AlfCrypto not found. Using python PC1 implementation.
DeDRM v6.7.0: Trying to decrypt test.pdf
DeDRM v6.7.0: test.pdf is a PDF ebook
Running file type plugin DeDRM failed with traceback:
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 638, in run
  File "calibre_plugins.dedrm.__init__", line 428, in PDFDecrypt
AttributeError: 'str' object has no attribute 'decode'
Traceback (most recent call last):
  File "/usr/lib/calibre/calibre/customize/ui.py", line 428, in get_file_type_metadata
    mi = plugin.get_metadata(stream, ftype.lower().strip())
  File "/usr/lib/calibre/calibre/customize/builtins.py", line 343, in get_metadata
    return get_metadata(stream)
  File "/usr/lib/calibre/calibre/ebooks/metadata/pdf.py", line 127, in get_metadata
    raise ValueError('Could not read info dict from PDF')
ValueError: Could not read info dict from PDF
Syntax Error: Couldn't find the 'EBX_HANDLER' security handler
pdfinfo errored out with return code: 1
lalmeras commented 4 years ago

@innir thank you for you feedback. No surprise it doesn't work, only simple fixes (print, exception syntax) was done on ineptpdf.py.

I just give it a glance, and I do not see how to work fast and efficiently on this issue without a key and an encrypted PDF. Compared to ineptepub.py that is already fixed, there are +1000 lines of PDF handling code that may trigger bytes/str errors.

I push a new version that fixes (I hope) the error you encountered. Please try it and send the new errors.

Currently working on unit tests so that python2 and python3 may be compared efficiently, but it is a very long job.

lalmeras commented 4 years ago

Side note: pdf code is a stripped down and inlined version of pdfminer, with customization for EBX_HANDLER, as advertised in comments (ineptpdf.py:~440)

waltercool commented 4 years ago

@lalmeras Hi, just tried to convert an Adobe pdf using your last commits at Python branch, and got this problem:

Running file type plugin DeDRM failed with traceback:
Traceback (most recent call last):
  File "/usr/lib64/calibre/calibre/customize/ui.py", line 172, in _run_filetype_plugins
    nfp = plugin.run(nfp) or nfp
  File "calibre_plugins.dedrm.__init__", line 638, in run
  File "calibre_plugins.dedrm.__init__", line 474, in PDFDecrypt
AttributeError: 'bytes' object has no attribute 'encode'
Traceback (most recent call last):
  File "/usr/lib64/calibre/calibre/customize/ui.py", line 428, in get_file_type_metadata
    mi = plugin.get_metadata(stream, ftype.lower().strip())
  File "/usr/lib64/calibre/calibre/customize/builtins.py", line 343, in get_metadata
    return get_metadata(stream)
  File "/usr/lib64/calibre/calibre/ebooks/metadata/pdf.py", line 129, in get_metadata
    raise ValueError('Could not read info dict from PDF')
ValueError: Could not read info dict from PDF
Syntax Error: Couldn't find the 'EBX_HANDLER' security handler
pdfinfo errored out with return code: 1
Aborting aboutToFinish handling.

Thank you for all your effort by the way!

fversaci commented 4 years ago

Hi everyone, I'm not sure which branch/repo is the most active now on this. I've posted a pull-request here [*] that fixes the dedrm for kindle. Feel free to integrate it wherever it is needed, if it has not been already fixed somewhere else.

[*] https://github.com/lalmeras/DeDRM_tools/pull/1/commits/625de222b2c969a006d74297cad659374b84bb0f

lalmeras commented 4 years ago

Thanks, I just accept the pull request on my repository (branch Python3)

So the updated status is:

@fversaci can you elaborate on the feature you tested on your side ? I suppose, as for other providers, kindle support features at least key extraction (from device, from software ?) and book decryption ? Which environment (Linux, Windows, ...) do you use ?

@norbusan can you give a look to the new version of lalmeras/Python3 to check if there is no regression on your side ?

About branches on my forked repository lalmeras/DeDRM_tools:

fversaci commented 4 years ago

Hi @lalmeras, thanks for the summary!

I'm using Linux and what I fixed was enough to decrypt an azw3 book using an already imported key. After a quick test it seems that importing new keys from k4i files is still not working. I'll try and see if I can get that fixed.

innir commented 4 years ago

@lalmeras Thanks for the update!

One comment from my side: I think Target platform for Adobe/* is also Linux - at least I tested on Linux (extracted the key from a Wine installation)

madhatter0 commented 4 years ago

Fedora 32 having upgraded calibre to 4.22.0, Obok is now no longer working, even with what I believe to be the latest lalmeras/Python3 version. It claims it's decrypting, but when I open my newest book in calibre, it's just gibberish.

Obok DeDRM v6.7.0 - Decrypting Consulting Demons
Trying key:  b'fd1ac2b292058c25b564a87c629e07c6'
Checking text:b"\x10j'F(\xa6\x1d\xd3\x1cv":
Perhaps utf-8 without BOM
Bad character at 0, value 16
Decryption failed, trying next key.
Trying key:  b'3b91232a5be0991ebd6909433382bc40'
Checking text:b'\xef\xf3\xba\xc5=[\x1e\xbf\xc4?':
Perhaps utf-8 without BOM
Bad character at 0, value 239
Decryption failed, trying next key.
Trying key:  b'3bf7db6cf3a399d48be4dfd82df9512e'
Checking text:b'e\x8b(b\xa6\xb0{\x16^\x1b':
Perhaps utf-8 without BOM
Bad character at 1, value 139
Decryption failed, trying next key.
Trying key:  b'a113812ba27a5f66b097e397aa5f4469'
Checking text:b'`Ze\x0b.\xb4\xa6A\nx':
Perhaps utf-8 without BOM
Bad character at 3, value 11
Decryption failed, trying next key.
Trying key:  b'8d133da2ade8743ba76045c3bcedb526'
Checking text:b'\x18\xfd\x02\xa0dw\xc8c\x03\x9a':
Perhaps utf-8 without BOM
Bad character at 0, value 24
Decryption failed, trying next key.
Trying key:  b'99cf5bc97a35cd00a1e2085558cdeae5'
Checking text:b'\xf0\xac\x1fVs\xed\x16\x8f\xaa=':
Perhaps utf-8 without BOM
Bad character at 0, value 240
Decryption failed, trying next key.
Trying key:  b'1ce2d895bef257347434f6df7153a6cc'
Checking text:b'\xbc\x80\xcb\xff\x80\x85\x8e\xaf\x8c\x99':
Perhaps utf-8 without BOM
Bad character at 0, value 188
Decryption failed, trying next key.
Trying key:  b'610f6374a62e2aefe25a2c9c33b72964'
Checking text:b'kK4b*D\x10\xa8\x1av':
Perhaps utf-8 without BOM
Seems to be good text
Success!
Obok DeDRM v6.7.0 - Added Consulting Demons
Obok DeDRM v6.7.0 - wrapping up results.
madhatter0 commented 4 years ago

Rechecking, it looks like it's just this particular ebook. Once I've bought my next ebook, I'll report back.

ElleKayEm commented 4 years ago

People have been reporting issues with the current release of Obok and Python 2 calibre lately as well. They'll have some books with problems, other books work fine. So it might not be Python 3 related.

madhatter0 commented 4 years ago

Yes, I'd seen this issue, which is exactly what I've been seeing, too. I tried everything they recommended there (remove book from kobo, redownload from store, reimport to calibre via obok) to no avail, so thought it worth mentioning here. But I'm happy to accept an informed opinion that the issues are unrelated!

madhatter0 commented 4 years ago

Definitely ignore me; just bought another book and it decrypts fine.

mikegb92121 commented 4 years ago

I received the error below trying to install the latest release into a completely fresh install (Manjaro OS and Calibre) on a VirtualBox VM:

calibre, version 4.23.0 ERROR: Unhandled exception: SyntaxError:invalid syntax (calibre_plugins.dedrm.init, line 168)

calibre 4.23 embedded-python: False is64bit: True Linux-5.8.6-1-MANJARO-x86_64-with-glibc2.2.5 Linux ('64bit', 'ELF') ('Linux', '5.8.6-1-MANJARO', '#1 SMP PREEMPT Thu Sep 3 14:19:36 UTC 2020') Python 3.8.5 Interface language: None Traceback (most recent call last): File "/usr/lib/calibre/calibre/gui2/preferences/plugins.py", line 317, in add_plugin plugin = add_plugin(path) File "/usr/lib/calibre/calibre/customize/ui.py", line 472, in add_plugin plugin = load_plugin(path_to_zip_file) File "/usr/lib/calibre/calibre/customize/ui.py", line 61, in load_plugin return loader.load(path_to_zip_file) File "/usr/lib/calibre/calibre/customize/zipplugin.py", line 201, in load reload(m) File "/usr/lib/calibre/polyglot/builtins.py", line 113, in reload return importlib.reload(module) File "/usr/lib/python3.8/importlib/init.py", line 169, in reload _bootstrap._exec(spec, module) File "", line 602, in _exec File "/usr/lib/calibre/calibre/customize/zipplugin.py", line 180, in load_module compiled = compile(code, 'calibre_plugins.%s.%s'%(plugin_name, File "calibre_plugins.dedrm.init", line 168 print u"{0} v{1}: Copying needed library files from plugin's zip".format(PLUGIN_NAME, PLUGIN_VERSION) ^ SyntaxError: invalid syntax

ElleKayEm commented 4 years ago

That's right. The current release does not work with the beta release of calibre with Python 3. For now, you can use the regular release of calibre which still has embedded Python 2.

mikegb92121 commented 4 years ago

I should have clarified that i was using the Python 3 branch/project from https://github.com/lalmeras. Did not see issues for that project.

ElleKayEm commented 4 years ago

Ah, okay. Nevermind then.

protist commented 4 years ago

I'm having some trouble installing the python3 fork. I downloaded the latest version, zipped the DeDRM_plugin directory, and tried to add it to Calibre. At first I got an error No module named 'ion', but it installed on the second attempt. I can see the plugin settings, it seems to have added my keys, and it's added to ~/.config/calibre/plugins. (Confusingly, the fork is tagged 6.7.0, and the latest python2 version in this repo is 6.8.0.) However, it doesn't seem to decrypt anything. I restart as Calibre suggested, but the add-on is now missing. On the command-line:

$ calibre
AlfCrypto not found. Using python PC1 implementation.
Failed to initialize plugin: '/home/protist/.config/calibre/plugins/DeDRM.zip'
JSWolf commented 4 years ago

Yes, I'd seen this issue, which is exactly what I've been seeing, too. I tried everything they recommended there (remove book from kobo, redownload from store, reimport to calibre via obok) to no avail, so thought it worth mentioning here. But I'm happy to accept an informed opinion that the issues are unrelated!

Why are you bothering with Obok when it's not important? Making sure ePub/KF8/Mobi work to have the DRM removed is much more important. You don't need Obok because you can download ePub direct from Kobo and remove the DRM. Then you can convert back to KePub if you want. So please leave Obok work until after everything else that needs to work works.

norbusan commented 4 years ago

You don't need Obok because you can download ePub direct from Kobo and remove the DRM.

And how do you remove the DRM from epubs downloaded from Kobo? This is done again via obok. The epub/kepub thing is completely independent from that.

JSWolf commented 4 years ago

You don't need Obok because you can download ePub direct from Kobo and remove the DRM.

And how do you remove the DRM from epubs downloaded from Kobo? This is done again via obok. The epub/kepub thing is completely independent from that.

You download the eBooks as ePub using ADE and then you remove the DRM on import to your Calibre library. It's what I've done with my Kobo purchased eBooks.

norbusan commented 4 years ago

But I don't have ADE, not windows, and use by kobo device, and I guess I'm not alone

norbusan commented 4 years ago

Anyway, I think I have fixed obok quite some time ago for P3...

madhatter0 commented 4 years ago

But I don't have ADE, not windows, and use by kobo device, and I guess I'm not alone

I'm glad it's not just me! For anyone operating without proprietary software, the Obok is a vital link in the DeDRMing chain.

JSWolf commented 4 years ago

But I don't have ADE, not windows, and use by kobo device, and I guess I'm not alone

I'm glad it's not just me! For anyone operating without proprietary software, the Obok is a vital link in the DeDRMing chain.

But Obok needs Kobo Desktop. There is no Linux version of Kobo Desktop.

madhatter0 commented 4 years ago

You're perfectly free to tell me that Obok won't work for me on Linux, but all I can say is that I use it to DeDRM content on my Kobo, and it works very well for that, even if perhaps it shouldn't.

ElleKayEm commented 4 years ago

But I don't have ADE, not windows, and use by kobo device, and I guess I'm not alone

I'm glad it's not just me! For anyone operating without proprietary software, the Obok is a vital link in the DeDRMing chain.

But Obok needs Kobo Desktop. There is no Linux version of Kobo Desktop.

Obok works with Kobo ereaders too.

norbusan commented 4 years ago

But Obok needs Kobo Desktop. There is no Linux version of Kobo Desktop.

On Linux it requires e physical device to get the decryption keys which are generated from the ethernet address etc. I know it out of obvious reasons. So it works without Kobo Desktop

apprenticeharper commented 4 years ago

I have manually merged lalmeras's changes into the master branch. Untested, but we should work on the master branch here to get things fixed up for an official release. The wretched virus and work changes rather put paid to my good intentions earlier this year, but I'll be dropping by at least once a week to merge in changes from my testing or other pull requests into the master branch, until we get an 'official' 7.0 release for calibre 5.0

Please concentrate on Python 3.x compatibility. I see no point in worrying about Python 2.x now.

Thanks to everyone for their hard work in my absence.

UnrealDrumpf commented 4 years ago

Suggestion: Please clarify (and be explicit in the release notes) which version(s) of ADE are being supported. This has proved a serious annoyance in the past, because many academic publishers only release e-books via ADE and that's not very device-independent.

It would be great if ADE4.0 and later is supported; if it isn't or can't be, that should be made clear.

hamkg commented 4 years ago

Suggestion: Please clarify (and be explicit in the release notes) which version(s) of ADE are being supported.

Not sure what you mean? As long as we talk about the DeDRM plugin, it doesn't interact with ADE AFAIK. If you've downloaded a book using ADE, you can then import the book to Calibre, and using the DeDRM plugin in Calibre to remove the DRM protection. I run ADE-4.5.10 under wine on my Linux machine. Works just fine.

ElleKayEm commented 4 years ago

@UnrealDrumpf ADE 3 and later support a harden version of Adobe DRM which DeDRM cannot remove (yet). If the ebook vendor isn't using that, you'll be fine on later versions. But with ADE 2.0.1, you know that the DRM can be removed.

UnrealDrumpf commented 4 years ago

Sigh. The contradiction between hamkg and ElleKayEm is exactly why I made that suggestion. And if there are differences among platforms, that should be made clear and explicit, too — many users cannot choose to run programs under wine on a Linux machine because they have to run Windows, or even Mac, natively. I'm only suggesting that things be made clear, not demanding any particular result... and that it be made on the basis of "This is how the program is configured" and not "it works for me with the following tweaks or unique setup."

ElleKayEm commented 4 years ago

No contradiction. DeDRM removes the older Adobe DRM. It does not remove the newer hardened DRM. If you want to be sure that you do not download a book with the hardened DRM, use ADE 2.0.1 (both Windows and Mac). If a vendor is exclusively using the newer DRM, you will not be able to download it with 2.0.1. If they are allowing both, you will get the older removeable DRM with 2.0.1. If a vendor is exclusively user the older DRM, it will not matter what version of ADE you're using -- ADE 3 and up can handle both old and new Adobe DRM. So it all depends on the vendor. People who have been fine using ADE 3 and up have not encountered a vendor using the newer DRM. I'm not aware of what vendors might be using the newer DRM.

hamkg commented 4 years ago

After a bit of experimenting I discovered that it is possible to have both Calibre-4 and Calibre-5 installed alongside each other on a Linux system: With calibre-5 already installed, I downloaded the 4-23 tarball and extracted all files to a newly created /opt/calibre4 folder. I then made a copy of calibre-gui.desktop, renamed it calibre4-gui.desktop and edited the exec lines so that they pointed at /opt/calibre4/calibre Both versions seem happy with sharing the same ~/.config/calibre files. Might be a solution for those that need DeDRM but for some reason also want Calibre-5 installed.

ElleKayEm commented 4 years ago

Windows users can use calibre portable 4.23 and have a regular installation of calibre 5. Or vice versa depending on use case.

ableeker commented 4 years ago

I've downloaded the latest master of DeDRM. My Windows box has Python 2, and 3 installed, so I just ran make_release.py in the root of the ZIP, told it to the version was 7.0.0, and it created ZIP file DeDRM_tools_7.0.0.zip. This ZIP contains our beloved DeDRM_plugin.zip, and it installs just fine in Calibre 5.0.1. (This version actually is 7.0.0.) If you don't have Python, you can just zip the content of folder DeDRM_plugin. But do make sure that all files are in the root of the ZIP, NOT in a folder, otherwise you'll get the error about a missing init.py file!

What's more, the plugin loads, and decrypts Kindle books, one book that's been purchased on a really old Kindle, and one that was downloaded to Kindle for PC 1.17.1. I don't know if the other tools work, but I'm dead chuffed that the Kindle tool works!

However, this is NOT the officially released 7.0.0, it's a work in progress that hasn't been tested thoroughly at all, so your milage may vary. If you're not all right with using an untested version, I suggest to wait for the official one, and use Calibre 4.23 with DeDRM 6.8.0, this combination works great.

hamkg commented 4 years ago

Thanks, ableeker, tried your solution and with the latest master with all the generic 3.0 changes from three days ago the plugin installs, runs, and decrypts DRM-encrypted .epub files just fine on my Linux with python2 and 3 installed. A big thanks to ApprenticeHarper (and everyone who has contributed) for your work findin a solution.

songmash commented 4 years ago

@ableeker 's method works for Mac too. Calibre 5.1 + latest DeDRM code (not release).

garpu commented 4 years ago

I tried ableeker's solution (zipping the contents of the plugin, but got this error. I'm on slackware-current, 64-bit, I have both python 2 and python 3 installed.

`calibre, version 5.1.0 ERROR: Unhandled exception: SyntaxError:invalid syntax (calibre_plugins.dedrm.init, line 168)

calibre 5.1 embedded-python: True is64bit: True Linux-5.4.69-x86_64-AMD_Ryzen_5_1600_Six-Core_Processor-with-glibc2.2.5 Linux ('64bit', 'ELF') ('Linux', '5.4.69', '#1 SMP Thu Oct 1 13:56:19 CDT 2020') Python 3.8.5 Interface language: None Successfully initialized third party plugins: Traceback (most recent call last): File "site-packages/calibre/gui2/preferences/plugins.py", line 317, in add_plugin File "site-packages/calibre/customize/ui.py", line 472, in add_plugin File "site-packages/calibre/customize/ui.py", line 61, in load_plugin File "site-packages/calibre/customize/zipplugin.py", line 200, in load File "site-packages/polyglot/builtins.py", line 123, in reload File "importlib/init.py", line 169, in reload File "", line 602, in _exec File "site-packages/calibre/customize/zipplugin.py", line 179, in load_module File "calibre_plugins.dedrm.init", line 168 print u"{0} v{1}: Copying needed library files from plugin's zip".format(PLUGIN_NAME, PLUGIN_VERSION) ^ SyntaxError: invalid syntax `

akumiszcza commented 4 years ago

@ableeker 's method worked for me on Windows 10 x64 with Calibre 5.1 64-bit. I used it to decode a book I bought today via Amazon and downloaded by an old version of Kindle for PC. Worked like a charm. The plugin identifies itself as DeDRM 7.0.0 already. I didn't have any Python installed.

hamkg commented 4 years ago

I tried ableeker's solution (zipping the contents of the plugin, but got this error. I'm on slackware-current, 64-bit, I have both python 2 and python 3 installed.

`calibre, version 5.1.0 ERROR: Unhandled exception: SyntaxError:invalid syntax (calibre_plugins.dedrm.init, line 168)

calibre 5.1 embedded-python: True is64bit: True Linux-5.4.69-x86_64-AMD_Ryzen_5_1600_Six-Core_Processor-with-glibc2.2.5 Linux ('64bit', 'ELF') ('Linux', '5.4.69', '#1 SMP Thu Oct 1 13:56:19 CDT 2020') Python 3.8.5 Interface language: None Successfully initialized third party plugins: Traceback (most recent call last): File "site-packages/calibre/gui2/preferences/plugins.py", line 317, in add_plugin File "site-packages/calibre/customize/ui.py", line 472, in add_plugin File "site-packages/calibre/customize/ui.py", line 61, in load_plugin File "site-packages/calibre/customize/zipplugin.py", line 200, in load File "site-packages/polyglot/builtins.py", line 123, in reload File "importlib/init.py", line 169, in reload File "", line 602, in _exec File "site-packages/calibre/customize/zipplugin.py", line 179, in load_module File "calibre_plugins.dedrm.init", line 168 print u"{0} v{1}: Copying needed library files from plugin's zip".format(PLUGIN_NAME, PLUGIN_VERSION) ^ SyntaxError: invalid syntax `

Did you pick the whole DeDRM Tools master or just the plugin? @ableeker writes that one can zip just the plugin content, but then one must make sure that all files are in the root of the zip file, otherwise one will encounter an init.py error. I cloned the whole Tools master, ran make_release.py and this produced a DeDRM_plugin zip file (among other things) that was accepted as plugin by Calibre.

garpu commented 4 years ago

redownloaded the master. make_release.py created a file that the init.py couldn't be found, but zipping the contents of the plugin file appeared to have worked.

UnrealDrumpf commented 4 years ago

I do a lot of tech support for academics, many of whom are of limited tech-awareness. So automatic updates are typically turned on, which is A Problem.

Is there any sense of an estimated, working 7.0 release timeframe? Some of these academics (who depend on removing DRM for academic works so they can read stuff on portable devices in the lab/in the field while waiting on experiments) are getting antsy because they can't update to Calibre 5.x yet. And it's just going to get worse with Windows 20H2 about to be released in the next few weeks (I'm being told the second half of October, but I'm betting on 10 November).

So how much optimism can I offer without looking like an idiot later? Coming Real Soon Now doesn't work with this crowd.

ElleKayEm commented 4 years ago

@UnrealDrumpf No way to make an estimate. This is an all volunteer, as time allows, various skill levels, community project. The release of calibre 5 has brought more attention to the situation so things are progressing faster than before. But there's really no telling when it will be ready for release.

dlaw commented 4 years ago

Head of master is working great for Kindle (azw3) decryption with calibre 5.0.1! Thanks to everyone who worked on this.

ametzler commented 4 years ago

Hello,

Head of master does not work for me when trying to import files from Kindle4pc. With the older plugin (and python2 calibre) the following steps work (trying in a new user profile without calibre config): Start calibre, add the dedrm plugin, import k4pc keyfile exported from working installation. Importing an encrypted book removes the DRM:

DeDRM v6.6.3: Trying to decrypt encrypted-fromk4pc.azw
Using Library AlfCrypto DLL/DYLIB/SO
MobiDeDrm v0.42.
Copyright © 2008-2017 The Dark Reverser, Apprentice Harper et al.
Decrypting Kindle Format 8 ebook: [XXXXXXX]
Found 4 keys to try after 0.0 seconds
Crypto Type is: 2
File is encoded with PID XXXXXXXX.
Decrypting. Please wait . . . done
Decryption succeeded after 0.0 seconds
DeDRM v6.6.3: Finished after 0.0 seconds

(ebook name and pid edited out)

On calibre 5.2.0 and dedrm HEAD decryption fails, and dedrm shows the following error message:

DeDRM v7.0.0: Trying to decrypt encrypted-fromk4pc.azw
Using Library AlfCrypto DLL/DYLIB/SO
Using Library AlfCrypto DLL/DYLIB/SO
MobiDeDrm v1.00.
Copyright © 2008-2020 The Dark Reverser, Apprentice Harper et al.
Decrypting Kindle Format 8 ebook: CR!_EDITED_OUT
Keys not found in the database kindl4PCwin10.
Found 0 keys to try after 0.0 seconds
Crypto Type is: 2
DeDRM v7.0.0: Failed to decrypt with error: No key found in 0 keys tried.
DeDRM v7.0.0: Looking for new default Kindle Key after 0.0 seconds
DeDRM v7.0.0: Running kindlekey.py under Wine
DeDRM v7.0.0: Command line: 'wine python.exe "/home/ametzler/.config/calibre/plugins/DeDRM/libraryfiles/kindlekey.py" "/home/ametzler/.config/calibre/plugins/DeDRM/libraryfiles/winekeysdir"'
/bin/sh: 1: wine: not found
DeDRM v7.0.0: Found and decrypted 0 key files
DeDRM v7.0.0: Ultimately failed to decrypt after 0.0 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md
Running file type plugin DeDRM failed with traceback:
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 533, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
  File "calibre_plugins.dedrm.k4mobidedrm", line 237, in GetDecryptedBook
    mb.processBook(totalpids)
  File "calibre_plugins.dedrm.mobidedrm", line 475, in processBook
    raise DrmException("No key found in {0:d} keys tried.".format(len(goodpids)))
calibre_plugins.dedrm.mobidedrm.DrmException: No key found in 0 keys tried.

During handling of the above exception, another exception occurred:

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 626, in run
    decrypted_ebook = self.KindleMobiDecrypt(path_to_ebook)
  File "calibre_plugins.dedrm.__init__", line 576, in KindleMobiDecrypt
    raise DeDRMError("{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime))
calibre_plugins.dedrm.DeDRMError: DeDRM v7.0.0: Ultimately failed to decrypt after 0.0 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md

"Found 0 keys" looks strange, since .config/calibre/plugins/dedrm.json has the correct entry in kindlekeys, it is identical to the file I get doing the abovementioned steps on older calibre (python2) with older (6.6.3) dedrm.

This is on Linux. (Debian unstable).