Fixes for the plugin and Android keys (help still needs adding)

This commit is contained in:
Apprentice Harper 2015-03-18 19:12:01 +00:00 committed by Apprentice Alf
parent 39c9d57b15
commit 6b2672ff7c
5 changed files with 43 additions and 30 deletions

View File

@ -479,7 +479,7 @@ class DeDRM(FileTypePlugin):
dedrmprefs = prefs.DeDRM_Prefs() dedrmprefs = prefs.DeDRM_Prefs()
pids = dedrmprefs['pids'] pids = dedrmprefs['pids']
serials = dedrmprefs['serials'] serials = dedrmprefs['serials']
serials.append(dedrmprefs['androidserials']) serials.extend(dedrmprefs['androidserials'])
kindleDatabases = dedrmprefs['kindlekeys'].items() kindleDatabases = dedrmprefs['kindlekeys'].items()
try: try:

View File

@ -256,14 +256,14 @@ def get_serials(path=STORAGE):
tar = tarfile.open(fileobj=output) tar = tarfile.open(fileobj=output)
for member in tar.getmembers(): for member in tar.getmembers():
if member.name.strip().endswith(STORAGE1): 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.write(tar.extractfile(member).read())
write.close() write.close()
write_path = os.path.abspath(write.name) write_path = os.path.abspath(write.name)
serials.extend(get_serials1(write_path)) serials.extend(get_serials1(write_path))
os.remove(write_path) os.remove(write_path)
elif member.name.strip().endswith(STORAGE2): 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.write(tar.extractfile(member).read())
write.close() write.close()
write_path = os.path.abspath(write.name) write_path = os.path.abspath(write.name)

View 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 PLUGIN_NAME, PLUGIN_VERSION
from calibre_plugins.dedrm.__init__ import RESOURCE_NAME as help_file_name from calibre_plugins.dedrm.__init__ import RESOURCE_NAME as help_file_name
from calibre_plugins.dedrm.utilities import uStrCmp from calibre_plugins.dedrm.utilities import uStrCmp
from calibre_plugins.dedrm.androidkindlekey import get_serials
import calibre_plugins.dedrm.prefs as prefs import calibre_plugins.dedrm.prefs as prefs
@ -199,6 +200,7 @@ class ManageKeysDialog(QDialog):
self.import_key = (keyfile_ext != u"") self.import_key = (keyfile_ext != u"")
self.binary_file = (keyfile_ext == u"der") self.binary_file = (keyfile_ext == u"der")
self.json_file = (keyfile_ext == u"k4i") self.json_file = (keyfile_ext == u"k4i")
self.android_file = (keyfile_ext == u"ab")
self.wineprefix = wineprefix self.wineprefix = wineprefix
self.setWindowTitle("{0} {1}: Manage {2}s".format(PLUGIN_NAME, PLUGIN_VERSION, self.key_type_name)) self.setWindowTitle("{0} {1}: Manage {2}s".format(PLUGIN_NAME, PLUGIN_VERSION, self.key_type_name))
@ -381,6 +383,17 @@ class ManageKeysDialog(QDialog):
for filename in files: for filename in files:
fpath = os.path.join(config_dir, filename) fpath = os.path.join(config_dir, filename)
filename = os.path.basename(filename) filename = os.path.basename(filename)
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] new_key_name = os.path.splitext(os.path.basename(filename))[0]
with open(fpath,'rb') as keyfile: with open(fpath,'rb') as keyfile:
new_key_value = keyfile.read() new_key_value = keyfile.read()

View 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 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. 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.