mirror of
https://github.com/noDRM/DeDRM_tools.git
synced 2026-03-20 04:58:56 +00:00
Compare commits
9 Commits
d2808d83d9
...
bc20870c1c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc20870c1c | ||
|
|
7379b45319 | ||
|
|
bde82fd7ab | ||
|
|
de3d91f5e5 | ||
|
|
c5ee327a60 | ||
|
|
501a1e6d31 | ||
|
|
815d86efe0 | ||
|
|
65646f4493 | ||
|
|
ad33aea18d |
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
|||||||
run: python3 make_release.py
|
run: python3 make_release.py
|
||||||
|
|
||||||
- name: Upload
|
- name: Upload
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: plugin
|
name: plugin
|
||||||
path: |
|
path: |
|
||||||
|
|||||||
@@ -105,4 +105,9 @@ This is v10.0.9, a release candidate for v10.1.0. I don't expect there to be maj
|
|||||||
- Fix some bugs (Python 2 and Python 3) in erdr2pml.py (untested).
|
- Fix some bugs (Python 2 and Python 3) in erdr2pml.py (untested).
|
||||||
- Fix file lock bug in androidkindlekey.py on Windows with Calibre >= 7 (untested).
|
- Fix file lock bug in androidkindlekey.py on Windows with Calibre >= 7 (untested).
|
||||||
- A bunch of updates to the external FileOpen ineptpdf script, might fix #442 (untested).
|
- A bunch of updates to the external FileOpen ineptpdf script, might fix #442 (untested).
|
||||||
|
- Fix exception handling on decrypt in ion.py (#662, thanks @C0rn3j).
|
||||||
|
- 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).
|
||||||
|
- 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).
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ li {margin-top: 0.5em}
|
|||||||
|
|
||||||
<p>If you have upgraded from an earlier version of the plugin, any existing Kindle for Mac/PC keys will have been automatically imported, so you might not need to do any more configuration. In addition, on Windows and Mac, the default Kindle for Mac/PC key is added the first time the plugin is run. Continue reading for key generation and management instructions.</p>
|
<p>If you have upgraded from an earlier version of the plugin, any existing Kindle for Mac/PC keys will have been automatically imported, so you might not need to do any more configuration. In addition, on Windows and Mac, the default Kindle for Mac/PC key is added the first time the plugin is run. Continue reading for key generation and management instructions.</p>
|
||||||
|
|
||||||
|
<p>Note that for best results, you should run Calibre / this plugin on the same machine where Kindle 4 PC / Kindle 4 Mac is running. It is possible to export/import the keys to another machine, but this may not always work, particularly with the newer DRM versions.</p>
|
||||||
|
|
||||||
<h3>Creating New Keys:</h3>
|
<h3>Creating New Keys:</h3>
|
||||||
|
|
||||||
<p>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 prompting you to enter a key name for the default Kindle for Mac/PC key. </p>
|
<p>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 prompting you to enter a key name for the default Kindle for Mac/PC key. </p>
|
||||||
|
|||||||
@@ -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):
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
"""ion.py: Decrypt Kindle KFX files.
|
"""ion.py: Decrypt Kindle KFX files.
|
||||||
|
|
||||||
Revision history:
|
Revision history:
|
||||||
@@ -13,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
|
||||||
@@ -1346,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])
|
||||||
|
|||||||
@@ -327,36 +327,50 @@ class KoboLibrary(object):
|
|||||||
elif sys.platform.startswith('darwin'):
|
elif sys.platform.startswith('darwin'):
|
||||||
self.kobodir = os.path.join(os.environ['HOME'], "Library", "Application Support", "Kobo", "Kobo Desktop Edition")
|
self.kobodir = os.path.join(os.environ['HOME'], "Library", "Application Support", "Kobo", "Kobo Desktop Edition")
|
||||||
elif sys.platform.startswith('linux'):
|
elif sys.platform.startswith('linux'):
|
||||||
|
# Since on Linux, you have to run Kobo Desktop within Wine,
|
||||||
|
# there is no guarantee where Kobo.sqlite (and the rest of
|
||||||
|
# the kobo directory) might be.
|
||||||
|
#
|
||||||
|
# It should also be noted that Kobo Desktop will store all
|
||||||
|
# of it files in the current directory where you run it,
|
||||||
|
# meaning that a user might accidentally create several
|
||||||
|
# Kobo.sqlite files which are all separate and then be
|
||||||
|
# confused why Obok can't find any of the new books. Sadly
|
||||||
|
# there isn't a trivial way to deal with this.
|
||||||
|
|
||||||
#sets ~/.config/calibre as the location to store the kobodir location info file and creates this directory if necessary
|
# We cache the kobodir we find in ~/.config/calibre.
|
||||||
kobodir_cache_dir = os.path.join(os.environ['HOME'], ".config", "calibre")
|
kobodir_cache_dir = os.path.join(os.environ['HOME'], ".config", "calibre", "plugins", "obok")
|
||||||
if not os.path.isdir(kobodir_cache_dir):
|
if not os.path.isdir(kobodir_cache_dir):
|
||||||
os.mkdir(kobodir_cache_dir)
|
os.mkdir(kobodir_cache_dir)
|
||||||
|
kobodir_cache_file = os.path.join(kobodir_cache_dir, "kobo-location")
|
||||||
|
|
||||||
#appends the name of the file we're storing the kobodir location info to the above path
|
try:
|
||||||
kobodir_cache_file = str(kobodir_cache_dir) + "/" + "kobo location"
|
# If the cached version exists and the path does really
|
||||||
|
# contain Kobo.sqlite, use that.
|
||||||
|
with open(kobodir_cache_file, "r") as f:
|
||||||
|
cached_kobodir = f.read().strip()
|
||||||
|
assert os.path.isfile(os.path.join(cached_kobodir, "Kobo.sqlite"))
|
||||||
|
self.kobodir = cached_kobodir
|
||||||
|
except (AssertionError, FileNotFoundError):
|
||||||
|
# If there was no cached version, search the entire
|
||||||
|
# filesystem tree for a directory containing
|
||||||
|
# "Kobo.sqlite".
|
||||||
|
#
|
||||||
|
# We first search $HOME to avoid picking another user's
|
||||||
|
# Kobo.sqlite file, but then fallback to / if there was
|
||||||
|
# nothing in $HOME.
|
||||||
|
for candidate_root in (os.environ["HOME"], "/"):
|
||||||
|
for root, _, files in os.walk(candidate_root):
|
||||||
|
if "Kobo.sqlite" in files:
|
||||||
|
with open(kobodir_cache_file, "w") as f:
|
||||||
|
f.write("%s/\n" % (root,))
|
||||||
|
self.kobodir = root
|
||||||
|
break
|
||||||
|
|
||||||
"""if the above file does not exist, recursively searches from the root
|
# Desktop versions use Kobo.sqlite.
|
||||||
of the filesystem until kobodir is found and stores the location of kobodir
|
|
||||||
in that file so this loop can be skipped in the future"""
|
|
||||||
original_stdout = sys.stdout
|
|
||||||
if not os.path.isfile(kobodir_cache_file):
|
|
||||||
for root, dirs, files in os.walk('/'):
|
|
||||||
for file in files:
|
|
||||||
if file == 'Kobo.sqlite':
|
|
||||||
kobo_linux_path = str(root)
|
|
||||||
with open(kobodir_cache_file, 'w') as f:
|
|
||||||
sys.stdout = f
|
|
||||||
print(kobo_linux_path, end='')
|
|
||||||
sys.stdout = original_stdout
|
|
||||||
|
|
||||||
f = open(kobodir_cache_file, 'r' )
|
|
||||||
self.kobodir = f.read()
|
|
||||||
|
|
||||||
# desktop versions use Kobo.sqlite
|
|
||||||
kobodb = os.path.join(self.kobodir, "Kobo.sqlite")
|
kobodb = os.path.join(self.kobodir, "Kobo.sqlite")
|
||||||
# check for existence of file
|
# check for existence of file
|
||||||
if (not(os.path.isfile(kobodb))):
|
if not os.path.isfile(kobodb):
|
||||||
# give up here, we haven't found anything useful
|
# give up here, we haven't found anything useful
|
||||||
self.kobodir = u""
|
self.kobodir = u""
|
||||||
kobodb = u""
|
kobodb = u""
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ Installation
|
|||||||
------------
|
------------
|
||||||
Open calibre's Preferences dialog. Click on the "Plugins" button. Next, click on the button, "Load plugin from file". Navigate to the unzipped DeDRM_tools folder, find the file "obok_plugin.zip". Click to select the file and select "Open". Click "Yes" in the "Are you sure?" dialog box. Click the "OK" button in the "Success" dialog box.
|
Open calibre's Preferences dialog. Click on the "Plugins" button. Next, click on the button, "Load plugin from file". Navigate to the unzipped DeDRM_tools folder, find the file "obok_plugin.zip". Click to select the file and select "Open". Click "Yes" in the "Are you sure?" dialog box. Click the "OK" button in the "Success" dialog box.
|
||||||
|
|
||||||
|
Note: This plugin requires the "wmic" component on Windows. On Windows 10 and below this will be available by default, on Windows 11 it needs to be explicitly enabled. Make sure that on your Windows 11 machine, under Settings -> System -> Optional features -> Add an optional feature -> View features, "WMIC" is enabled / activated, otherwise this plugin may not work correctly.
|
||||||
|
|
||||||
|
|
||||||
Customization
|
Customization
|
||||||
-------------
|
-------------
|
||||||
@@ -16,7 +18,6 @@ No customization is required, except choosing which menus will show the plugin.
|
|||||||
|
|
||||||
Using the plugin
|
Using the plugin
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
Select the plugin's menu or icon from whichever part of the calibre interface you have chosen to have it. Follow the instructions in the dialog that appears.
|
Select the plugin's menu or icon from whichever part of the calibre interface you have chosen to have it. Follow the instructions in the dialog that appears.
|
||||||
|
|
||||||
|
|
||||||
@@ -29,5 +30,5 @@ If you find that the DeDRM plugin is not working for you (imported ebooks still
|
|||||||
- Once calibre has re-started, import the problem ebook.
|
- Once calibre has re-started, import the problem ebook.
|
||||||
- Now close calibre.
|
- Now close calibre.
|
||||||
|
|
||||||
A log will appear that you can copy and paste into a comment at Apprentice Alf's blog, http://apprenticealf.wordpress.com/ or an issue at Apprentice Harper's repository, https://github.com/apprenticeharper/DeDRM_tools/issues . You should also give details of your computer, and how you obtained the ebook file.
|
A log will appear that you can copy and paste into a GitHub issue at noDRM's repository, https://github.com/noDRM/DeDRM_tools/issues . You should also give details of your computer, and how you obtained the ebook file.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user