diff --git a/DeDRM_calibre_plugin/DeDRM_plugin.zip b/DeDRM_calibre_plugin/DeDRM_plugin.zip
index 01a60f5..9906f05 100644
Binary files a/DeDRM_calibre_plugin/DeDRM_plugin.zip and b/DeDRM_calibre_plugin/DeDRM_plugin.zip differ
diff --git a/DeDRM_calibre_plugin/DeDRM_plugin/__init__.py b/DeDRM_calibre_plugin/DeDRM_plugin/__init__.py
index 169c777..ef1e1b4 100644
--- a/DeDRM_calibre_plugin/DeDRM_plugin/__init__.py
+++ b/DeDRM_calibre_plugin/DeDRM_plugin/__init__.py
@@ -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:
diff --git a/DeDRM_calibre_plugin/DeDRM_plugin/androidkindlekey.py b/DeDRM_calibre_plugin/DeDRM_plugin/androidkindlekey.py
index d5cb01a..fd4c193 100644
--- a/DeDRM_calibre_plugin/DeDRM_plugin/androidkindlekey.py
+++ b/DeDRM_calibre_plugin/DeDRM_plugin/androidkindlekey.py
@@ -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)
diff --git a/DeDRM_calibre_plugin/DeDRM_plugin/config.py b/DeDRM_calibre_plugin/DeDRM_plugin/config.py
index 1714d31..1357b49 100644
--- a/DeDRM_calibre_plugin/DeDRM_plugin/config.py
+++ b/DeDRM_calibre_plugin/DeDRM_plugin/config.py
@@ -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 {0} already exists!\nSkipping key file {1}.\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 {1} 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 {0} already exists!\nSkipping key file {1}.\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 {1} 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:
diff --git a/DeDRM_calibre_plugin/DeDRM_plugin_ReadMe.txt b/DeDRM_calibre_plugin/DeDRM_plugin_ReadMe.txt
index 6e77c16..dda00d7 100644
--- a/DeDRM_calibre_plugin/DeDRM_plugin_ReadMe.txt
+++ b/DeDRM_calibre_plugin/DeDRM_plugin_ReadMe.txt
@@ -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.