mirror of
https://github.com/noDRM/DeDRM_tools.git
synced 2026-03-20 04:58:56 +00:00
Compare commits
3 Commits
c5ee327a60
...
7379b45319
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7379b45319 | ||
|
|
bde82fd7ab | ||
|
|
de3d91f5e5 |
@@ -109,4 +109,5 @@ This is v10.0.9, a release candidate for v10.1.0. I don't expect there to be maj
|
|||||||
- Fix SHA1 hash function for erdr2pml.py script (#608, thanks @unwiredben).
|
- Fix SHA1 hash function for erdr2pml.py script (#608, thanks @unwiredben).
|
||||||
- Make Kobo DRM removal not fail when there are undownloaded ebooks (#384, thanks @precondition).
|
- Make Kobo DRM removal not fail when there are undownloaded ebooks (#384, thanks @precondition).
|
||||||
- Fix Obok import failing in Calibre flatpak due to missing ip command (#586 and #585, thanks @jcotton42).
|
- Fix Obok import failing in Calibre flatpak due to missing ip command (#586 and #585, thanks @jcotton42).
|
||||||
|
- Don't re-pack EPUB if there's no DRM to remove and no postprocessing done (fixes #555).
|
||||||
|
|
||||||
|
|||||||
@@ -216,12 +216,16 @@ class DeDRM(FileTypePlugin):
|
|||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def postProcessEPUB(self, path_to_ebook):
|
def postProcessEPUB(self, path_to_ebook, path_to_original_ebook = None):
|
||||||
# This is called after the DRM is removed (or if no DRM was present)
|
# This is called after the DRM is removed (or if no DRM was present)
|
||||||
# It does stuff like de-obfuscating fonts (by calling checkFonts)
|
# It does stuff like de-obfuscating fonts (by calling checkFonts)
|
||||||
# or removing watermarks.
|
# or removing watermarks.
|
||||||
|
|
||||||
postProcessStart = time.time()
|
postProcessStart = time.time()
|
||||||
|
postProcessingNeeded = False
|
||||||
|
|
||||||
|
# Save a backup of the EPUB path after DRM removal but before any postprocessing is done.
|
||||||
|
pre_postprocessing_EPUB_path = path_to_ebook
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import prefs
|
import prefs
|
||||||
@@ -248,6 +252,15 @@ class DeDRM(FileTypePlugin):
|
|||||||
postProcessEnd = time.time()
|
postProcessEnd = time.time()
|
||||||
print("{0} v{1}: Post-processing took {2:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION, postProcessEnd-postProcessStart))
|
print("{0} v{1}: Post-processing took {2:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION, postProcessEnd-postProcessStart))
|
||||||
|
|
||||||
|
|
||||||
|
# If the EPUB is DRM-free (path_to_original_ebook will only be set in this case),
|
||||||
|
# and the post-processing hasn't changed anything in the EPUB,
|
||||||
|
# return the raw original file from path_to_original_ebook from before the
|
||||||
|
# zipfix code was executed.
|
||||||
|
if ((path_to_ebook == pre_postprocessing_EPUB_path) and path_to_original_ebook is not None):
|
||||||
|
print("{0} v{1}: Post-processing didn't do anything on DRM-free EPUB, returning original file".format(PLUGIN_NAME, PLUGIN_VERSION))
|
||||||
|
return path_to_original_ebook
|
||||||
|
|
||||||
return path_to_ebook
|
return path_to_ebook
|
||||||
|
|
||||||
except:
|
except:
|
||||||
@@ -299,9 +312,9 @@ class DeDRM(FileTypePlugin):
|
|||||||
# import the LCP handler
|
# import the LCP handler
|
||||||
import lcpdedrm
|
import lcpdedrm
|
||||||
|
|
||||||
if (lcpdedrm.isLCPbook(path_to_ebook)):
|
if (lcpdedrm.isLCPbook(inf.name)):
|
||||||
try:
|
try:
|
||||||
retval = lcpdedrm.decryptLCPbook(path_to_ebook, dedrmprefs['lcp_passphrases'], self)
|
retval = lcpdedrm.decryptLCPbook(inf.name, dedrmprefs['lcp_passphrases'], self)
|
||||||
except:
|
except:
|
||||||
print("Looks like that didn't work:")
|
print("Looks like that didn't work:")
|
||||||
raise
|
raise
|
||||||
@@ -628,7 +641,7 @@ class DeDRM(FileTypePlugin):
|
|||||||
|
|
||||||
# Not a Barnes & Noble nor an Adobe Adept
|
# Not a Barnes & Noble nor an Adobe Adept
|
||||||
# Probably a DRM-free EPUB, but we should still check for fonts.
|
# Probably a DRM-free EPUB, but we should still check for fonts.
|
||||||
return self.postProcessEPUB(inf.name)
|
return self.postProcessEPUB(inf.name, path_to_ebook)
|
||||||
|
|
||||||
|
|
||||||
def PDFIneptDecrypt(self, path_to_ebook):
|
def PDFIneptDecrypt(self, path_to_ebook):
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ Revision history:
|
|||||||
|
|
||||||
Copyright © 2013-2020 Apprentice Harper et al.
|
Copyright © 2013-2020 Apprentice Harper et al.
|
||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import hashlib
|
import hashlib
|
||||||
@@ -1348,7 +1347,7 @@ class DrmIonVoucher(object):
|
|||||||
process_V4648(shared), process_V5683(shared)]
|
process_V4648(shared), process_V5683(shared)]
|
||||||
|
|
||||||
decrypted=False
|
decrypted=False
|
||||||
lastexception: Exception | None = None
|
lastexception = None # type: Exception | None
|
||||||
for sharedsecret in sharedsecrets:
|
for sharedsecret in sharedsecrets:
|
||||||
key = hmac.new(sharedsecret, b"PIDv3", digestmod=hashlib.sha256).digest()
|
key = hmac.new(sharedsecret, b"PIDv3", digestmod=hashlib.sha256).digest()
|
||||||
aes = AES.new(key[:32], AES.MODE_CBC, self.cipheriv[:16])
|
aes = AES.new(key[:32], AES.MODE_CBC, self.cipheriv[:16])
|
||||||
|
|||||||
Reference in New Issue
Block a user