]> xmof Git - DeDRM.git/commitdiff
Fix for Kobo Desktop 3.17
authorapprenticeharper <apprenticeharper@gmail.com>
Thu, 3 Sep 2015 06:49:09 +0000 (07:49 +0100)
committerapprenticeharper <apprenticeharper@gmail.com>
Thu, 3 Sep 2015 06:49:09 +0000 (07:49 +0100)
Obok_calibre_plugin/obok_plugin.zip
Obok_calibre_plugin/obok_plugin/__init__.py
Obok_calibre_plugin/obok_plugin/action.py
Obok_calibre_plugin/obok_plugin/obok/obok.py
Other_Tools/Kobo/obok.py

index aace56178c3ace958ce991583f8ef768418c8dde..a1264e1451e3a730959e4087089d587e84ad8f88 100644 (file)
Binary files a/Obok_calibre_plugin/obok_plugin.zip and b/Obok_calibre_plugin/obok_plugin.zip differ
index 84d0ec1b1a5f56679b1d4bda26aad460f4feabc8..f627a42498d87cb0f340cd9f416de867f8c0a1f2 100644 (file)
@@ -19,7 +19,7 @@ except NameError:
 PLUGIN_NAME = 'Obok DeDRM'
 PLUGIN_SAFE_NAME = PLUGIN_NAME.strip().lower().replace(' ', '_')
 PLUGIN_DESCRIPTION = _('Removes DRM from Kobo kepubs and adds them to the library.')
-PLUGIN_VERSION_TUPLE = (3, 1, 3)
+PLUGIN_VERSION_TUPLE = (3, 1, 4)
 PLUGIN_VERSION = '.'.join([str(x) for x in PLUGIN_VERSION_TUPLE])
 HELPFILE_NAME = PLUGIN_SAFE_NAME + '_Help.htm'
 PLUGIN_AUTHORS = 'Anon'
index 2af4eb6027e87ea54bcb17e42dac8084d5c5166f..d93816e0119d1e9ccede0ba7a2af3422d505e574 100644 (file)
@@ -6,7 +6,7 @@ __license__   = 'GPL v3'
 __docformat__ = 'restructuredtext en'
 
 
-import os, zipfile
+import os, traceback, zipfile
 
 try:
     from PyQt5.Qt import QToolButton, QUrl
@@ -98,6 +98,7 @@ class InterfacePluginAction(InterfaceAction):
             candidate_keys = self.library.userkeys
         except:
             print (_('Trouble retrieving keys with newer obok method.'))
+            traceback.print_exc()
         else:
             if len(candidate_keys):
                 self.userkeys.extend(candidate_keys)
index 6846be11e17ae60c1776fb35fed0689192f8d645..054515229b1880ee613981602a0b71d55bbec3af 100644 (file)
@@ -1,6 +1,9 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
+# Version 3.1.4 September 2015
+# Updated for version 3.17 of the Windows Desktop app.
+#
 # Version 3.1.3 August 2015
 # Add translations for Portuguese and Arabic
 #
@@ -220,7 +223,7 @@ class KoboLibrary(object):
     of books, their titles, and the user's encryption key(s)."""
 
     def __init__ (self):
-        print u"Obok v{0}\nCopyright © 2012-2014 Physisticated et al.".format(__version__)
+        print u"Obok v{0}\nCopyright © 2012-2015 Physisticated et al.".format(__version__)
         if sys.platform.startswith('win'):
             if sys.getwindowsversion().major > 5:
                 self.kobodir = os.environ['LOCALAPPDATA']
@@ -249,9 +252,8 @@ class KoboLibrary(object):
         """
         if len(self._userkeys) != 0:
             return self._userkeys
-        userid = self.__getuserid()
         for macaddr in self.__getmacaddrs():
-            self._userkeys.append(self.__getuserkey(macaddr, userid))
+            self._userkeys.extend(self.__getuserkeys(macaddr))
         return self._userkeys
 
     @property
@@ -297,13 +299,33 @@ class KoboLibrary(object):
                 macaddrs.append(m[0].upper())
         return macaddrs
 
-    def __getuserid (self):
-        return self.__cursor.execute('SELECT UserID FROM user WHERE HasMadePurchase = "true"').fetchone()[0]
-
-    def __getuserkey (self, macaddr, userid):
+    def __getuserids (self):
+        userids = []
+        cursor = self.__cursor.execute('SELECT UserID FROM user WHERE HasMadePurchase = "true"')
+        row = cursor.fetchone()
+        while row is not None:
+            try:
+                userid = row[0]
+                userids.append(userid)
+            except:
+                pass
+            row = cursor.fetchone()
+        return userids
+               
+    def __getuserkeys (self, macaddr):
+        userids = self.__getuserids()
+        userkeys = []
+        # This version is used for versions before 3.17.0.
         deviceid = hashlib.sha256('NoCanLook' + macaddr).hexdigest()
-        userkey = hashlib.sha256(deviceid + userid).hexdigest()
-        return binascii.a2b_hex(userkey[32:])
+        for userid in userids:
+            userkey = hashlib.sha256(deviceid + userid).hexdigest()
+            userkeys.append(binascii.a2b_hex(userkey[32:]))
+        # This version is used for 3.17.0 and later.
+        deviceid = hashlib.sha256('XzUhGYdFp' + macaddr).hexdigest()
+        for userid in userids:
+            userkey = hashlib.sha256(deviceid + userid).hexdigest()
+            userkeys.append(binascii.a2b_hex(userkey[32:]))
+        return userkeys
 
 class KoboBook(object):
     """A Kobo book.
index 42620d21460bd6a97500997c559b8c1d9fbb9c9d..054515229b1880ee613981602a0b71d55bbec3af 100644 (file)
@@ -1,6 +1,12 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
+# Version 3.1.4 September 2015
+# Updated for version 3.17 of the Windows Desktop app.
+#
+# Version 3.1.3 August 2015
+# Add translations for Portuguese and Arabic
+#
 # Version 3.1.2 January 2015
 # Add coding, version number and version announcement
 #
 #
 """Manage all Kobo books, either encrypted or DRM-free."""
 
-__version__ = '3.1.1'
+__version__ = '3.1.3'
 
 import sys
 import os
@@ -217,7 +223,7 @@ class KoboLibrary(object):
     of books, their titles, and the user's encryption key(s)."""
 
     def __init__ (self):
-        print u"Obok v{0}\nCopyright © 2012-2014 Physisticated et al.".format(__version__)
+        print u"Obok v{0}\nCopyright © 2012-2015 Physisticated et al.".format(__version__)
         if sys.platform.startswith('win'):
             if sys.getwindowsversion().major > 5:
                 self.kobodir = os.environ['LOCALAPPDATA']
@@ -246,9 +252,8 @@ class KoboLibrary(object):
         """
         if len(self._userkeys) != 0:
             return self._userkeys
-        userid = self.__getuserid()
         for macaddr in self.__getmacaddrs():
-            self._userkeys.append(self.__getuserkey(macaddr, userid))
+            self._userkeys.extend(self.__getuserkeys(macaddr))
         return self._userkeys
 
     @property
@@ -294,13 +299,33 @@ class KoboLibrary(object):
                 macaddrs.append(m[0].upper())
         return macaddrs
 
-    def __getuserid (self):
-        return self.__cursor.execute('SELECT UserID FROM user WHERE HasMadePurchase = "true"').fetchone()[0]
-
-    def __getuserkey (self, macaddr, userid):
+    def __getuserids (self):
+        userids = []
+        cursor = self.__cursor.execute('SELECT UserID FROM user WHERE HasMadePurchase = "true"')
+        row = cursor.fetchone()
+        while row is not None:
+            try:
+                userid = row[0]
+                userids.append(userid)
+            except:
+                pass
+            row = cursor.fetchone()
+        return userids
+               
+    def __getuserkeys (self, macaddr):
+        userids = self.__getuserids()
+        userkeys = []
+        # This version is used for versions before 3.17.0.
         deviceid = hashlib.sha256('NoCanLook' + macaddr).hexdigest()
-        userkey = hashlib.sha256(deviceid + userid).hexdigest()
-        return binascii.a2b_hex(userkey[32:])
+        for userid in userids:
+            userkey = hashlib.sha256(deviceid + userid).hexdigest()
+            userkeys.append(binascii.a2b_hex(userkey[32:]))
+        # This version is used for 3.17.0 and later.
+        deviceid = hashlib.sha256('XzUhGYdFp' + macaddr).hexdigest()
+        for userid in userids:
+            userkey = hashlib.sha256(deviceid + userid).hexdigest()
+            userkeys.append(binascii.a2b_hex(userkey[32:]))
+        return userkeys
 
 class KoboBook(object):
     """A Kobo book.