Skip to content

Commit a44b50d

Browse files
committed
LCP support
1 parent 05e0d0b commit a44b50d

16 files changed

+218
-55
lines changed

.github/ISSUE_TEMPLATE/QUESTION.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ body:
1010
id: calibre-version
1111
attributes:
1212
label: Which version of Calibre are you running?
13-
description: "Example: 5.30"
14-
placeholder: "5.30"
13+
description: "Example: 5.32"
14+
placeholder: "5.32"
1515
validations:
1616
required: true
1717
- type: input
1818
id: plugin-version
1919
attributes:
2020
label: Which version of the DeDRM plugin are you running?
21-
description: "Example: v7.2.1"
22-
placeholder: "v7.2.1"
21+
description: "Example: v10.0.0"
22+
placeholder: "v10.0.0"
2323
validations:
2424
required: true
2525
- type: input

CHANGELOG.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Changelog
2+
3+
List of changes since the fork of Apprentice Harper's repository:
4+
5+
- CI testing / linting removed as that always failed anyways. The CI now "just" packages the plugin.
6+
- Support for the Readium LCP DRM (also known as "CARE DRM" or "TEA DRM"). This supports EPUB and PDF files. It does not yet support Readium LCPDF/LPF/LCPA/LCPAU/LCPDI files, as I don't have access to any of these. If you have an LCP-protected file in one of these formats that this plugin does not work with, please open [an issue](https://github.com/noDRM/DeDRM_tools/issues) and attach the file to the report.
7+
- Add new Github issue report form which forces the user to include stuff like their Calibre version to hopefully increase the quality of bug reports.
8+
- Issues with PDF files in Calibre 5 should be fixed (merged [apprenticeharper/DeDRM_tools#1689](https://github.com/apprenticeharper/DeDRM_tools/pull/1689) ).
9+
- Fixed tons of issues with the B&N PDF DRM removal script ignoblepdf.py. It looks like that has never been tested since the move to Python3. I have integrated the B&N-specific code into ineptpdf.py, the original ignoblepdf.py is now unused. Fairly untested as I don't have any PDFs with B&N DRM.
10+
- Issues with Obok key retrieval fixed (merged [apprenticeharper/DeDRM_tools#1691](https://github.com/apprenticeharper/DeDRM_tools/pull/1691) ).
11+
- Issues with obfuscated Adobe fonts fixed (fixes [apprenticeharper/DeDRM_tools#1828](https://github.com/apprenticeharper/DeDRM_tools/issues/1828) ).
12+
- Deobfuscate font files in EPUBs by default (can be disabled in the plugin settings).
13+
- The standalone adobekey.py script now includes the account UUID in the key file name.
14+
- When extracting the default key from an ADE install, include the account UUID in the key name.
15+
- Adobe key management window size increased to account for longer key names due to the UUID.
16+
- Verify that the decrypted book key has the correct format. This makes it way less likely for issue [apprenticeharper/DeDRM_tools#1862](https://github.com/apprenticeharper/DeDRM_tools/issues/1862) to cause trouble.
17+
- If the Adobe owner UUID of a book being imported happens to be included in a particular key's name, try this key first before trying all the others. This completely fixes [apprenticeharper/DeDRM_tools#1862](https://github.com/apprenticeharper/DeDRM_tools/issues/1862), but only if the key name contains the correct UUID (not always the case, especially for keys imported with older versions of the plugin). It also makes DRM removal faster as the plugin no longer has to attempt all possible keys.
18+
- Remove some additional DRM remnants in Amazon MOBI files (merged [apprenticeharper/DeDRM_tools#23](https://github.com/apprenticeharper/DeDRM_tools/pull/23) ).
19+
- Just in case it's necessary, added a setting to the B&N key generation script to optionally allow the user to select the old key generation algorithm. Who knows, they might want to remove DRM from old books with the old key scheme.
20+
- Add a more verbose error message when trying to remove DRM from a book with the new, not-yet-cracked version of the Adobe ADEPT DRM.
21+
- Added back support for Python2 (Calibre 2.0+). Only tested with ADEPT (PDF & EPUB) and Readium LCP so far, please open an issue if there's errors with other book types.
22+
- Begin work on removing some kinds of watermarks from files after DRM removal. This isn't tested a lot, and is disabled by default. You can enable it in the plugin settings.
23+
- If you're using the [ACSM Input Plugin / DeACSM](https://www.mobileread.com/forums/showthread.php?t=341975), the encryption key will automatically be extracted from that plugin if necessary.

DeDRM_plugin/DeDRM_Help.htm

+10-4
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,19 @@
1717

1818
<body>
1919

20-
<h1>DeDRM Plugin <span class="version">(v6.7.0)</span></h1>
20+
<h1>DeDRM Plugin <span class="version">(v10.0.0)</span></h1>
2121

2222
<p>This plugin removes DRM from ebooks when they are imported into calibre. If you already have DRMed ebooks in your calibre library, you will need to remove them and import them again.</p>
2323

24+
<p>It is a forked version created by NoDRM, based on the original plugin by Apprentice Alf and Apprentice Harper.</p>
25+
2426
<h3>Installation</h3>
2527
<p>You have obviously managed to install the plugin, as otherwise you wouldn’t be reading this help file. However, you should also delete any older DRM removal plugins, as this DeDRM plugin replaces the five older plugins: Kindle and Mobipocket DeDRM (K4MobiDeDRM), Ignoble Epub DeDRM (ignobleepub), Inept Epub DeDRM (ineptepub), Inept PDF DeDRM (ineptepub) and eReader PDB 2 PML (eReaderPDB2PML).</p>
2628

2729
<h3>Configuration</h3>
28-
<p>On Windows and Mac, the keys for ebooks downloaded for Kindle for Mac/PC and Adobe Digital Editions are automatically generated. If all your DRMed ebooks can be opened and read in Kindle for Mac/PC and/or Adobe Digital Editions on the same computer on which you are running calibre, you do not need to do any configuration of this plugin. On Linux, keys for Kindle for PC and Adobe Digital Editions need to be generated separately (see the Linux section below)</p>
30+
<p>On Windows and Mac, the keys for ebooks downloaded for Kindle for Mac/PC and Adobe Digital Editions are automatically generated. If all your DRMed ebooks can be opened and read in Kindle for Mac/PC and/or Adobe Digital Editions on the same computer on which you are running calibre, you do not need to do any configuration of this plugin. On Linux, keys for Kindle for PC and Adobe Digital Editions need to be generated separately (see the Linux section below).</p>
31+
32+
<p>If you are using the <a href="https://www.mobileread.com/forums/showthread.php?t=341975">DeACSM / ACSM Input Plugin</a> for Calibre, the keys will also automatically be dumped for you.</p>
2933

3034
<p>If you have other DRMed ebooks, you will need to enter extra configuration information. The buttons in this dialog will open individual configuration dialogs that will allow you to enter the needed information, depending on the type and source of your DRMed eBooks. Additional help on the information required is available in each of the the dialogs.</p>
3135

@@ -42,11 +46,12 @@ <h3>Troubleshooting:</h3>
4246

4347
<h3>Credits:</h3>
4448
<ul>
49+
<li>NoDRM for a bunch of updates and the Readium LCP support</li>
4550
<li>The Dark Reverser for the Mobipocket and eReader scripts</li>
4651
<li>i♥cabbages for the Adobe Digital Editions scripts</li>
4752
<li>Skindle aka Bart Simpson for the Amazon Kindle for PC script</li>
4853
<li>CMBDTC for Amazon Topaz DRM removal script</li>
49-
<li>some_updates, clarknova and Bart Simpson for Amazon Topaz conversion scripts</li>
54+
<li>some_updates, clarknova and Bart Simpson for Amazon Topaz conversion scripts</li>
5055
<li>DiapDealer for the first calibre plugin versions of the tools</li>
5156
<li>some_updates, DiapDealer, Apprentice Alf and mdlnx for Amazon Kindle/Mobipocket tools</li>
5257
<li>some_updates for the DeDRM all-in-one Python tool</li>
@@ -55,7 +60,8 @@ <h3>Credits:</h3>
5560
<li>And probably many more.</li>
5661
</ul>
5762

58-
<h3> For additional help read the <a href="https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md">FAQs</a> at <a href="https://github.com/apprenticeharper/DeDRM_tools/">Apprentice Harpers’s GitHub repository</a>. You can ask questions in the comments section of the <a href="http://apprenticealf.wordpress.com/2012/09/10/drm-removal-tools-for-ebooks/">first post</a> at <a href="http://wordpress.com/apprenticealf/">Apprentice Alf's blog</a> or <a href="https://github.com/apprenticeharper/DeDRM_tools/issues">raise an issue</a>. </h3>
63+
<h3>For additional help read the <a href="https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md">FAQs</a> at <a href="https://github.com/noDRM/DeDRM_tools">NoDRM's GitHub repository</a> (or the corresponding <a href="https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md">FAQs</a> at <a href="https://github.com/apprenticeharper/DeDRM_tools/">Apprentice Harpers’s GitHub repository</a>). You can <a href="https://github.com/noDRM/DeDRM_tools/issues">open issue reports</a>related to this fork at NoDRM's GitHub repository.</h3>
64+
5965

6066
<h2>Linux Systems Only</h2>
6167
<h3>Generating decryption keys for Adobe Digital Editions and Kindle for PC</h3>

DeDRM_plugin/DeDRM_Mobipocket PID_Help.htm

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ <h3>Deleting Mobipocket PIDs:</h3>
3535

3636
<p>On the right-hand side of the plugin’s customization dialog, you will see a button with an icon that looks like a red "X". Clicking this button will delete the highlighted Mobipocket PID from the list. You will be prompted once to be sure that’s what you truly mean to do. Once gone, it’s permanently gone.</p>
3737

38-
<p>Once done creating/deleting PIDs, click Close to exit the customization dialogue. Your changes wil only be saved permanently when you click OK in the main configuration dialog.</p>
38+
<p>Once done creating/deleting PIDs, click Close to exit the customization dialogue. Your changes will only be saved permanently when you click OK in the main configuration dialog.</p>
3939

4040
</body>
4141

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2+
"http://www.w3.org/TR/html4/strict.dtd">
3+
4+
<html>
5+
6+
<head>
7+
<meta http-equiv="content-type" content="text/html; charset=utf-8">
8+
<title>Managing Readium LCP passphrases</title>
9+
<style type="text/css">
10+
span.version {font-size: 50%}
11+
span.bold {font-weight: bold}
12+
h3 {margin-bottom: 0}
13+
p {margin-top: 0}
14+
li {margin-top: 0.5em}
15+
</style>
16+
</head>
17+
18+
<body>
19+
20+
<h1>Managing Readium LCP passphrases</h1>
21+
22+
<p>Readium LCP is a relatively new eBook DRM. It's also known under the names "CARE DRM" or "TEA DRM". It does not rely on any accounts or key data that's difficult to acquire. All you need to open (or decrypt) LCP eBooks is the account passphrase given to you by the eBook provider - the very same passphrase you'd have to enter into your eBook reader device (once) to read LCP-encrypted books.</p>
23+
24+
25+
<h3>Entering an LCP passphrase:</h3>
26+
27+
<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 for entering a new passphrase.</p>
28+
29+
<p>Just enter your passphrase as provided with the book, then click the OK button to save the passphrase. </p>
30+
31+
<p>Usually, passphrases are identical for all books bought with the same account. So if you buy multiple LCP-protected eBooks, they'll usually all have the same passphrase if they've all been bought at the same store with the same account. </p>
32+
33+
<h3>Deleting an LCP passphrase:</h3>
34+
35+
<p>On the right-hand side of the plugin’s customization dialog, you will see a button with an icon that looks like a red "X". Clicking this button will delete the highlighted passphrase from the list. You will be prompted once to be sure that’s what you truly mean to do. Once gone, it’s permanently gone.</p>
36+
37+
<p>Once done entering/deleting passphrases, click Close to exit the customization dialogue. Your changes will only be saved permanently when you click OK in the main configuration dialog.</p>
38+
39+
</body>
40+
41+
</html>

DeDRM_plugin/__init__.py

+44-14
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Copyright © 2021 NoDRM
77

88
__license__ = 'GPL v3'
9-
__version__ = '7.2.1'
9+
__version__ = '10.0.0'
1010
__docformat__ = 'restructuredtext en'
1111

1212

@@ -78,6 +78,7 @@
7878
# 7.1.0 - Full release for calibre 5.x
7979
# 7.2.0 - Update for latest KFX changes, and Python 3 Obok fixes.
8080
# 7.2.1 - Whitespace!
81+
# 10.0.0 - First forked version by NoDRM. See CHANGELOG.md for details.
8182

8283
"""
8384
Decrypt DRMed ebooks.
@@ -130,7 +131,7 @@ def __getattr__(self, attr):
130131

131132
class DeDRM(FileTypePlugin):
132133
name = PLUGIN_NAME
133-
description = "Removes DRM from Amazon Kindle, Adobe Adept (including Kobo), Barnes & Noble, Mobipocket and eReader ebooks. Credit given to i♥cabbages and The Dark Reverser for the original stand-alone scripts."
134+
description = "Removes DRM from Amazon Kindle, Adobe Adept (including Kobo), Readium LCP, Barnes & Noble, Mobipocket and eReader ebooks. Credit given to i♥cabbages and The Dark Reverser for the original stand-alone scripts."
134135
supported_platforms = ['linux', 'osx', 'windows']
135136
author = "Apprentice Alf, Apprentice Harper, NoDRM, The Dark Reverser and i♥cabbages"
136137
version = PLUGIN_VERSION_TUPLE
@@ -225,10 +226,10 @@ def postProcessEPUB(self, path_to_ebook):
225226

226227
# Remove watermarks (currently just Amazon) from the OPF file
227228
path_to_ebook = watermark.removeOPFwatermarks(self, path_to_ebook) or path_to_ebook
228-
229+
229230
# Remove watermarks (currently just Adobe's resource ID) from all HTML and XHTML files
230231
path_to_ebook = watermark.removeHTMLwatermarks(self, path_to_ebook) or path_to_ebook
231-
232+
232233
return path_to_ebook
233234

234235
except:
@@ -240,18 +241,18 @@ def checkFonts(self, path_to_ebook):
240241
# It checks if there's fonts that need to be deobfuscated
241242

242243
try:
243-
import calibre_plugins.dedrm.epubfontdecrypt as epubfontdecrypt
244+
import calibre_plugins.dedrm.epubfontdecrypt as epubfontdecrypt
244245

245-
output = self.temporary_file(".epub").name
246-
ret = epubfontdecrypt.decryptFontsBook(path_to_ebook, output)
246+
output = self.temporary_file(".epub").name
247+
ret = epubfontdecrypt.decryptFontsBook(path_to_ebook, output)
247248

248-
if (ret == 0):
249-
return output
250-
elif (ret == 1):
251-
return path_to_ebook
252-
else:
253-
print("{0} v{1}: Error during font deobfuscation".format(PLUGIN_NAME, PLUGIN_VERSION))
254-
raise DeDRMError("Font deobfuscation failed")
249+
if (ret == 0):
250+
return output
251+
elif (ret == 1):
252+
return path_to_ebook
253+
else:
254+
print("{0} v{1}: Error during font deobfuscation".format(PLUGIN_NAME, PLUGIN_VERSION))
255+
raise DeDRMError("Font deobfuscation failed")
255256

256257
except:
257258
print("{0} v{1}: Error during font deobfuscation".format(PLUGIN_NAME, PLUGIN_VERSION))
@@ -276,6 +277,22 @@ def ePubDecrypt(self,path_to_ebook):
276277
import calibre_plugins.dedrm.prefs as prefs
277278
dedrmprefs = prefs.DeDRM_Prefs()
278279

280+
281+
# import the LCP handler
282+
import calibre_plugins.dedrm.lcpdedrm as lcpdedrm
283+
284+
if (lcpdedrm.isLCPbook(path_to_ebook)):
285+
try:
286+
retval = lcpdedrm.decryptLCPbook(path_to_ebook, dedrmprefs['lcp_passphrases'], self)
287+
except:
288+
print("Looks like that didn't work:")
289+
raise
290+
291+
return self.postProcessEPUB(retval)
292+
293+
294+
# Not an LCP book, do the normal EPUB (Adobe) handling.
295+
279296
# import the Barnes & Noble ePub handler
280297
import calibre_plugins.dedrm.ignobleepub as ignobleepub
281298

@@ -545,8 +562,21 @@ def ePubDecrypt(self,path_to_ebook):
545562
def PDFDecrypt(self,path_to_ebook):
546563
import calibre_plugins.dedrm.prefs as prefs
547564
import calibre_plugins.dedrm.ineptpdf as ineptpdf
565+
import calibre_plugins.dedrm.lcpdedrm as lcpdedrm
548566
dedrmprefs = prefs.DeDRM_Prefs()
549567

568+
if (lcpdedrm.isLCPbook(path_to_ebook)):
569+
try:
570+
retval = lcpdedrm.decryptLCPbook(path_to_ebook, dedrmprefs['lcp_passphrases'], self)
571+
except:
572+
print("Looks like that didn't work:")
573+
raise
574+
575+
return retval
576+
577+
578+
# Not an LCP book, do the normal Adobe handling.
579+
550580
book_uuid = None
551581
try:
552582
# Try to figure out which Adobe account this book is licensed for.

0 commit comments

Comments
 (0)