tools v5.4
This commit is contained in:
@@ -55,6 +55,9 @@ from __future__ import with_statement
|
||||
# 0.1.3 - add in fix for improper rejection of session bookkeys with len(bookkey) = length + 1
|
||||
# 0.1.4 - update to the new calibre plugin interface
|
||||
# 0.1.5 - synced to ineptpdf 7.11
|
||||
# 0.1.6 - Fix for potential problem with PyCrypto
|
||||
# 0.1.7 - Fix for potential problem with ADE keys and fix possible output/unicode problem
|
||||
|
||||
"""
|
||||
Decrypts Adobe ADEPT-encrypted PDF files.
|
||||
"""
|
||||
@@ -2137,15 +2140,25 @@ class IneptPDFDeDRM(FileTypePlugin):
|
||||
Credit given to I <3 Cabbages for the original stand-alone scripts.'
|
||||
supported_platforms = ['linux', 'osx', 'windows']
|
||||
author = 'DiapDealer'
|
||||
version = (0, 1, 5)
|
||||
version = (0, 1, 7)
|
||||
minimum_calibre_version = (0, 7, 55) # for the new plugin interface
|
||||
file_types = set(['pdf'])
|
||||
on_import = True
|
||||
|
||||
def run(self, path_to_ebook):
|
||||
from calibre_plugins.ineptpdf import outputfix
|
||||
|
||||
if sys.stdout.encoding == None:
|
||||
sys.stdout = outputfix.getwriter('utf-8')(sys.stdout)
|
||||
else:
|
||||
sys.stdout = outputfix.getwriter(sys.stdout.encoding)(sys.stdout)
|
||||
if sys.stderr.encoding == None:
|
||||
sys.stderr = outputfix.getwriter('utf-8')(sys.stderr)
|
||||
else:
|
||||
sys.stderr = outputfix.getwriter(sys.stderr.encoding)(sys.stderr)
|
||||
|
||||
global ARC4, RSA, AES
|
||||
|
||||
|
||||
ARC4, RSA, AES = _load_crypto()
|
||||
|
||||
if AES == None or RSA == None or ARC4 == None:
|
||||
@@ -2162,10 +2175,13 @@ class IneptPDFDeDRM(FileTypePlugin):
|
||||
files = os.listdir(confpath)
|
||||
filefilter = re.compile("\.der$", re.IGNORECASE)
|
||||
files = filter(filefilter.search, files)
|
||||
foundDefault = False
|
||||
|
||||
if files:
|
||||
try:
|
||||
for filename in files:
|
||||
if filename[:16] == 'calibre-adeptkey':
|
||||
foundDefault = True
|
||||
fpath = os.path.join(confpath, filename)
|
||||
with open(fpath, 'rb') as f:
|
||||
userkeys.append(f.read())
|
||||
@@ -2173,22 +2189,23 @@ class IneptPDFDeDRM(FileTypePlugin):
|
||||
except IOError:
|
||||
print 'IneptPDF: Error reading keyfiles from config directory.'
|
||||
pass
|
||||
else:
|
||||
|
||||
if not foundDefault:
|
||||
# Try to find key from ADE install and save the key in
|
||||
# Calibre's configuration directory for future use.
|
||||
if iswindows or isosx:
|
||||
# ADE key retrieval script.
|
||||
from calibre_plugins.ineptpdf.ade_key import retrieve_key
|
||||
# ADE key retrieval script included in respective OS folder.
|
||||
from calibre_plugins.ineptepub.ineptkey import retrieve_keys
|
||||
try:
|
||||
keydata = retrieve_key()
|
||||
userkeys.append(keydata)
|
||||
keypath = os.path.join(confpath, 'calibre-adeptkey.der')
|
||||
with open(keypath, 'wb') as f:
|
||||
f.write(keydata)
|
||||
print 'IneptPDF: Created keyfile from ADE install.'
|
||||
keys = retrieve_keys()
|
||||
for i,key in enumerate(keys):
|
||||
userkeys.append(key)
|
||||
keypath = os.path.join(confpath, 'calibre-adeptkey{0:d}.der'.format(i))
|
||||
open(keypath, 'wb').write(key)
|
||||
print 'IneptPDF: Created keyfile %s from ADE install.' % keypath
|
||||
except:
|
||||
print 'IneptPDF: Couldn\'t Retrieve key from ADE install.'
|
||||
pass
|
||||
print 'IneptPDF: Couldn\'t Retrieve key from ADE install.'
|
||||
pass
|
||||
|
||||
if not userkeys:
|
||||
# No user keys found... bail out.
|
||||
|
||||
Reference in New Issue
Block a user