printu"{0} v{1}: Exception when trying to decrypt after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Exception when trying to decrypt after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
traceback.print_exc()
traceback.print_exc()
result=1
result=1
@ -242,10 +243,10 @@ class DeDRM(FileTypePlugin):
# Return the modified PersistentTemporary file to calibre.
# Return the modified PersistentTemporary file to calibre.
returnof.name
returnof.name
printu"{0} v{1}: Failed to decrypt with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,keyname_masked,time.time()-self.starttime)
print(u"{0} v{1}: Failed to decrypt with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,keyname_masked,time.time()-self.starttime))
# perhaps we should see if we can get a key from a log file
# perhaps we should see if we can get a key from a log file
printu"{0} v{1}: Looking for new NOOK Study Keys after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Looking for new NOOK Study Keys after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
printu"{0} v{1}: Saved a new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Saved a new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
except:
except:
printu"{0} v{1}: Exception saving a new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Exception saving a new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
traceback.print_exc()
traceback.print_exc()
# Return the modified PersistentTemporary file to calibre.
# Return the modified PersistentTemporary file to calibre.
returnof.name
returnof.name
printu"{0} v{1}: Failed to decrypt with new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Failed to decrypt with new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
exceptException,e:
exceptException,e:
pass
pass
printu"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
raiseDeDRMError(u"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
raiseDeDRMError(u"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
# import the Adobe Adept ePub handler
# import the Adobe Adept ePub handler
importcalibre_plugins.dedrm.ineptepubasineptepub
importcalibre_plugins.dedrm.ineptepubasineptepub
ifineptepub.adeptBook(inf.name):
ifineptepub.adeptBook(inf.name):
printu"{0} v{1}: {2} is a secure Adobe Adept ePub".format(PLUGIN_NAME,PLUGIN_VERSION,os.path.basename(path_to_ebook))
print(u"{0} v{1}: {2} is a secure Adobe Adept ePub".format(PLUGIN_NAME,PLUGIN_VERSION,os.path.basename(path_to_ebook)))
# Attempt to decrypt epub with each encryption key (generated or provided).
# Attempt to decrypt epub with each encryption key (generated or provided).
printu"{0} v{1}: Exception when decrypting after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Exception when decrypting after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
traceback.print_exc()
traceback.print_exc()
result=1
result=1
try:
try:
of.close()
of.close()
except:
except:
printu"{0} v{1}: Exception closing temporary file after {2:.1f} seconds. Ignored.".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Exception closing temporary file after {2:.1f} seconds. Ignored.".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
ifresult==0:
ifresult==0:
# Decryption was successful.
# Decryption was successful.
# Return the modified PersistentTemporary file to calibre.
# Return the modified PersistentTemporary file to calibre.
printu"{0} v{1}: Decrypted with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,keyname,time.time()-self.starttime)
print(u"{0} v{1}: Decrypted with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,keyname,time.time()-self.starttime))
returnof.name
returnof.name
printu"{0} v{1}: Failed to decrypt with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,keyname,time.time()-self.starttime)
print(u"{0} v{1}: Failed to decrypt with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,keyname,time.time()-self.starttime))
# perhaps we need to get a new default ADE key
# perhaps we need to get a new default ADE key
printu"{0} v{1}: Looking for new default Adobe Digital Editions Keys after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Looking for new default Adobe Digital Editions Keys after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
# get the default Adobe keys
# get the default Adobe keys
defaultkeys=[]
defaultkeys=[]
@ -360,7 +361,7 @@ class DeDRM(FileTypePlugin):
self.default_key=defaultkeys[0]
self.default_key=defaultkeys[0]
except:
except:
printu"{0} v{1}: Exception when getting default Adobe Key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Exception when getting default Adobe Key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
traceback.print_exc()
traceback.print_exc()
self.default_key=u""
self.default_key=u""
@ -372,14 +373,14 @@ class DeDRM(FileTypePlugin):
iflen(newkeys)>0:
iflen(newkeys)>0:
try:
try:
fori,userkeyinenumerate(newkeys):
fori,userkeyinenumerate(newkeys):
printu"{0} v{1}: Trying a new default key".format(PLUGIN_NAME,PLUGIN_VERSION)
print(u"{0} v{1}: Trying a new default key".format(PLUGIN_NAME,PLUGIN_VERSION))
of=self.temporary_file(u".epub")
of=self.temporary_file(u".epub")
# Give the user key, ebook and TemporaryPersistent file to the decryption function.
# Give the user key, ebook and TemporaryPersistent file to the decryption function.
printu"{0} v{1}: Saved a new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Saved a new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
except:
except:
printu"{0} v{1}: Exception when saving a new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Exception when saving a new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
traceback.print_exc()
traceback.print_exc()
printu"{0} v{1}: Decrypted with new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Decrypted with new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
# Return the modified PersistentTemporary file to calibre.
# Return the modified PersistentTemporary file to calibre.
returnof.name
returnof.name
printu"{0} v{1}: Failed to decrypt with new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Failed to decrypt with new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
exceptException,e:
exceptException,e:
printu"{0} v{1}: Unexpected Exception trying a new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Unexpected Exception trying a new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
traceback.print_exc()
traceback.print_exc()
pass
pass
# Something went wrong with decryption.
# Something went wrong with decryption.
printu"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
raiseDeDRMError(u"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
raiseDeDRMError(u"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
# Not a Barnes & Noble nor an Adobe Adept
# Not a Barnes & Noble nor an Adobe Adept
# Import the fixed epub.
# Import the fixed epub.
printu"{0} v{1}: “{2}” is neither an Adobe Adept nor a Barnes & Noble encrypted ePub".format(PLUGIN_NAME,PLUGIN_VERSION,os.path.basename(path_to_ebook))
print(u"{0} v{1}: “{2}” is neither an Adobe Adept nor a Barnes & Noble encrypted ePub".format(PLUGIN_NAME,PLUGIN_VERSION,os.path.basename(path_to_ebook)))
raiseDeDRMError(u"{0} v{1}: Couldn't decrypt after {2:.1f} seconds. DRM free perhaps?".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
raiseDeDRMError(u"{0} v{1}: Couldn't decrypt after {2:.1f} seconds. DRM free perhaps?".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
defPDFDecrypt(self,path_to_ebook):
defPDFDecrypt(self,path_to_ebook):
@ -421,17 +422,17 @@ class DeDRM(FileTypePlugin):
dedrmprefs=prefs.DeDRM_Prefs()
dedrmprefs=prefs.DeDRM_Prefs()
# Attempt to decrypt epub with each encryption key (generated or provided).
# Attempt to decrypt epub with each encryption key (generated or provided).
printu"{0} v{1}: {2} is a PDF ebook".format(PLUGIN_NAME,PLUGIN_VERSION,os.path.basename(path_to_ebook))
print(u"{0} v{1}: {2} is a PDF ebook".format(PLUGIN_NAME,PLUGIN_VERSION,os.path.basename(path_to_ebook)))
printu"{0} v{1}: Exception when decrypting after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Exception when decrypting after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
traceback.print_exc()
traceback.print_exc()
result=1
result=1
@ -442,10 +443,10 @@ class DeDRM(FileTypePlugin):
# Return the modified PersistentTemporary file to calibre.
# Return the modified PersistentTemporary file to calibre.
returnof.name
returnof.name
printu"{0} v{1}: Failed to decrypt with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,keyname,time.time()-self.starttime)
print(u"{0} v{1}: Failed to decrypt with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,keyname,time.time()-self.starttime))
# perhaps we need to get a new default ADE key
# perhaps we need to get a new default ADE key
printu"{0} v{1}: Looking for new default Adobe Digital Editions Keys after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Looking for new default Adobe Digital Editions Keys after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
# get the default Adobe keys
# get the default Adobe keys
defaultkeys=[]
defaultkeys=[]
@ -463,7 +464,7 @@ class DeDRM(FileTypePlugin):
self.default_key=defaultkeys[0]
self.default_key=defaultkeys[0]
except:
except:
printu"{0} v{1}: Exception when getting default Adobe Key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Exception when getting default Adobe Key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
traceback.print_exc()
traceback.print_exc()
self.default_key=u""
self.default_key=u""
@ -475,14 +476,14 @@ class DeDRM(FileTypePlugin):
iflen(newkeys)>0:
iflen(newkeys)>0:
try:
try:
fori,userkeyinenumerate(newkeys):
fori,userkeyinenumerate(newkeys):
printu"{0} v{1}: Trying a new default key".format(PLUGIN_NAME,PLUGIN_VERSION)
print(u"{0} v{1}: Trying a new default key".format(PLUGIN_NAME,PLUGIN_VERSION))
of=self.temporary_file(u".pdf")
of=self.temporary_file(u".pdf")
# Give the user key, ebook and TemporaryPersistent file to the decryption function.
# Give the user key, ebook and TemporaryPersistent file to the decryption function.
printu"{0} v{1}: Saved a new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Saved a new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
except:
except:
printu"{0} v{1}: Exception when saving a new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Exception when saving a new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
traceback.print_exc()
traceback.print_exc()
# Return the modified PersistentTemporary file to calibre.
# Return the modified PersistentTemporary file to calibre.
returnof.name
returnof.name
printu"{0} v{1}: Failed to decrypt with new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Failed to decrypt with new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
exceptException,e:
exceptException,e:
pass
pass
# Something went wrong with decryption.
# Something went wrong with decryption.
printu"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
raiseDeDRMError(u"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
raiseDeDRMError(u"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
@ -538,8 +539,8 @@ class DeDRM(FileTypePlugin):
decoded=False
decoded=False
# perhaps we need to get a new default Kindle for Mac/PC key
# perhaps we need to get a new default Kindle for Mac/PC key
defaultkeys=[]
defaultkeys=[]
printu"{0} v{1}: Failed to decrypt with error: {2}".format(PLUGIN_NAME,PLUGIN_VERSION,e.args[0])
print(u"{0} v{1}: Failed to decrypt with error: {2}".format(PLUGIN_NAME,PLUGIN_VERSION,e.args[0]))
printu"{0} v{1}: Looking for new default Kindle Key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Looking for new default Kindle Key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
#if you reached here then no luck raise and exception
#if you reached here then no luck raise and exception
printu"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
raiseDeDRMError(u"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
raiseDeDRMError(u"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
of=self.temporary_file(book.getBookExtension())
of=self.temporary_file(book.getBookExtension())
@ -594,7 +595,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).
# Give the userkey, ebook and TemporaryPersistent file to the decryption function.
# Give the userkey, ebook and TemporaryPersistent file to the decryption function.
@ -605,12 +606,12 @@ class DeDRM(FileTypePlugin):
# Decryption was successful return the modified PersistentTemporary
# Decryption was successful return the modified PersistentTemporary
# file to Calibre's import process.
# file to Calibre's import process.
ifresult==0:
ifresult==0:
printu"{0} v{1}: Successfully decrypted with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,keyname_masked,time.time()-self.starttime)
print(u"{0} v{1}: Successfully decrypted with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,keyname_masked,time.time()-self.starttime))
returnof.name
returnof.name
printu"{0} v{1}: Failed to decrypt with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,keyname_masked,time.time()-self.starttime)
print(u"{0} v{1}: Failed to decrypt with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,keyname_masked,time.time()-self.starttime))
printu"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime)
print(u"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
raiseDeDRMError(u"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
raiseDeDRMError(u"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
@ -620,7 +621,7 @@ class DeDRM(FileTypePlugin):
sys.stdout=SafeUnbuffered(sys.stdout)
sys.stdout=SafeUnbuffered(sys.stdout)
sys.stderr=SafeUnbuffered(sys.stderr)
sys.stderr=SafeUnbuffered(sys.stderr)
printu"{0} v{1}: Trying to decrypt {2}".format(PLUGIN_NAME,PLUGIN_VERSION,os.path.basename(path_to_ebook))
print(u"{0} v{1}: Trying to decrypt {2}".format(PLUGIN_NAME,PLUGIN_VERSION,os.path.basename(path_to_ebook)))