summaryrefslogtreecommitdiffstats
path: root/DeDRM_calibre_plugin
diff options
context:
space:
mode:
authorapprenticeharper <[email protected]>2015-07-13 18:02:48 +0100
committerapprenticeharper <[email protected]>2015-07-13 18:02:48 +0100
commitc16d767b0067025f402bb86b5d3433635d58cb94 (patch)
treeadd303829ed32c3b5773c3a0618bbe0abcb27dff /DeDRM_calibre_plugin
parent6be132381749676211730b5e75a74528a2282893 (diff)
parent9a8d5f74a68536cd105ab08f640631f085490ec4 (diff)
Merge branch 'nook_url_support'
Diffstat (limited to 'DeDRM_calibre_plugin')
-rw-r--r--DeDRM_calibre_plugin/DeDRM_plugin/DeDRM_Barnes and Noble Key_Help.htm4
-rw-r--r--DeDRM_calibre_plugin/DeDRM_plugin/__init__.py4
-rw-r--r--DeDRM_calibre_plugin/DeDRM_plugin/config.py11
-rw-r--r--DeDRM_calibre_plugin/DeDRM_plugin/ignoblekey.py11
-rw-r--r--DeDRM_calibre_plugin/DeDRM_plugin/ignoblekeyfetch.py36
5 files changed, 43 insertions, 23 deletions
diff --git a/DeDRM_calibre_plugin/DeDRM_plugin/DeDRM_Barnes and Noble Key_Help.htm b/DeDRM_calibre_plugin/DeDRM_plugin/DeDRM_Barnes and Noble Key_Help.htm
index aba641d..8f22f21 100644
--- a/DeDRM_calibre_plugin/DeDRM_plugin/DeDRM_Barnes and Noble Key_Help.htm
+++ b/DeDRM_calibre_plugin/DeDRM_plugin/DeDRM_Barnes and Noble Key_Help.htm
@@ -1,4 +1,4 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
@@ -59,7 +59,7 @@ li {margin-top: 0.5em}
<p>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.</p>
<h3>NOOK Study</h3>
-<p>Books downloaded through NOOK Study may or may not use the key fetched using the above method. If a books is not decrypted successfully with any of the keys, the plugin will attempt to recover a key from the NOOK Study log file and use that.</p>
+<p>Books downloaded through NOOK Study may or may not use the key found using the above method. If a book is not decrypted successfully with any of the keys, the plugin will attempt to recover keys from the NOOK Study log file and use them.</p>
diff --git a/DeDRM_calibre_plugin/DeDRM_plugin/__init__.py b/DeDRM_calibre_plugin/DeDRM_plugin/__init__.py
index 0ba33f4..82329fe 100644
--- a/DeDRM_calibre_plugin/DeDRM_plugin/__init__.py
+++ b/DeDRM_calibre_plugin/DeDRM_plugin/__init__.py
@@ -40,8 +40,10 @@ __docformat__ = 'restructuredtext en'
# 6.2.0 - Support for getting B&N key from nook Study log. Fix for UTF-8 filenames in Adobe ePubs.
# Fix for not copying needed files. Fix for getting default Adobe key for PDFs
# 6.2.1 - Fix for non-ascii Windows user names
+# 6.2.2 - Added URL method for B&N/nook books
# 6.3.0 - Added in Kindle for Android serial number solution
+
"""
Decrypt DRMed ebooks.
"""
@@ -254,7 +256,7 @@ class DeDRM(FileTypePlugin):
# 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('bandnkeys','default_key',keyvalue)
+ dedrmprefs.addnamedvaluetoprefs('bandnkeys','nook_Study_key',keyvalue)
dedrmprefs.writeprefs()
print u"{0} v{1}: Saved a new default key after {2:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime)
except:
diff --git a/DeDRM_calibre_plugin/DeDRM_plugin/config.py b/DeDRM_calibre_plugin/DeDRM_plugin/config.py
index 432a0ee..dcba6eb 100644
--- a/DeDRM_calibre_plugin/DeDRM_plugin/config.py
+++ b/DeDRM_calibre_plugin/DeDRM_plugin/config.py
@@ -109,15 +109,14 @@ class ConfigWidget(QWidget):
self.ereader_button.setToolTip(_(u"Click to manage keys for eReader ebooks"))
self.ereader_button.setText(u"eReader ebooks")
self.ereader_button.clicked.connect(self.ereader_keys)
-
- button_layout.addWidget(self.adept_button)
- button_layout.addWidget(self.kindle_key_button)
button_layout.addWidget(self.kindle_serial_button)
button_layout.addWidget(self.kindle_android_button)
button_layout.addWidget(self.bandn_button)
button_layout.addWidget(self.mobi_button)
button_layout.addWidget(self.ereader_button)
-
+ button_layout.addWidget(self.adept_button)
+ button_layout.addWidget(self.kindle_key_button)
+
self.resize(self.sizeHint())
def kindle_serials(self):
@@ -125,7 +124,7 @@ class ConfigWidget(QWidget):
d.exec_()
def kindle_android_serials(self):
- d = ManageKeysDialog(self,u"Kindle for Andoid",self.tempdedrmprefs['androidserials'], AddAndroidSerialDialog, 'ab')
+ d = ManageKeysDialog(self,u"Kindle for Andoid Serial Number",self.tempdedrmprefs['androidserials'], AddAndroidSerialDialog, 'ab')
d.exec_()
def kindle_keys(self):
@@ -901,7 +900,7 @@ class AddAndroidSerialDialog(QDialog):
data_group_box_layout.addLayout(key_group)
key_group.addWidget(QLabel(u"Kindle for Android Serial Number:", self))
self.key_ledit = QLineEdit("", self)
- self.key_ledit.setToolTip(u"Enter a Kindle for Android serial number. These can be found using the androidkindlekey.py script.")
+ self.key_ledit.setToolTip(u"Enter a Kindle for ANdroid serial number. These can be found using the androidkindlekey.py script.")
key_group.addWidget(self.key_ledit)
key_label = QLabel(_(''), self)
key_label.setAlignment(Qt.AlignHCenter)
diff --git a/DeDRM_calibre_plugin/DeDRM_plugin/ignoblekey.py b/DeDRM_calibre_plugin/DeDRM_plugin/ignoblekey.py
index 4e9eead..dbadc5d 100644
--- a/DeDRM_calibre_plugin/DeDRM_plugin/ignoblekey.py
+++ b/DeDRM_calibre_plugin/DeDRM_plugin/ignoblekey.py
@@ -4,7 +4,7 @@
from __future__ import with_statement
# ignoblekey.py
-# Copyright © 2015 Apprentice Alf
+# Copyright © 2015 Apprentice Alf and Apprentice Harper
# Based on kindlekey.py, Copyright © 2010-2013 by some_updates and Apprentice Alf
@@ -13,13 +13,14 @@ from __future__ import with_statement
# Revision history:
# 1.0 - Initial release
+# 1.1 - remove duplicates and return last key as single key
"""
Get Barnes & Noble EPUB user key from nook Studio log file
"""
__license__ = 'GPL v3'
-__version__ = "1.0"
+__version__ = "1.1"
import sys
import os
@@ -143,7 +144,7 @@ def getNookLogFiles():
paths.add(path)
except WindowsError:
pass
-
+
for path in paths:
# look for nookStudy log file
logpath = path +'\\Barnes & Noble\\NOOKstudy\\logs\\BNClientLog.txt'
@@ -199,7 +200,7 @@ def nookkeys(files = []):
if fileKeys:
print u"Found {0} keys in the Nook Study log files".format(len(fileKeys))
keys.extend(fileKeys)
- return keys
+ return list(set(keys))
# interface for Python DeDRM
# returns single key or multiple keys, depending on path or file passed in
@@ -209,7 +210,7 @@ def getkey(outpath, files=[]):
if not os.path.isdir(outpath):
outfile = outpath
with file(outfile, 'w') as keyfileout:
- keyfileout.write(keys[0])
+ keyfileout.write(keys[-1])
print u"Saved a key to {0}".format(outfile)
else:
keycount = 0
diff --git a/DeDRM_calibre_plugin/DeDRM_plugin/ignoblekeyfetch.py b/DeDRM_calibre_plugin/DeDRM_plugin/ignoblekeyfetch.py
index 2ecbe96..c91e6f3 100644
--- a/DeDRM_calibre_plugin/DeDRM_plugin/ignoblekeyfetch.py
+++ b/DeDRM_calibre_plugin/DeDRM_plugin/ignoblekeyfetch.py
@@ -3,13 +3,14 @@
from __future__ import with_statement
-# ignoblekeyfetch.pyw, version 1.0
+# ignoblekeyfetch.pyw, version 1.1
# Copyright © 2015 Apprentice Harper
# Released under the terms of the GNU General Public Licence, version 3
# <http://www.gnu.org/licenses/>
# Based on discoveries by "Nobody You Know"
+# Code partly based on ignoblekeygen.py by several people.
# Windows users: Before running this program, you must first install Python.
# We recommend ActiveState Python 2.7.X for Windows from
@@ -17,11 +18,12 @@ from __future__ import with_statement
# Then save this script file as ignoblekeyfetch.pyw and double-click on it to run it.
#
# Mac OS X users: Save this script file as ignoblekeyfetch.pyw. You can run this
-# program from the command line (python ignoblekeygen.pyw) or by double-clicking
+# program from the command line (python ignoblekeyfetch.pyw) or by double-clicking
# it when it has been associated with PythonLauncher.
# Revision history:
-# 1.0 - Initial release
+# 1.0 - Initial version
+# 1.1 - Try second URL if first one fails
"""
Fetch Barnes & Noble EPUB user key from B&N servers using email and password
@@ -87,7 +89,7 @@ def unicode_argv():
xrange(start, argc.value)]
# if we don't have any arguments at all, just pass back script name
# this should never happen
- return [u"ignoblekeygen.py"]
+ return [u"ignoblekeyfetch.py"]
else:
argvencoding = sys.stdin.encoding
if argvencoding == None:
@@ -99,7 +101,7 @@ class IGNOBLEError(Exception):
pass
def fetch_key(email, password):
- # remove spaces and case from name and CC numbers.
+ # change name and CC numbers to utf-8 if unicode
if type(email)==unicode:
email = email.encode('utf-8')
if type(password)==unicode:
@@ -108,7 +110,9 @@ def fetch_key(email, password):
import random
random = "%030x" % random.randrange(16**30)
- import urllib, urllib2
+ import urllib, urllib2, re
+
+ # try the URL from nook for PC
fetch_url = "https://cart4.barnesandnoble.com/services/service.aspx?Version=2&acctPassword="
fetch_url += urllib.quote(password,'')+"&devID=PC_BN_2.5.6.9575_"+random+"&emailAddress="
fetch_url += urllib.quote(email,"")+"&outFormat=5&schema=1&service=1&stage=deviceHashB"
@@ -120,12 +124,26 @@ def fetch_key(email, password):
response = urllib2.urlopen(req)
the_page = response.read()
#print the_page
-
- import re
-
found = re.search('ccHash>(.+?)</ccHash', the_page).group(1)
except:
found = ''
+ if len(found)!=28:
+ # try the URL from android devices
+ fetch_url = "https://cart4.barnesandnoble.com/services/service.aspx?Version=2&acctPassword="
+ fetch_url += urllib.quote(password,'')+"&devID=hobbes_9.3.50818_"+random+"&emailAddress="
+ fetch_url += urllib.quote(email,"")+"&outFormat=5&schema=1&service=1&stage=deviceHashB"
+ #print fetch_url
+
+ found = ''
+ try:
+ req = urllib2.Request(fetch_url)
+ response = urllib2.urlopen(req)
+ the_page = response.read()
+ #print the_page
+ found = re.search('ccHash>(.+?)</ccHash', the_page).group(1)
+ except:
+ found = ''
+
return found