]> xmof Git - DeDRM.git/commitdiff
Fixes for the plugin and Android keys (help still needs adding)
authorApprentice Harper <apprenticeharper@gmail.com>
Wed, 18 Mar 2015 19:12:01 +0000 (19:12 +0000)
committerApprentice Alf <apprenticealf@gmail.com>
Wed, 18 Mar 2015 19:12:01 +0000 (19:12 +0000)
DeDRM_calibre_plugin/DeDRM_plugin.zip
DeDRM_calibre_plugin/DeDRM_plugin/__init__.py
DeDRM_calibre_plugin/DeDRM_plugin/androidkindlekey.py
DeDRM_calibre_plugin/DeDRM_plugin/config.py
DeDRM_calibre_plugin/DeDRM_plugin_ReadMe.txt

index 01a60f50a69d97850b7b16c32e171c0aab13cc55..9906f05a4d65cdd9d8461caac9ad4699179cc856 100644 (file)
Binary files a/DeDRM_calibre_plugin/DeDRM_plugin.zip and b/DeDRM_calibre_plugin/DeDRM_plugin.zip differ
index 169c77736934983628e7f00664495646dc2d91cf..ef1e1b44a5c85004e1c1e361ece179a2fd72c59a 100644 (file)
@@ -479,7 +479,7 @@ class DeDRM(FileTypePlugin):
         dedrmprefs = prefs.DeDRM_Prefs()
         pids = dedrmprefs['pids']
         serials = dedrmprefs['serials']
-        serials.append(dedrmprefs['androidserials'])
+        serials.extend(dedrmprefs['androidserials'])
         kindleDatabases = dedrmprefs['kindlekeys'].items()
 
         try:
index d5cb01ab09d764b1530bffc59af4d3f5502e9b95..fd4c19355fa5938ecf21cc1b24374152ad5c345c 100644 (file)
@@ -256,14 +256,14 @@ def get_serials(path=STORAGE):
     tar = tarfile.open(fileobj=output)
     for member in tar.getmembers():
         if member.name.strip().endswith(STORAGE1):
-            write = tempfile.NamedTemporaryFile(mode='w', delete=False)
+            write = tempfile.NamedTemporaryFile(mode='wb', delete=False)
             write.write(tar.extractfile(member).read())
             write.close()
             write_path = os.path.abspath(write.name)
             serials.extend(get_serials1(write_path))
             os.remove(write_path)
         elif member.name.strip().endswith(STORAGE2):
-            write = tempfile.NamedTemporaryFile(mode='w', delete=False)
+            write = tempfile.NamedTemporaryFile(mode='wb', delete=False)
             write.write(tar.extractfile(member).read())
             write.close()
             write_path = os.path.abspath(write.name)
index 1714d31f81bd32d76a89728fe7775c00090fbcff..1357b496f469461d881cfeca9c0767bff6b8e513 100644 (file)
@@ -34,6 +34,7 @@ from calibre.constants import iswindows, isosx
 from calibre_plugins.dedrm.__init__ import PLUGIN_NAME, PLUGIN_VERSION
 from calibre_plugins.dedrm.__init__ import RESOURCE_NAME as help_file_name
 from calibre_plugins.dedrm.utilities import uStrCmp
+from calibre_plugins.dedrm.androidkindlekey import get_serials
 
 import calibre_plugins.dedrm.prefs as prefs
 
@@ -199,6 +200,7 @@ class ManageKeysDialog(QDialog):
         self.import_key = (keyfile_ext != u"")
         self.binary_file = (keyfile_ext == u"der")
         self.json_file = (keyfile_ext == u"k4i")
+        self.android_file = (keyfile_ext == u"ab")
         self.wineprefix = wineprefix
 
         self.setWindowTitle("{0} {1}: Manage {2}s".format(PLUGIN_NAME, PLUGIN_VERSION, self.key_type_name))
@@ -381,32 +383,43 @@ class ManageKeysDialog(QDialog):
             for filename in files:
                 fpath = os.path.join(config_dir, filename)
                 filename = os.path.basename(filename)
-                new_key_name = os.path.splitext(os.path.basename(filename))[0]
-                with open(fpath,'rb') as keyfile:
-                    new_key_value = keyfile.read()
-                if self.binary_file:
-                    new_key_value = new_key_value.encode('hex')
-                elif self.json_file:
-                    new_key_value = json.loads(new_key_value)
-                match = False
-                for key in self.plugin_keys.keys():
-                    if uStrCmp(new_key_name, key, True):
-                        skipped += 1
-                        msg = u"A key with the name <strong>{0}</strong> already exists!\nSkipping key file  <strong>{1}</strong>.\nRename the existing key and import again".format(new_key_name,filename)
-                        inf = info_dialog(None, "{0} {1}".format(PLUGIN_NAME, PLUGIN_VERSION),
-                                _(msg), show_copy_button=False, show=True)
-                        match = True
-                        break
-                if not match:
-                    if new_key_value in self.plugin_keys.values():
-                        old_key_name = [name for name, value in self.plugin_keys.iteritems() if value == new_key_value][0]
-                        skipped += 1
-                        info_dialog(None, "{0} {1}".format(PLUGIN_NAME, PLUGIN_VERSION),
-                                            u"The key in file {0} is the same as the existing key <strong>{1}</strong> and has been skipped.".format(filename,old_key_name), show_copy_button=False, show=True)
-                    else:
-                        counter += 1
-                        self.plugin_keys[new_key_name] = new_key_value
-
+                if type(self.plugin_keys) != dict:
+                    # must be the new Kindle for Android section
+                    print u"Getting keys from "+fpath
+                    new_keys = get_serials(fpath)
+                    for key in new_keys:
+                        if key in self.plugin_keys:
+                            skipped += 1
+                        else:
+                            counter += 1
+                            self.plugin_keys.append(key)
+                else:
+                    new_key_name = os.path.splitext(os.path.basename(filename))[0]
+                    with open(fpath,'rb') as keyfile:
+                        new_key_value = keyfile.read()
+                    if self.binary_file:
+                        new_key_value = new_key_value.encode('hex')
+                    elif self.json_file:
+                        new_key_value = json.loads(new_key_value)
+                    match = False
+                    for key in self.plugin_keys.keys():
+                        if uStrCmp(new_key_name, key, True):
+                            skipped += 1
+                            msg = u"A key with the name <strong>{0}</strong> already exists!\nSkipping key file  <strong>{1}</strong>.\nRename the existing key and import again".format(new_key_name,filename)
+                            inf = info_dialog(None, "{0} {1}".format(PLUGIN_NAME, PLUGIN_VERSION),
+                                    _(msg), show_copy_button=False, show=True)
+                            match = True
+                            break
+                    if not match:
+                        if new_key_value in self.plugin_keys.values():
+                            old_key_name = [name for name, value in self.plugin_keys.iteritems() if value == new_key_value][0]
+                            skipped += 1
+                            info_dialog(None, "{0} {1}".format(PLUGIN_NAME, PLUGIN_VERSION),
+                                                u"The key in file {0} is the same as the existing key <strong>{1}</strong> and has been skipped.".format(filename,old_key_name), show_copy_button=False, show=True)
+                        else:
+                            counter += 1
+                            self.plugin_keys[new_key_name] = new_key_value
+                            
             msg = u""
             if counter+skipped > 1:
                 if counter > 0:
index 6e77c165928646e1339e784ef9f4d1612ce68b92..dda00d7b9d9b59740a1df1cfb98fe8722238fc8f 100644 (file)
@@ -91,6 +91,6 @@ These instructions have been tested with Wine 1.4 on Ubuntu.
 Instructions for getting Kindle for PC and Adobe Digital Editions default decryption keys
 -----------------------------------------------------------------------------------------
 
-If everything has been installed in wine as above, the keys will be retrieve automatically.
+If everything has been installed in wine as above, the keys will be retrieved automatically.
 
 If you have a more complex wine installation, you may enter the appropriate WINEPREFIX in the configuration dialogs for Kindle for PC and Adobe Digital Editions. You can also test that you have entered the WINEPREFIX correctly by trying to add the default keys to the preferences by clicking on the green plus button in the configuration dialogs.