mirror of
https://github.com/noDRM/DeDRM_tools
synced 2024-11-16 19:48:10 +01:00
Fix Kindle for real
This commit is contained in:
parent
726d72217e
commit
76ce6d9c5c
2 changed files with 12 additions and 14 deletions
|
@ -959,30 +959,28 @@ class DeDRM(FileTypePlugin):
|
|||
traceback.print_exc()
|
||||
pass
|
||||
|
||||
newkeys = []
|
||||
newkeys = {}
|
||||
newnames = []
|
||||
|
||||
for i,keyvalue in enumerate(defaultkeys):
|
||||
try:
|
||||
keyname = "default_key_" + defaultnames[i]
|
||||
except:
|
||||
keyname = "default_key_{0:d}".format(i+1)
|
||||
|
||||
if keyvalue not in dedrmprefs['kindlekeys'].values():
|
||||
newkeys.append(keyvalue)
|
||||
newnames.append(keyname)
|
||||
newkeys["key_{0:d}".format(i)] = keyvalue
|
||||
|
||||
if len(newkeys) > 0:
|
||||
print("{0} v{1}: Found {2} new {3}".format(PLUGIN_NAME, PLUGIN_VERSION, len(newkeys), "key" if len(newkeys)==1 else "keys"))
|
||||
try:
|
||||
book = k4mobidedrm.GetDecryptedBook(path_to_ebook,list(newkeys),[],[],[],self.starttime)
|
||||
book = k4mobidedrm.GetDecryptedBook(path_to_ebook,newkeys.items(),[],[],[],self.starttime)
|
||||
decoded = True
|
||||
# store the new successful keys in the defaults
|
||||
print("{0} v{1}: Saving {2} new {3}".format(PLUGIN_NAME, PLUGIN_VERSION, len(newkeys), "key" if len(newkeys)==1 else "keys"))
|
||||
for i,keyvalue in enumerate(newkeys):
|
||||
dedrmprefs.addnamedvaluetoprefs('kindlekeys',newnames[i],keyvalue)
|
||||
i = 1
|
||||
for keyvalue in newkeys.values():
|
||||
while "kindle_key_{0:d}_{1:d}".format(int(time.time()), i) in dedrmprefs['kindlekeys']:
|
||||
i = i + 1
|
||||
dedrmprefs.addnamedvaluetoprefs('kindlekeys',"kindle_key_{0:d}_{1:d}".format(int(time.time()), i),keyvalue)
|
||||
dedrmprefs.writeprefs()
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
pass
|
||||
if not decoded:
|
||||
#if you reached here then no luck raise and exception
|
||||
|
|
|
@ -6,7 +6,7 @@ __license__ = 'GPL v3'
|
|||
# Python 3, September 2020
|
||||
|
||||
# Standard Python modules.
|
||||
import sys, os, traceback, json, codecs, base64
|
||||
import sys, os, traceback, json, codecs, base64, time
|
||||
|
||||
from PyQt5.Qt import (Qt, QWidget, QHBoxLayout, QVBoxLayout, QLabel, QLineEdit,
|
||||
QGroupBox, QPushButton, QListWidget, QListWidgetItem, QCheckBox,
|
||||
|
@ -1237,7 +1237,7 @@ class AddKindleDialog(QDialog):
|
|||
from wineutils import WineGetKeys
|
||||
|
||||
scriptpath = os.path.join(parent.parent.alfdir,"kindlekey.py")
|
||||
defaultkeys = WineGetKeys(scriptpath, ".k4i",parent.getwineprefix())
|
||||
defaultkeys, defaultnames = WineGetKeys(scriptpath, ".k4i",parent.getwineprefix())
|
||||
|
||||
self.default_key = defaultkeys[0]
|
||||
except:
|
||||
|
@ -1255,7 +1255,7 @@ class AddKindleDialog(QDialog):
|
|||
key_group = QHBoxLayout()
|
||||
data_group_box_layout.addLayout(key_group)
|
||||
key_group.addWidget(QLabel("Unique Key Name:", self))
|
||||
self.key_ledit = QLineEdit("default_key", self)
|
||||
self.key_ledit = QLineEdit("default_key_" + str(int(time.time())), self)
|
||||
self.key_ledit.setToolTip("<p>Enter an identifying name for the current default Kindle for Mac/PC key.")
|
||||
key_group.addWidget(self.key_ledit)
|
||||
|
||||
|
|
Loading…
Reference in a new issue