apprenticeharper / DeDRM_tools

DeDRM tools for ebooks
14.49k stars 1.5k forks source link

Obok calibre plugin unable to find user keys #840

Open Grimmr opened 5 years ago

Grimmr commented 5 years ago

attempting to use the plugin causes the following error message to be displayed: No userkeys found to decrypt books with. No point in proceeding.

I've attempted reinstalling the plugins, calibre, and the kobo ebook reader to no effect

Calibre version 3.4.4 Obok plugin version 6.5.4 Kobo reader version 4.14.10877 OS is windows 7

I apologise if this issue is due to user error on my part

ElleKayEm commented 5 years ago

Calibre and Kobo Desktop are on the same machine and user? You can read the books in the Kobo Desktop app?

Grimmr commented 5 years ago

yes, same machine and user.

ElleKayEm commented 5 years ago

And you can open and read books in the Kobo app?

Grimmr commented 5 years ago

Yes, I can also read them in the app. (Apologies I meant to say that earlier)

ElleKayEm commented 5 years ago

Hmm, I don't know. I have the same setup except I'm on Windows 8, and it's working for me.

Not a solution, but a workaround would be to get the Adobe DRM versions from the Kobo website using ADE 2.0.1 and the DeDRM plugin instead.

Grimmr commented 5 years ago

your suggested workaround has worked. Thanks for your help.

Is it always the case that kobo books can be obtained via acsm files?

ElleKayEm commented 5 years ago

Most, if not all, I believe. You can check at the bottom of an ebook's page on the Kobo site for the "Ebook Details" and it will show under "download options". If it has Adobe DRM, you'll get the .acsm file. If it's DRM-free, you'll be able to download the EPUB itself.

Avventato commented 3 years ago

After six months I have the same problem with exactly the same situation except I now use Calibre version 5.9.0, Obok version 6.7.0, and windows 10. It should be interesting at least to understand which are these "userkeys" the obok plugin is asking for. Any ideas?

ElleKayEm commented 3 years ago

Obok should find the userkeys automatically in the Kobo Desktop database. You are using the Kobo Desktop program? Not the Windows store app? Also, you're using the master file version of Obok? Not the last release that comes with DeDRM_tools_6.8.1.zip? Both of those still show a version number of 6.7.0.

Avventato commented 3 years ago

First of all, thankyou for the explanation. Yes, I use Kobo Desktop downloaded by the kobo site. If Obok find the userkeys in the Kobo Desktop installation I can see two possibilities: Kobo has changed something in its app or I installed badly the app (despite the fact that everything seems ok)

ElleKayEm commented 3 years ago

Still working for me. Kobo updated when I checked yesterday, and I had no issues.

Avventato commented 3 years ago

Happy for you! I tried on another PC, but no luck.

ElleKayEm commented 3 years ago

Kobo is on the same machine and user as calibre with Obok? You can read your books in Kobo?

I am using calibre 4.23 and the Python 2 version of Obok. Although I have seen others report that calibre 5.x and the unreleased version of Obok works for them.

If you have a Kobo reader, you could connect it via usb and have Obok decrypt those books. And there is the workaround I suggested to the op...using ADE and DeDRM.

Avventato commented 3 years ago

Again thank you Ellie, and yes: Kobo is on the same machine as Calibre with Obok and I can read my books in Kobo. I maintained also the 4.x version of Calibre with Python 2. This is in a different PC. On this "Calibre legacy" PC I do not have any problem with the OBOK plugin and I use it for one year or more with no difficulties. I would like to change to the new Calibre 5, but, being afraid of possible bugs, I maintained my Calibre4 installation. For some time (not now) I had Calibre 4 and Calibre 5 (portable) on the same PC with the same Calibre archive and Kobo Desktop installation (of course). Obok for Calibre 4 was ok whereas obok for Calibre 5 had this "userkeys" problem. I could use the workaround you suggested, but this is not the point and I have a workaround already operating (calibre4). My point is to give an advice that there is something that is not always correct on Obok 6.7.0 (or perhaps on Calibre 5 or perhaps in the installation procedure or something else) so that I suggest a review of the plugin, taking into account these symptoms.

I hope that this can be of some interest for the authors and, in the meantime, I send a big hug to you and to your kindness.

Claudio

ElleKayEm commented 3 years ago

So for calibre 5, you downloaded the current DeDRM tools code from the main page and then zipped up the contents of the Obok folder?

Avventato commented 3 years ago

Sure. 7.0.3 for DeDrm and 6.7.0 for obok. Mantaining the old ones for Calibre 4.

Avventato commented 3 years ago

To be precise I unzipped the master package, then I extracted the obok part and the DeDrm part and rezipped both separately. After I loaded them onto Calibre 5 with no problems of installation.

Avventato commented 3 years ago

I didn't figure that the third package included into the master pack had to be loaded to allow the operation. Is it correct?

ElleKayEm commented 3 years ago

Just double-checking since there hasn't been a beta release yet for Obok for calibre 5. And Obok's version number hasn't been updated since the release of DeDRM 6.7.0 almost a year ago.

I don't know what you mean by third package. The Other_Tools folder? No, those are a lot of odds and ends that aren't need for the plugins.

Avventato commented 3 years ago

Yes to both your question. Yes I intend to wait the beta release that I suppose will include improvements and debugging and yes the "other_tools" software. Thank you for your answer. Coming back to the first question I tried to give a knowledge contribution to the next version according to my tests. I do not hope that there is any easy solution now.

Claudio

stakyman commented 3 years ago

Hi, Just thought I'd post some debug output from Calibre when using OBOK since nobody else has. This is on a new install of Big Sur 11.2, calibre 5.10.1 and Obok latest at the time of this post. Obok is pointing at ~/Library/Application Support/Kobo/Kobo Desktop Edition. New install as well, version 4.24.12382.

Running Obok DeDRM v6.7.0 DEBUG: 219.5 get_device_settings - device_path= /Volumes/KOBOeReader/ Obok v4.0.0 Copyright © 2012-2020 Physisticated et al. /var/folders/_p/r3hglfrx5hq_qqrcrg4mnt980000gn/T/tmp5kdvrfas DEBUG: 224.6 got kobodir /Volumes/KOBOeReader/.kobo Error parsing Kobo plist: no legacy user key found. Trouble retrieving keys with newer obok method. Traceback (most recent call last): File "calibre_plugins.obok_dedrm.action", line 121, in launchObok candidate_keys = self.library.userkeys File "calibre_plugins.obok_dedrm.obok.obok", line 413, in userkeys for macaddr in self.getmacaddrs(): File "calibre_plugins.obok_dedrm.obok.obok", line 455, in getmacaddrs matches = c.findall(output) TypeError: cannot use a string pattern on a bytes-like object

journeyman88 commented 3 years ago

I had a similar problem on Windows 10, using the latest 7.1.0 as the ipconfig command used in the "getmacaddrs" function returned some invalid utf-8 characters (according to debug).

I've solved modifing the obok.py file to use the wmic command (as is a windows command it do not require special scripting permissions on the powershell, and should also work on Win 7 and Win 8, and in contrast with "getmac" should get all mac address and not only those of the enabled network adapters), and changing the regex to match correctly the result of the command.

This is the pseudo-diff of the modification.

obok.py.diff.txt

TheNeurotox commented 3 years ago

Thanks journeyman88 !

vertis commented 3 years ago

I was experiencing the same thing on Mac.

DEBUG:    3.0 got kobodir /Users/vertis/Library/Application Support/Kobo/Kobo Desktop Edition
Error parsing Kobo plist: no legacy user key found.
Trouble retrieving keys with newer obok method.
Traceback (most recent call last):
  File "calibre_plugins.obok_dedrm.action", line 121, in launchObok
    candidate_keys = self.library.userkeys
  File "calibre_plugins.obok_dedrm.obok.obok", line 440, in userkeys
    for macaddr in self.__getmacaddrs():
  File "calibre_plugins.obok_dedrm.obok.obok", line 482, in __getmacaddrs
    matches = c.findall(output)
TypeError: cannot use a string pattern on a bytes-like object

Updating the output variable to add .decode('utf-8') fixed the problem

output = subprocess.check_output('/sbin/ifconfig -a', shell=True)
matches = c.findall(output.decode('utf-8'))

Not enough of a pythonista to know if this is a correct solution. Found the solution here by googling TypeError: cannot use a string pattern on a bytes-like object.

I assume this is a somewhat generic error.

journeyman88 commented 3 years ago

That's in essence what #1586 do to solve the problem on macOS. On win10 as the error as reported seems to happen on byte->string conversion in #1575 I've changed the external call so that it gets only the MAC addresses reducing the possibility of conversion error.

lalratty commented 3 years ago

I'm having a remarkably similar problem with obok and Kobo! My Kobo desktop reader and library are on the same machine as Calibre. All the books are readable in the Kobo desktop, but I'm also getting the "no userkeys" problem. See debug below. I'm using calibre 5.27 and Obok DeDRM v7.1.0 One peculiar, and I don't know if it's relevant, but all of the files in /Users/xxx/Library/Application\ Support/Kobo/Kobo\ Desktop\ Edition/kepub have no extension. If I try importing them to Adobe Digital Editions, I get "unsuccessful, this file's format is not currently supported" If I change the extension to .epub, ADE seems to import it, showing the title, author and page count, but if I try to open it, I get all blank pages. calibre 5.27 embedded-python: True is64bit: True macOS-10.14.6-x86_64-i386-64bit Darwin ('64bit', '') ('Darwin', '18.7.0', 'Darwin Kernel Version 18.7.0: Mon May 3 20:41:19 PDT 2021; root:xnu-4903.278.68~1/RELEASE_X86_64') Python 3.8.5 OSX: ('10.14.6', ('', '', ''), 'x86_64') Interface language: en_GB Successfully initialized third party plugins: DeDRM (7, 1, 0) && Kobo Utilities (2, 14, 1) && Obok DeDRM (7, 1, 0) devicePixelRatio: 2.0 logicalDpi: 72.0 x 72.0 physicalDpi: 110.50000165954353 x 110.50000165954353 Using calibre Qt style: True [0.00] Starting up... [0.02] Showing splash screen... [0.35] splash screen shown [0.35] Initializing db... [0.41] db initialized [0.41] Constructing main UI... DEBUG: 0.0 KoboUtilites::action.py - loading translations DEBUG: 0.0 KoboUtilites::dialogs.py - loading translations DEBUG: 0.0 KoboUtilites::action.py - loading translations DEBUG: 0.0 obok::utilities.py - loading translations DEBUG: 0.0 obok::dialogs.py - loading translations DEBUG: 0.0 obok::config.py - loading translations DEBUG: 0.3 obok::action_err.py - loading translations DEBUG: 1.1 No Kobo Touch, Glo or Mini appears to be connected DEBUG: 1.1 rebuild_menus - self.supports_ratings=None, self.supports_tiles=None DEBUG: 1.1 KoboUtilities:set_toolbar_button_tooltip - start: text='None' DEBUG: 1.1 device_driver_name - could not load extended driver. Exception= No module named 'calibre_plugins.kobotouch_extended' DEBUG: 1.1 KoboUtilities:set_toolbar_button_tooltip - setting to text='Utilities to use with Kobo ereaders

Driver: KoboTouch' DEBUG: 1.1 device_driver_name - could not load extended driver. Exception= No module named 'calibre_plugins.kobotouch_extended' [2.23] main UI initialized... [2.23] Hiding splash screen Starting QuickView [2.60] splash screen hidden [2.60] Started up in 2.60 seconds with 28 books Running Obok DeDRM v7.1.0 DEBUG: 15.8 didn't find device Obok v4.0.0 Copyright © 2012-2020 Physisticated et al. /var/folders/kw/02xvhdxs4ql1bp6t_gnmts980000gn/T/tmp8_0bhcve DEBUG: 15.8 got kobodir /Users/dominic/Library/Application Support/Kobo/Kobo Desktop Edition Error parsing Kobo plist: no legacy user key found. Trouble retrieving keys with newer obok method. Traceback (most recent call last): File "calibre_plugins.obok_dedrm.action", line 121, in launchObok candidate_keys = self.library.userkeys File "calibre_plugins.obok_dedrm.obok.obok", line 440, in userkeys for macaddr in self.getmacaddrs(): File "calibre_plugins.obok_dedrm.obok.obok", line 482, in getmacaddrs matches = c.findall(output) TypeError: cannot use a string pattern on a bytes-like object

ElleKayEm commented 3 years ago

@lalratty Try updating to Obok 7.2.1. No, the Kobo Desktop book files don't have extensions. These won't work in ADE since they have a different DRM. However, you can get a Adobe DRM epub from your books page on Kobo's website, and those can be decrypted with DeDRM.

lalratty commented 3 years ago

@ElleKayEm Thanks. I'd only been given the link for 7.1.0 yesterday by epubor's support, so I'd assumed I was on the latest version!