diff --git a/DeDRM_Macintosh_Application/DeDRM.app/Contents/Info.plist b/DeDRM_Macintosh_Application/DeDRM.app/Contents/Info.plist
index 6ed5ade..86275f3 100644
--- a/DeDRM_Macintosh_Application/DeDRM.app/Contents/Info.plist
+++ b/DeDRM_Macintosh_Application/DeDRM.app/Contents/Info.plist
@@ -24,19 +24,19 @@
If you have upgraded from an earlier version of the plugin, any existing Barnes and Noble keys will have been automatically imported, so you might not need to do any more configuration. Continue reading for key generation and management instructions.
-In mid-2014, Barnes & Noble changed the way they generated encryption keys. Instead of deriving the key from the user's name and credit card number, they started generating a random key themselves, sending that key through to devices when they connected to the B&N servers. This means that some users will find that no combination of their name and CC# will work in decrypting their ebooks.
+ +There is a work-around. B&N's desktop apps for Mac and Windows (nook for Mac/PC, nookStudy) generate a log file that contains the encryption key. For Mac the log file can be found somewhere in [user folder]/Library/Application Support/Barnes & Noble/ and for Windows the log file can be found somewhere in C:\Users\admin\AppData\Roaming\Barnes & Noble\
+In both cases, the log file will be called BNClientLog.txt
+You will need to open the application, sign in to your account, and download your books, checking that you can read them in the application, and then quit the application.
+Then you must open the log file in a text editor and search for CCHashResponseV1. Immediately after that text should be some more text, similar to ccHash: "rLYiGD+vcPoXvsj/87kDAb1AkBy="
+
Copy the text after ccHash, include the " marks. Save it in a new text file, with file name extension .b64
+Follow the instructions below "Importing Existing Keyfiles:" to import that newly saved file into the preferences.
+ +On the right-hand side of the plugin’s customization dialog, you will see a button with an icon that looks like a green plus sign (+). Clicking this button will open a new dialog for entering the necessary data to generate a new key.
At the bottom-left of the plugin’s customization dialog, you will see a button labeled "Import Existing Keyfiles". Use this button to import existing ‘.b64’ key files. Key files might come from being exported from this or older plugins, or may have been generated using the original i♥cabbages script.
+At the bottom-left of the plugin’s customization dialog, you will see a button labeled "Import Existing Keyfiles". Use this button to import existing ‘.b64’ key files. Key files might come from being exported from this or older plugins, or may have been generated using the original i♥cabbages script, or you may have made it by following the instructions above.
Once done creating/deleting/renaming/importing decryption keys, click Close to exit the customization dialogue. Your changes wil only be saved permanently when you click OK in the main configuration dialog.
diff --git a/DeDRM_calibre_plugin/DeDRM_plugin/DeDRM_Help.htm b/DeDRM_calibre_plugin/DeDRM_plugin/DeDRM_Help.htm index f0c51a8..019ba36 100644 --- a/DeDRM_calibre_plugin/DeDRM_plugin/DeDRM_Help.htm +++ b/DeDRM_calibre_plugin/DeDRM_plugin/DeDRM_Help.htm @@ -17,7 +17,7 @@ p {margin-top: 0} -This plugin removes DRM from ebooks when they are imported into calibre. If you already have DRMed ebooks in your calibre library, you will need to remove them and import them again.
diff --git a/DeDRM_calibre_plugin/DeDRM_plugin/__init__.py b/DeDRM_calibre_plugin/DeDRM_plugin/__init__.py index 232b6bc..016c9ef 100644 --- a/DeDRM_calibre_plugin/DeDRM_plugin/__init__.py +++ b/DeDRM_calibre_plugin/DeDRM_plugin/__init__.py @@ -36,13 +36,14 @@ __docformat__ = 'restructuredtext en' # 6.0.7 - Error handling for incomplete PDF metadata # 6.0.8 - Fixes a Wine key issue and topaz support # 6.0.9 - Ported to work with newer versions of Calibre (moved to Qt5). Still supports older Qt4 versions. +# 6.1.0 - Fixed multiple books import problem and PDF import with no key problem """ Decrypt DRMed ebooks. """ PLUGIN_NAME = u"DeDRM" -PLUGIN_VERSION_TUPLE = (6, 0, 9) +PLUGIN_VERSION_TUPLE = (6, 1, 0) PLUGIN_VERSION = u".".join([unicode(str(x)) for x in PLUGIN_VERSION_TUPLE]) # Include an html helpfile in the plugin's zipfile with the following name. RESOURCE_NAME = PLUGIN_NAME + '_Help.htm' @@ -90,21 +91,22 @@ class DeDRM(FileTypePlugin): on_import = True priority = 600 - def initialize(self): - # convert old preferences, if necessary. - try: - from calibre_plugins.dedrm.prefs import convertprefs - convertprefs() - except: - traceback.print_exc() + def load_resources(self, names): + print u"{0} v{1}: In load_resources".format(PLUGIN_NAME, PLUGIN_VERSION) + return {} + def __init__(self, plugin_path): + print u"{0} v{1}: In __init__".format(PLUGIN_NAME, PLUGIN_VERSION) + super(DeDRM, self).__init__(plugin_path) """ - Dynamic modules can't be imported/loaded from a zipfile... so this routine - runs whenever the plugin gets initialized. This will extract the appropriate + Dynamic modules can't be imported/loaded from a zipfile. + So this routine will extract the appropriate library for the target OS and copy it to the 'alfcrypto' subdirectory of calibre's configuration directory. That 'alfcrypto' directory is then inserted into the syspath (as the very first entry) in the run function so the CDLL stuff will work in the alfcrypto.py script. + + The extraction only happens once per version of the plugin """ try: if iswindows: @@ -126,13 +128,31 @@ class DeDRM(FileTypePlugin): self.alfdir = os.path.join(self.maindir,u"libraryfiles") if not os.path.exists(self.alfdir): os.mkdir(self.alfdir) - for entry, data in lib_dict.items(): - file_path = os.path.join(self.alfdir, entry) - open(file_path,'wb').write(data) + # only continue if we've never run this version of the plugin before + self.verdir = os.path.join(self.maindir,PLUGIN_VERSION) + print u"{0} v{1}: verdir {2}".format(PLUGIN_NAME, PLUGIN_VERSION, self.verdir) + if not os.path.exists(self.verdir): + print u"{0} v{1}: Copying needed libraries from zip".format(PLUGIN_NAME, PLUGIN_VERSION) + os.mkdir(self.verdir) + for entry, data in lib_dict.items(): + file_path = os.path.join(self.alfdir, entry) + os.remove(file_path) + open(file_path,'wb').write(data) except Exception, e: traceback.print_exc() raise + + + def initialize(self): + print u"{0} v{1}: In initialize".format(PLUGIN_NAME, PLUGIN_VERSION) + # convert old preferences, if necessary. + try: + from calibre_plugins.dedrm.prefs import convertprefs + convertprefs() + except: + traceback.print_exc() + def ePubDecrypt(self,path_to_ebook): # Create a TemporaryPersistent file to work with. # Check original epub archive for zip errors. @@ -298,63 +318,63 @@ class DeDRM(FileTypePlugin): # Return the modified PersistentTemporary file to calibre. return of.name - # perhaps we need to get a new default ADE key - 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) + # perhaps we need to get a new default ADE key + 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 - defaultkeys = [] + # get the default Adobe keys + defaultkeys = [] - if iswindows or isosx: - import calibre_plugins.dedrm.adobekey as adobe + if iswindows or isosx: + import calibre_plugins.dedrm.adobekey as adobe - try: - defaultkeys = adobe.adeptkeys() - except: - pass - else: - # linux - try: - from wineutils import WineGetKeys + try: + defaultkeys = adobe.adeptkeys() + except: + pass + else: + # linux + try: + from wineutils import WineGetKeys - scriptpath = os.path.join(self.alfdir,u"adobekey.py") - defaultkeys = WineGetKeys(scriptpath, u".der",dedrmprefs['adobewineprefix']) - except: - pass + scriptpath = os.path.join(self.alfdir,u"adobekey.py") + defaultkeys = WineGetKeys(scriptpath, u".der",dedrmprefs['adobewineprefix']) + except: + pass - newkeys = [] - for keyvalue in defaultkeys: - if keyvalue.encode('hex') not in dedrmprefs['adeptkeys'].values(): - newkeys.append(keyvalue) + newkeys = [] + for keyvalue in defaultkeys: + if keyvalue.encode('hex') not in dedrmprefs['adeptkeys'].values(): + newkeys.append(keyvalue) - if len(newkeys) > 0: - try: - for i,userkey in enumerate(newkeys): - print u"{0} v{1}: Trying a new default key".format(PLUGIN_NAME, PLUGIN_VERSION) - of = self.temporary_file(u".pdf") + if len(newkeys) > 0: + try: + for i,userkey in enumerate(newkeys): + print u"{0} v{1}: Trying a new default key".format(PLUGIN_NAME, PLUGIN_VERSION) + 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. + try: + result = ineptepdf.decryptBook(userkey, inf.name, of.name) + except: + result = 1 + + of.close() + + if result == 0: + # Decryption was a success + # Store the new successful key in the defaults + print u"{0} v{1}: Saving a new default key".format(PLUGIN_NAME, PLUGIN_VERSION) try: - result = ineptepdf.decryptBook(userkey, inf.name, of.name) + dedrmprefs.addnamedvaluetoprefs('adeptkeys','default_key',keyvalue.encode('hex')) + dedrmprefs.writeprefs() except: - result = 1 + traceback.print_exc() + # Return the modified PersistentTemporary file to calibre. + return of.name - of.close() - - if result == 0: - # Decryption was a success - # Store the new successful key in the defaults - print u"{0} v{1}: Saving a new default key".format(PLUGIN_NAME, PLUGIN_VERSION) - try: - dedrmprefs.addnamedvaluetoprefs('adeptkeys','default_key',keyvalue.encode('hex')) - dedrmprefs.writeprefs() - except: - traceback.print_exc() - # Return the modified PersistentTemporary file to calibre. - return of.name - - 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) - except Exception, e: - pass + 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) + except Exception, e: + pass # Something went wrong with decryption. print u"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds.\nRead the FAQs at Alf's blog: http://apprenticealf.wordpress.com/".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime) diff --git a/ReadMe_First.txt b/ReadMe_First.txt index b08fd6c..485644e 100644 --- a/ReadMe_First.txt +++ b/ReadMe_First.txt @@ -1,7 +1,7 @@ Welcome to the tools! ===================== -This ReadMe_First.txt is meant to give users a quick overview of what is available and how to get started. This document is part of the Tools v6.0.5 archive from Apprentice Alf's Blog: http://apprenticealf.wordpress.com/ +This ReadMe_First.txt is meant to give users a quick overview of what is available and how to get started. This document is part of the Tools v6.1.0 archive from Apprentice Alf's Blog: http://apprenticealf.wordpress.com/ The is archive includes tools to remove DRM from: @@ -71,7 +71,7 @@ For more detailed instructions, see the DeDRM_App_ReadMe.txt file in the DeDRM_W Other_Tools ----------- -This folder includes other tools that may be useful for DRMed ebooks from certain sources or for Linux users. Most users won't need any of these tools. +This is now a separate archive and includes other tools that may be useful for DRMed ebooks from certain sources or for Linux users. Most users won't need any of these tools. Key_Generation_Scripts This folder contains python scripts that creates a keyfiles for Barnes and Noble ePubs, Adobe Digital Editions ePubs and Kindle for Mac/PC ebooks.