2
0
mirror of https://github.com/apprenticeharper/DeDRM_tools synced 2024-11-11 01:10:26 +00:00

Change to ineptpdf.py, so that we throw an exception for DRM-free PDFs, rather than processing them.

This commit is contained in:
Apprentice Harper 2016-08-10 06:40:48 +01:00
parent 908ebc5c58
commit c2615c4d3b
10 changed files with 35 additions and 25 deletions

View File

@ -24,7 +24,7 @@
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>droplet</string> <string>droplet</string>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
<string>DeDRM AppleScript 6.5.0 Written 20102016 by Apprentice Alf et al.</string> <string>DeDRM AppleScript 6.5.1 Written 20102016 by Apprentice Alf et al.</string>
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>DeDRM</string> <string>DeDRM</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
@ -36,7 +36,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>6.5.0</string> <string>6.5.1</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>dplt</string> <string>dplt</string>
<key>LSRequiresCarbon</key> <key>LSRequiresCarbon</key>

View File

@ -54,6 +54,7 @@ __docformat__ = 'restructuredtext en'
# 6.5.0 - Big update to Macintosh app # 6.5.0 - Big update to Macintosh app
# Fix for some more 'new' tags in Topaz ebooks. # Fix for some more 'new' tags in Topaz ebooks.
# Fix an error in wineutils.py # Fix an error in wineutils.py
# 6.5.1 - Updated version number, added PDF check for DRM-free documents
""" """
@ -61,7 +62,7 @@ Decrypt DRMed ebooks.
""" """
PLUGIN_NAME = u"DeDRM" PLUGIN_NAME = u"DeDRM"
PLUGIN_VERSION_TUPLE = (6, 5, 0) PLUGIN_VERSION_TUPLE = (6, 5, 1)
PLUGIN_VERSION = u".".join([unicode(str(x)) for x in PLUGIN_VERSION_TUPLE]) 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. # Include an html helpfile in the plugin's zipfile with the following name.
RESOURCE_NAME = PLUGIN_NAME + '_Help.htm' RESOURCE_NAME = PLUGIN_NAME + '_Help.htm'

View File

@ -57,6 +57,7 @@ from __future__ import with_statement
# 8.0.2 - Add additional check on DER file sanity # 8.0.2 - Add additional check on DER file sanity
# 8.0.3 - Remove erroneous check on DER file sanity # 8.0.3 - Remove erroneous check on DER file sanity
# 8.0.4 - Completely remove erroneous check on DER file sanity # 8.0.4 - Completely remove erroneous check on DER file sanity
# 8.0.5 - Do not process DRM-free documents
""" """
@ -64,7 +65,7 @@ Decrypts Adobe ADEPT-encrypted PDF files.
""" """
__license__ = 'GPL v3' __license__ = 'GPL v3'
__version__ = "8.0.4" __version__ = "8.0.5"
import sys import sys
import os import os
@ -1468,6 +1469,7 @@ class PDFDocument(object):
if not self.encryption: if not self.encryption:
self.is_printable = self.is_modifiable = self.is_extractable = True self.is_printable = self.is_modifiable = self.is_extractable = True
self.ready = True self.ready = True
raise PDFEncryptionError('Document is not encrypted.')
return return
(docid, param) = self.encryption (docid, param) = self.encryption
type = literal_name(param['Filter']) type = literal_name(param['Filter'])
@ -2180,11 +2182,11 @@ def decryptBook(userkey, inpath, outpath):
if RSA is None: if RSA is None:
raise ADEPTError(u"PyCrypto or OpenSSL must be installed.") raise ADEPTError(u"PyCrypto or OpenSSL must be installed.")
with open(inpath, 'rb') as inf: with open(inpath, 'rb') as inf:
try: #try:
serializer = PDFSerializer(inf, userkey) serializer = PDFSerializer(inf, userkey)
except: #except:
print u"Error serializing pdf {0}. Probably wrong key.".format(os.path.basename(inpath)) # print u"Error serializing pdf {0}. Probably wrong key.".format(os.path.basename(inpath))
return 2 # return 2
# hope this will fix the 'bad file descriptor' problem # hope this will fix the 'bad file descriptor' problem
with open(outpath, 'wb') as outf: with open(outpath, 'wb') as outf:
# help construct to make sure the method runs to the end # help construct to make sure the method runs to the end

View File

@ -26,8 +26,9 @@
# 6.4.2 - Fix for new tags in Topaz ebooks, and very small Topaz ebooks # 6.4.2 - Fix for new tags in Topaz ebooks, and very small Topaz ebooks
# 6.4.3 - Version bump to match plugin & Mac app # 6.4.3 - Version bump to match plugin & Mac app
# 6.5.0 - Fix for some new tags in Topaz ebooks # 6.5.0 - Fix for some new tags in Topaz ebooks
# 6.5.1 - Version bump to match plugin & Mac app
__version__ = '6.5.0' __version__ = '6.5.1'
import sys import sys
import os, os.path import os, os.path

View File

@ -54,6 +54,7 @@ __docformat__ = 'restructuredtext en'
# 6.5.0 - Big update to Macintosh app # 6.5.0 - Big update to Macintosh app
# Fix for some more 'new' tags in Topaz ebooks. # Fix for some more 'new' tags in Topaz ebooks.
# Fix an error in wineutils.py # Fix an error in wineutils.py
# 6.5.1 - Updated version number, added PDF check for DRM-free documents
""" """
@ -61,7 +62,7 @@ Decrypt DRMed ebooks.
""" """
PLUGIN_NAME = u"DeDRM" PLUGIN_NAME = u"DeDRM"
PLUGIN_VERSION_TUPLE = (6, 5, 0) PLUGIN_VERSION_TUPLE = (6, 5, 1)
PLUGIN_VERSION = u".".join([unicode(str(x)) for x in PLUGIN_VERSION_TUPLE]) 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. # Include an html helpfile in the plugin's zipfile with the following name.
RESOURCE_NAME = PLUGIN_NAME + '_Help.htm' RESOURCE_NAME = PLUGIN_NAME + '_Help.htm'

View File

@ -57,6 +57,7 @@ from __future__ import with_statement
# 8.0.2 - Add additional check on DER file sanity # 8.0.2 - Add additional check on DER file sanity
# 8.0.3 - Remove erroneous check on DER file sanity # 8.0.3 - Remove erroneous check on DER file sanity
# 8.0.4 - Completely remove erroneous check on DER file sanity # 8.0.4 - Completely remove erroneous check on DER file sanity
# 8.0.5 - Do not process DRM-free documents
""" """
@ -64,7 +65,7 @@ Decrypts Adobe ADEPT-encrypted PDF files.
""" """
__license__ = 'GPL v3' __license__ = 'GPL v3'
__version__ = "8.0.4" __version__ = "8.0.5"
import sys import sys
import os import os
@ -1468,6 +1469,7 @@ class PDFDocument(object):
if not self.encryption: if not self.encryption:
self.is_printable = self.is_modifiable = self.is_extractable = True self.is_printable = self.is_modifiable = self.is_extractable = True
self.ready = True self.ready = True
raise PDFEncryptionError('Document is not encrypted.')
return return
(docid, param) = self.encryption (docid, param) = self.encryption
type = literal_name(param['Filter']) type = literal_name(param['Filter'])
@ -2180,11 +2182,11 @@ def decryptBook(userkey, inpath, outpath):
if RSA is None: if RSA is None:
raise ADEPTError(u"PyCrypto or OpenSSL must be installed.") raise ADEPTError(u"PyCrypto or OpenSSL must be installed.")
with open(inpath, 'rb') as inf: with open(inpath, 'rb') as inf:
try: #try:
serializer = PDFSerializer(inf, userkey) serializer = PDFSerializer(inf, userkey)
except: #except:
print u"Error serializing pdf {0}. Probably wrong key.".format(os.path.basename(inpath)) # print u"Error serializing pdf {0}. Probably wrong key.".format(os.path.basename(inpath))
return 2 # return 2
# hope this will fix the 'bad file descriptor' problem # hope this will fix the 'bad file descriptor' problem
with open(outpath, 'wb') as outf: with open(outpath, 'wb') as outf:
# help construct to make sure the method runs to the end # help construct to make sure the method runs to the end

View File

@ -54,6 +54,7 @@ __docformat__ = 'restructuredtext en'
# 6.5.0 - Big update to Macintosh app # 6.5.0 - Big update to Macintosh app
# Fix for some more 'new' tags in Topaz ebooks. # Fix for some more 'new' tags in Topaz ebooks.
# Fix an error in wineutils.py # Fix an error in wineutils.py
# 6.5.1 - Updated version number, added PDF check for DRM-free documents
""" """
@ -61,7 +62,7 @@ Decrypt DRMed ebooks.
""" """
PLUGIN_NAME = u"DeDRM" PLUGIN_NAME = u"DeDRM"
PLUGIN_VERSION_TUPLE = (6, 5, 0) PLUGIN_VERSION_TUPLE = (6, 5, 1)
PLUGIN_VERSION = u".".join([unicode(str(x)) for x in PLUGIN_VERSION_TUPLE]) 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. # Include an html helpfile in the plugin's zipfile with the following name.
RESOURCE_NAME = PLUGIN_NAME + '_Help.htm' RESOURCE_NAME = PLUGIN_NAME + '_Help.htm'

View File

@ -57,6 +57,7 @@ from __future__ import with_statement
# 8.0.2 - Add additional check on DER file sanity # 8.0.2 - Add additional check on DER file sanity
# 8.0.3 - Remove erroneous check on DER file sanity # 8.0.3 - Remove erroneous check on DER file sanity
# 8.0.4 - Completely remove erroneous check on DER file sanity # 8.0.4 - Completely remove erroneous check on DER file sanity
# 8.0.5 - Do not process DRM-free documents
""" """
@ -64,7 +65,7 @@ Decrypts Adobe ADEPT-encrypted PDF files.
""" """
__license__ = 'GPL v3' __license__ = 'GPL v3'
__version__ = "8.0.4" __version__ = "8.0.5"
import sys import sys
import os import os
@ -1468,6 +1469,7 @@ class PDFDocument(object):
if not self.encryption: if not self.encryption:
self.is_printable = self.is_modifiable = self.is_extractable = True self.is_printable = self.is_modifiable = self.is_extractable = True
self.ready = True self.ready = True
raise PDFEncryptionError('Document is not encrypted.')
return return
(docid, param) = self.encryption (docid, param) = self.encryption
type = literal_name(param['Filter']) type = literal_name(param['Filter'])
@ -2180,11 +2182,11 @@ def decryptBook(userkey, inpath, outpath):
if RSA is None: if RSA is None:
raise ADEPTError(u"PyCrypto or OpenSSL must be installed.") raise ADEPTError(u"PyCrypto or OpenSSL must be installed.")
with open(inpath, 'rb') as inf: with open(inpath, 'rb') as inf:
try: #try:
serializer = PDFSerializer(inf, userkey) serializer = PDFSerializer(inf, userkey)
except: #except:
print u"Error serializing pdf {0}. Probably wrong key.".format(os.path.basename(inpath)) # print u"Error serializing pdf {0}. Probably wrong key.".format(os.path.basename(inpath))
return 2 # return 2
# hope this will fix the 'bad file descriptor' problem # hope this will fix the 'bad file descriptor' problem
with open(outpath, 'wb') as outf: with open(outpath, 'wb') as outf:
# help construct to make sure the method runs to the end # help construct to make sure the method runs to the end

View File

@ -1,7 +1,7 @@
Welcome to the tools! 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.5.0 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.5.1 archive from Apprentice Alf's Blog: http://apprenticealf.wordpress.com/
The is archive includes tools to remove DRM from: The is archive includes tools to remove DRM from: