Skip to content

Commit

Permalink
tools v5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
apprenticealf committed Mar 7, 2015
1 parent 602ff30 commit c23b903
Show file tree
Hide file tree
Showing 51 changed files with 4,352 additions and 1,088 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Ignoble Epub DeDRM - ignobleepub_v02.5_plugin.zip
Ignoble Epub DeDRM - ignobleepub_v02.6_plugin.zip
=================================================

All credit given to i♥cabbages for the original standalone scripts. I had the much easier job of converting them to a calibre plugin.
Expand All @@ -9,7 +9,7 @@ This plugin is meant to decrypt Barnes & Noble Epubs that are protected with Ado
Installation
------------

Do **NOT** select "Get plugins to enhance calibre" as this is reserved for "official" calibre plugins, instead select "Change calibre behavior" to go to Calibre's Preferences page. Under "Advanced" click on the Plugins button. Use the "Load plugin from file" button to select the plugin's zip file (ignobleepub_v02.5_plugin.zip) and click the 'Add' button. Click 'Yes' in the the "Are you sure?" dialog. Click OK in the "Success" dialog.
Do **NOT** select "Get plugins to enhance calibre" as this is reserved for "official" calibre plugins, instead select "Change calibre behavior" to go to Calibre's Preferences page. Under "Advanced" click on the Plugins button. Use the "Load plugin from file" button to select the plugin's zip file (ignobleepub_v02.6_plugin.zip) and click the 'Add' button. Click 'Yes' in the the "Are you sure?" dialog. Click OK in the "Success" dialog.


Customization
Expand All @@ -30,7 +30,7 @@ Creating New Keys:
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.

* Unique Key Name: this is a unique name you choose to help you identify the key after it's created. This name will show in the list of configured keys. Choose something that will help you remember the data (name, cc#) it was created with.
* Your Name: Your name as set in your Barnes & Noble account, My Account page, directly under PERSONAL INFORMATION. It is usually just your first name and last name separated by a space. This name will not be stored anywhere on your computer or in calibre. It will only be used in the creation of the one-way hash/key that's stored in the preferences.
* Your Name: Your name as set in your Barnes & Noble account, My Account page, directly under PERSONAL INFORMATION. It is usually just your first name and last name separated by a space. This name will not be stored anywhere on your computer or in calibre. It will only be used in the creation of the one-way hash/key that's stored in the preferences. For some B&N accounts, the name to use is the name used in the default shipping address. For some B&N accounts, the name to use is the name used for the default Credit Card.
* Credit Card number: this is the credit card number that was set as default with Barnes & Noble at the time of download. Nothing fancy here; no dashes or spaces ... just the 16 (15?) digits. Again... this number will not be stored anywhere on your computer or in calibre. It will only be used in the creation of the one-way hash/key that's stored in the preferences.
Click the 'OK" button to create and store the generated key. Or Cancel if you didn't want to create a key.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Inept Epub DeDRM - ineptepub_v02.0_plugin.zip
Inept Epub DeDRM - ineptepub_v02.1_plugin.zip
=============================================

All credit given to i♥cabbages for the original standalone scripts. I had the much easier job of converting them to a Calibre plugin.
Expand All @@ -9,7 +9,7 @@ This plugin is meant to decrypt Adobe Digital Edition Epubs that are protected w
Installation
------------

Do **NOT** select "Get plugins to enhance calibre" as this is reserved for "official" calibre plugins, instead select "Change calibre behavior" to go to Calibre's Preferences page. Under "Advanced" click on the Plugins button. Use the "Load plugin from file" button to select the plugin's zip file (ineptepub_v02.0_plugin.zip) and click the 'Add' button. Click 'Yes' in the the "Are you sure?" dialog. Click OK in the "Success" dialog.
Do **NOT** select "Get plugins to enhance calibre" as this is reserved for "official" calibre plugins, instead select "Change calibre behavior" to go to Calibre's Preferences page. Under "Advanced" click on the Plugins button. Use the "Load plugin from file" button to select the plugin's zip file (ineptepub_v02.1_plugin.zip) and click the 'Add' button. Click 'Yes' in the the "Are you sure?" dialog. Click OK in the "Success" dialog.



Expand Down Expand Up @@ -55,7 +55,7 @@ Paste the information into a comment at my blog, http://apprenticealf.wordpress.
Linux and Adobe Digital Editions ePubs
--------------------------------------

Here are the instructions for using the tools with ePub books and Adobe Digital Editions on Linux under Wine. (Thank you mclien!)
Here are the instructions for using the tools with ePub books and Adobe Digital Editions on Linux under Wine. (Thank you mclien and Fadel!)


1. download the most recent version of wine from winehq.org (1.3.29 in my case)
Expand All @@ -81,8 +81,7 @@ again as root use

'apt-get install python-tk’

4. all programms need to be installed as normal user. All these programm are installed the same way:
‘wine ‘
4. all programms need to be installed as normal user. The .exe files are installed using ‘wine <filename>’ but .msi files must be installed using ‘wine start <filename>’
we need:
a) Adobe Digital Edition 1.7.2(from: http://kb2.adobe.com/cps/403/kb403051.html)
(there is a “can’t install ADE” site, where the setup.exe hides)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Paste the information into a comment at my blog, http://apprenticealf.wordpress.
Linux and Adobe Digital Editions PDFs
--------------------------------------

Here are the instructions for using the tools with ePub books and Adobe Digital Editions on Linux under Wine. (Thank you mclien!)
Here are the instructions for using the tools with ePub books and Adobe Digital Editions on Linux under Wine. (Thank you mclien and Fadel!)


1. download the most recent version of wine from winehq.org (1.3.29 in my case)
Expand All @@ -80,10 +80,9 @@ again as root use

'apt-get install python-tk’

4. all programms need to be installed as normal user. All these programm are installed the same way:
‘wine ‘
4. all programms need to be installed as normal user. The .exe files are installed using ‘wine <filename>’ but .msi files must be installed using ‘wine start <filename>’
we need:
a) Adobe Digital Edition 1.7.2(from: http://kb2.adobe.com/cps/403/kb403051.html)
a) Adobe Digital Editions 1.7.2(from: http://kb2.adobe.com/cps/403/kb403051.html)
(there is a “can’t install ADE” site, where the setup.exe hides)

b) ActivePython-2.7.2.5-win32-x86.msi (from: http://www.activestate.com/activepython/downloads)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Kindle and Mobipocket Plugin - K4MobiDeDRM_v04.10_plugin.zip
Kindle and Mobipocket Plugin - K4MobiDeDRM_v04.18_plugin.zip
============================================================

Credit given to The Dark Reverser for the original standalone script. Credit also to the many people who have updated and expanded that script since then.
Expand All @@ -13,7 +13,7 @@ This plugin is meant to remove the DRM from .prc, .mobi, .azw, .azw1, .azw3, .az
Installation
------------

Do **NOT** select "Get plugins to enhance calibre" as this is reserved for "official" calibre plugins, instead select "Change calibre behavior" to go to Calibre's Preferences page. Under "Advanced" click on the Plugins button. Use the "Load plugin from file" button to select the plugin's zip file (K4MobiDeDRM_v04.10_plugin.zip) and click the 'Add' button. Click 'Yes' in the the "Are you sure?" dialog. Click OK in the "Success" dialog.
Do **NOT** select "Get plugins to enhance calibre" as this is reserved for "official" calibre plugins, instead select "Change calibre behavior" to go to Calibre's Preferences page. Under "Advanced" click on the Plugins button. Use the "Load plugin from file" button to select the plugin's zip file (K4MobiDeDRM_v04.18_plugin.zip) and click the 'Add' button. Click 'Yes' in the the "Are you sure?" dialog. Click OK in the "Success" dialog.

Make sure that you delete any old versions of the plugin. They might interfere with the operation of the new one.

Expand Down
9 changes: 7 additions & 2 deletions Calibre_Plugins/K4MobiDeDRM_plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@
# 0.4.11 - Fixed Linux support of K4PC
# 0.4.12 - More Linux Wine fixes
# 0.4.13 - Ancient Mobipocket files fix
# 0.4.14 - Error on invalid character in book names fix
# 0.4.15 - Another Topaz fix
# 0.4.16 - Yet another Topaz fix
# 0.4.17 - Manage to include the actual fix.
# 0.4.18 - More Topaz fixes

"""
Decrypt Amazon Kindle and Mobipocket encrypted ebooks.
"""

PLUGIN_NAME = u"Kindle and Mobipocket DeDRM"
PLUGIN_VERSION_TUPLE = (0, 4, 13)
PLUGIN_VERSION_TUPLE = (0, 4, 18)
PLUGIN_VERSION = '.'.join([str(x) for x in PLUGIN_VERSION_TUPLE])

import sys, os, re
Expand Down Expand Up @@ -170,7 +175,7 @@ def run(self, path_to_ebook):

print u"{0} v{1}: Successfully decrypted book after {2:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-starttime)

of = self.temporary_file(k4mobidedrm.cleanup_name(k4mobidedrm.unescape(book.getBookTitle()))+book.getBookExtension())
of = self.temporary_file(u"decrypted_ebook.{0}".format(book.getBookExtension()))
book.getFile(of.name)
book.cleanup()
return of.name
Expand Down
17 changes: 10 additions & 7 deletions Calibre_Plugins/K4MobiDeDRM_plugin/convert2xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,15 @@ def __init__(self, filename, dict, debug, flat_xml):

'empty_text_region' : (1, 'snippets', 1, 0),

'img' : (1, 'snippets', 1, 0),
'img.x' : (1, 'scalar_number', 0, 0),
'img.y' : (1, 'scalar_number', 0, 0),
'img.h' : (1, 'scalar_number', 0, 0),
'img.w' : (1, 'scalar_number', 0, 0),
'img.src' : (1, 'scalar_number', 0, 0),
'img.color_src' : (1, 'scalar_number', 0, 0),
'img' : (1, 'snippets', 1, 0),
'img.x' : (1, 'scalar_number', 0, 0),
'img.y' : (1, 'scalar_number', 0, 0),
'img.h' : (1, 'scalar_number', 0, 0),
'img.w' : (1, 'scalar_number', 0, 0),
'img.src' : (1, 'scalar_number', 0, 0),
'img.color_src' : (1, 'scalar_number', 0, 0),
'img.gridBeginCenter' : (1, 'scalar_number', 0, 0),
'img.gridEndCenter' : (1, 'scalar_number', 0, 0),

'paragraph' : (1, 'snippets', 1, 0),
'paragraph.class' : (1, 'scalar_text', 0, 0),
Expand Down Expand Up @@ -307,6 +309,7 @@ def __init__(self, filename, dict, debug, flat_xml):
'span.gridEndCenter' : (1, 'scalar_number', 0, 0),

'extratokens' : (1, 'snippets', 1, 0),
'extratokens.class' : (1, 'scalar_text', 0, 0),
'extratokens.type' : (1, 'scalar_text', 0, 0),
'extratokens.firstGlyph' : (1, 'scalar_number', 0, 0),
'extratokens.lastGlyph' : (1, 'scalar_number', 0, 0),
Expand Down
12 changes: 8 additions & 4 deletions Calibre_Plugins/K4MobiDeDRM_plugin/flatxml2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,14 @@ def getParaDescription(self, start, end, regtype):
ws_last = int(argres)

elif name.endswith('word.class'):
(cname, space) = argres.split('-',1)
if space == '' : space = '0'
if (cname == 'spaceafter') and (int(space) > 0) :
word_class = 'sa'
# we only handle spaceafter word class
try:
(cname, space) = argres.split('-',1)
if space == '' : space = '0'
if (cname == 'spaceafter') and (int(space) > 0) :
word_class = 'sa'
except:
pass

elif name.endswith('word.img.src'):
result.append(('img' + word_class, int(argres)))
Expand Down
2 changes: 1 addition & 1 deletion Calibre_Plugins/K4MobiDeDRM_plugin/genbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def lookup(self,val):
self.pos = val
return self.stable[self.pos]
else:
print "Error - %d outside of string table limits" % val
print "Error: %d outside of string table limits" % val
raise TpzDRMError('outside or string table limits')
# sys.exit(-1)
def getSize(self):
Expand Down
6 changes: 4 additions & 2 deletions Calibre_Plugins/K4MobiDeDRM_plugin/k4mobidedrm.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@
# 4.7 - Added timing reports, and changed search for Mac key files
# 4.8 - Much better unicode handling, matching the updated inept and ignoble scripts
# - Moved back into plugin, __init__ in plugin now only contains plugin code.
# 4.9 - Missed some invalid characters in cleanup_name

__version__ = '4.8'
__version__ = '4.9'


import sys, os, re
Expand Down Expand Up @@ -144,7 +145,7 @@ def unicode_argv():
# and with some (heavily edited) code from Paul Durrant's kindlenamer.py
def cleanup_name(name):
# substitute filename unfriendly characters
name = name.replace(u"<",u"[").replace(u">",u"]").replace(u" : ",u" – ").replace(u": ",u" – ").replace(u":",u"—").replace(u"/",u"_").replace(u"\\",u"_").replace(u"|",u"_").replace(u"\"",u"\'")
name = name.replace(u"<",u"[").replace(u">",u"]").replace(u" : ",u" – ").replace(u": ",u" – ").replace(u":",u"—").replace(u"/",u"_").replace(u"\\",u"_").replace(u"|",u"_").replace(u"\"",u"\'").replace(u"*",u"_").replace(u"?",u"")
# delete control characters
name = u"".join(char for char in name if ord(char)>=32)
# white space to single space, delete leading and trailing while space
Expand Down Expand Up @@ -220,6 +221,7 @@ def decryptBook(infile, outdir, kInfoFiles, serials, pids):
book = GetDecryptedBook(infile, kInfoFiles, serials, pids, starttime)
except Exception, e:
print u"Error decrypting book after {1:.1f} seconds: {0}".format(e.args[0],time.time()-starttime)
traceback.print_exc()
return 1

# if we're saving to the same folder as the original, use file name_
Expand Down
File renamed without changes.
Binary file modified Calibre_Plugins/ignobleepub_plugin.zip
Binary file not shown.
Binary file modified Calibre_Plugins/ignobleepub_plugin/Ignoble Epub DeDRM_Help.htm
Binary file not shown.
27 changes: 8 additions & 19 deletions Calibre_Plugins/ignobleepub_plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@
# - added ability to rename existing keys.
# 0.2.5 - Major code change to use unaltered ignobleepub.py 3.6 and
# - ignoblekeygen 2.4 and later.
# 0.2.6 - Tweaked to eliminate issue with both ignoble and inept calibre plugins installed/enabled at once

"""
Decrypt Barnes & Noble ADEPT encrypted EPUB books.
"""

PLUGIN_NAME = u"Ignoble Epub DeDRM"
PLUGIN_VERSION_TUPLE = (0, 2, 5)
PLUGIN_VERSION_TUPLE = (0, 2, 6)
PLUGIN_VERSION = '.'.join([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'
Expand Down Expand Up @@ -138,10 +139,7 @@ def run(self, path_to_ebook):
#check the book
from calibre_plugins.ignobleepub import ignobleepub
if not ignobleepub.ignobleBook(inf.name):
print u"{0} v{1}: {2} is not a secure Barnes & Noble ePub.".format(PLUGIN_NAME, PLUGIN_VERSION, os.path.basename(path_to_ebook))
# return the original file, so that no error message is generated in the GUI
return path_to_ebook

raise IGNOBLEError(u"{0} v{1}: {2} is not a secure Barnes & Noble ePub.".format(PLUGIN_NAME, PLUGIN_VERSION, os.path.basename(path_to_ebook)))

# Attempt to decrypt epub with each encryption key (generated or provided).
for keyname, userkey in cfg.prefs['keys'].items():
Expand All @@ -152,30 +150,21 @@ def run(self, path_to_ebook):
# Give the user key, ebook and TemporaryPersistent file to the decryption function.
result = ignobleepub.decryptBook(userkey, inf.name, of.name)

# Ebook is not a B&N epub... do nothing and pass it on.
# This allows a non-encrypted epub to be imported without error messages.
if result[0] == 1:
print u"{0} v{1}: {2}".format(PLUGIN_NAME, PLUGIN_VERSION, result[1])
of.close()
return path_to_ebook
break
of.close()

# Decryption was successful return the modified PersistentTemporary
# file to Calibre's import process.
if result[0] == 0:
if result == 0:
print u"{0} v{1}: Encryption successfully removed.".format(PLUGIN_NAME, PLUGIN_VERSION)
of.close()
return of.name
break

print u"{0} v{1}: {2}".format(PLUGIN_NAME, PLUGIN_VERSION, result[1])
of.close()

print u"{0} v{1}: Encryption key incorrect.".format(PLUGIN_NAME, PLUGIN_VERSION)

# Something went wrong with decryption.
# Import the original unmolested epub.
print(u"{0} v{1}: Ultimately failed to decrypt".format(PLUGIN_NAME, PLUGIN_VERSION))
return path_to_ebook
raise IGNOBLEError(u"{0} v{1}: Ultimately failed to decrypt".format(PLUGIN_NAME, PLUGIN_VERSION))
return

def is_customizable(self):
# return true to allow customization via the Plugin->Preferences.
Expand Down
Loading

0 comments on commit c23b903

Please sign in to comment.