@ -41,3 +41,7 @@ List of changes since the fork of Apprentice Harper's repository:
- Add code to support importing multiple decryption keys from ADE (click the 'plus' button multiple times).
- Improve epubtest.py to also detect Kobo & Apple DRM.
- Small updates to the LCP DRM error messages.
- Merge ignobleepub into ineptepub so there's no duplicate code.
- Support extracting the B&N / Nook key from the NOOK Microsoft Store application (based on [this script](https://github.com/noDRM/DeDRM_tools/discussions/9) by fesiwi).
- Support extracting the B&N / Nook key from a data dump of the NOOK Android application.
- Support adding an existing B&N key base64 string without having to write it to a file first.
print("{0} v{1}: Exception when getting default NOOK Microsoft App keys after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
traceback.print_exc()
# Give the user key, ebook and TemporaryPersistent file to the decryption function.
print("{0} v{1}: Saved a new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
except:
print("{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()
# Return the modified PersistentTemporary file to calibre.
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))
except:
pass
print("{0} v{1}: Failed to decrypt with new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
exceptExceptionase:
else:
# This is a "normal" Adobe eBook.
book_uuid=None
try:
# This tries to figure out which Adobe account UUID the book is licensed for.
# If we know that we can directly use the correct key instead of having to
# try them all.
book_uuid=ineptepub.adeptGetUserUUID(inf.name)
except:
pass
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))
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))
ifbook_uuidisNone:
print("{0} v{1}: {2} is a secure Adobe Adept ePub".format(PLUGIN_NAME,PLUGIN_VERSION,os.path.basename(path_to_ebook)))
else:
print("{0} v{1}: {2} is a secure Adobe Adept ePub for UUID {3}".format(PLUGIN_NAME,PLUGIN_VERSION,os.path.basename(path_to_ebook),book_uuid))
# import the Adobe Adept ePub handler
importcalibre_plugins.dedrm.ineptepubasineptepub
ifineptepub.adeptBook(inf.name):
book_uuid=None
try:
# This tries to figure out which Adobe account UUID the book is licensed for.
# If we know that we can directly use the correct key instead of having to
# try them all.
book_uuid=ineptepub.adeptGetUserUUID(inf.name)
except:
pass
ifbook_uuidisnotNone:
# Check if we have a key with that UUID in its name:
print("{0} v{1}: Book uses unsupported (too new) Adobe DRM.".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
returnself.postProcessEPUB(path_to_ebook)
except:
print("{0} v{1}: Exception when decrypting after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
traceback.print_exc()
result=1
try:
of.close()
except:
print("{0} v{1}: Exception closing temporary file after {2:.1f} seconds. Ignored.".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
ifresult==0:
# Decryption was successful.
# Return the modified PersistentTemporary file to calibre.
print("{0} v{1}: Decrypted with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,keyname,time.time()-self.starttime))
returnself.postProcessEPUB(of.name)
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))
# perhaps we need to get a new default ADE key
print("{0} v{1}: Looking for new default Adobe Digital Editions Keys after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
ifresult==0:
# Decryption was successful.
# Return the modified PersistentTemporary file to calibre.
print("{0} v{1}: Decrypted with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,keyname,time.time()-self.starttime))
returnself.postProcessEPUB(of.name)
# get the default Adobe keys
defaultkeys=[]
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))
try:
ifiswindowsorisosx:
fromcalibre_plugins.dedrm.adobekeyimportadeptkeys
# perhaps we need to get a new default ADE key
print("{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("{0} v{1}: Saved a new default key after {2:.1f} seconds".format(PLUGIN_NAME,PLUGIN_VERSION,time.time()-self.starttime))
except:
print("{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()
print("{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.
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))
exceptExceptionase:
print("{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()
pass
# 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))
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))
# 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))
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))
# 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)))
# 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)))