mirror of
https://github.com/noDRM/DeDRM_tools.git
synced 2024-12-29 21:07:39 +06:00
Python 3 fixes for __init__.py
This commit is contained in:
parent
ccfa454226
commit
ae806f734e
@ -77,7 +77,7 @@ Decrypt DRMed ebooks.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
PLUGIN_NAME = "DeDRM"
|
PLUGIN_NAME = "DeDRM"
|
||||||
PLUGIN_VERSION_TUPLE = tuple([int(x) for x in __version__.split(".")])
|
PLUGIN_VERSION_TUPLE = (7, 0, 0)
|
||||||
PLUGIN_VERSION = ".".join([str(x)for x in PLUGIN_VERSION_TUPLE])
|
PLUGIN_VERSION = ".".join([str(x)for x in PLUGIN_VERSION_TUPLE])
|
||||||
# Include an html helpfile in the plugin's zipfile with the following name.
|
# Include an html helpfile in the plugin's zipfile with the following name.
|
||||||
RESOURCE_NAME = PLUGIN_NAME + '_Help.htm'
|
RESOURCE_NAME = PLUGIN_NAME + '_Help.htm'
|
||||||
@ -421,7 +421,7 @@ class DeDRM(FileTypePlugin):
|
|||||||
# Attempt to decrypt epub with each encryption key (generated or provided).
|
# Attempt to decrypt epub with each encryption key (generated or provided).
|
||||||
print("{0} v{1}: {2} is a PDF ebook".format(PLUGIN_NAME, PLUGIN_VERSION, os.path.basename(path_to_ebook)))
|
print("{0} v{1}: {2} is a PDF ebook".format(PLUGIN_NAME, PLUGIN_VERSION, os.path.basename(path_to_ebook)))
|
||||||
for keyname, userkeyhex in dedrmprefs['adeptkeys'].items():
|
for keyname, userkeyhex in dedrmprefs['adeptkeys'].items():
|
||||||
userkey = userkeyhex.decode('hex')
|
userkey = codecs.decode(userkeyhex,'hex')
|
||||||
print("{0} v{1}: Trying Encryption key {2:s}".format(PLUGIN_NAME, PLUGIN_VERSION, keyname))
|
print("{0} v{1}: Trying Encryption key {2:s}".format(PLUGIN_NAME, PLUGIN_VERSION, keyname))
|
||||||
of = self.temporary_file(".pdf")
|
of = self.temporary_file(".pdf")
|
||||||
|
|
||||||
@ -467,7 +467,7 @@ class DeDRM(FileTypePlugin):
|
|||||||
|
|
||||||
newkeys = []
|
newkeys = []
|
||||||
for keyvalue in defaultkeys:
|
for keyvalue in defaultkeys:
|
||||||
if keyvalue.encode('hex') not in dedrmprefs['adeptkeys'].values():
|
if codecs.encode(keyvalue,'hex') not in dedrmprefs['adeptkeys'].values():
|
||||||
newkeys.append(keyvalue)
|
newkeys.append(keyvalue)
|
||||||
|
|
||||||
if len(newkeys) > 0:
|
if len(newkeys) > 0:
|
||||||
@ -491,7 +491,7 @@ class DeDRM(FileTypePlugin):
|
|||||||
# Store the new successful key in the defaults
|
# Store the new successful key in the defaults
|
||||||
print("{0} v{1}: Saving a new default key".format(PLUGIN_NAME, PLUGIN_VERSION))
|
print("{0} v{1}: Saving a new default key".format(PLUGIN_NAME, PLUGIN_VERSION))
|
||||||
try:
|
try:
|
||||||
dedrmprefs.addnamedvaluetoprefs('adeptkeys','default_key',keyvalue.encode('hex'))
|
dedrmprefs.addnamedvaluetoprefs('adeptkeys','default_key',codecs.encode(keyvalue,'hex'))
|
||||||
dedrmprefs.writeprefs()
|
dedrmprefs.writeprefs()
|
||||||
print("{0} v{1}: Saved a new default key after {2:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime))
|
print("{0} v{1}: Saved a new default key after {2:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime))
|
||||||
except:
|
except:
|
||||||
@ -596,7 +596,7 @@ class DeDRM(FileTypePlugin):
|
|||||||
of = self.temporary_file(".pmlz")
|
of = self.temporary_file(".pmlz")
|
||||||
|
|
||||||
# Give the userkey, ebook and TemporaryPersistent file to the decryption function.
|
# Give the userkey, ebook and TemporaryPersistent file to the decryption function.
|
||||||
result = erdr2pml.decryptBook(path_to_ebook, of.name, True, userkey.decode('hex'))
|
result = erdr2pml.decryptBook(path_to_ebook, of.name, True, codecs.decode(userkey,'hex'))
|
||||||
|
|
||||||
of.close()
|
of.close()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user