print("{0} v{1}: Trying a new default key".format(PLUGIN_NAME,PLUGIN_VERSION))
print("{0} v{1}: Trying a new default key".format(PLUGIN_NAME,PLUGIN_VERSION))
of=self.temporary_file(".epub")
of=self.temporary_file(".epub")
@ -451,10 +459,14 @@ class DeDRM(FileTypePlugin):
returnself.postProcessEPUB(of.name)
returnself.postProcessEPUB(of.name)
print("{0} v{1}: Failed to decrypt with new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
print("{0} v{1}: Failed to decrypt with new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
returninf.name
except:
except:
pass
pass
# Looks like we were unable to decrypt the book ...
returninf.name
else:
else:
# This is a "normal" Adobe eBook.
# This is a "normal" Adobe eBook.
@ -611,17 +623,13 @@ class DeDRM(FileTypePlugin):
pass
pass
# Something went wrong with decryption.
# Something went wrong with decryption.
print("{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("{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
raiseDeDRMError("{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("{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
# Not a Barnes & Noble nor an Adobe Adept
# Probably a DRM-free EPUB, but we should still check for fonts.
print("{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)))
# Give the user key, ebook and TemporaryPersistent file to the decryption function.
# Give the user key, ebook and TemporaryPersistent file to the decryption function.
@ -951,8 +958,8 @@ class DeDRM(FileTypePlugin):
pass
pass
ifnotdecoded:
ifnotdecoded:
#if you reached here then no luck raise and exception
#if you reached here then no luck raise and exception
print("{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("{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
raiseDeDRMError("{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("{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/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())
book.getFile(of.name)
book.getFile(of.name)
@ -969,8 +976,7 @@ 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).
# Give the userkey, ebook and TemporaryPersistent file to the decryption function.
# Give the userkey, ebook and TemporaryPersistent file to the decryption function.
@ -981,13 +987,13 @@ 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:
print("{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("{0} v{1}: Successfully decrypted with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,keyname,time.time()-self.starttime))
returnof.name
returnof.name
print("{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("{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("{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("{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
raiseDeDRMError("{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("{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))