noDRM / DeDRM_tools

DeDRM tools for ebooks
7.17k stars 321 forks source link

Debugging not working #175

Open theachard opened 2 years ago

theachard commented 2 years ago

Question / bug report

Hi there! I use Calibre on a Macbook Pro and downloaded DeDRM because I wanted to debug an ebook that I created (converting from Adobe InDesign and cleaning up in Calibre). It's flagging the following error when I load it up to my distribution channel:

"You have submitted an encrypted ePub. Encryption is not fully supported across the publishing industry and may delay or prevent publication at certain digital stores."

I've never had this issue before and I always use the same machine and process for my ebook creation, so I'm thinking one of the programs updated and now something is getting encrypted somewhere along the line. Please help—thanks!

Which version of Calibre are you running?

6.61

Which version of the DeDRM plugin are you running?

v10.0.3

If applicable, which version of the Kindle software are you running?

No response

Log output

Using calibre Qt style: True calibre Debug log calibre 6.6.1 embedded-python: True macOS-12.6-x86_64-i386-64bit Darwin ('64bit', '') ('Darwin', '21.6.0', 'Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64') Python 3.10.1 OSX: ('12.6', ('', '', ''), 'x86_64') Interface language: None Successfully initialized third party plugins: DeDRM (10, 0, 3) calibre 6.6.1 embedded-python: True macOS-12.6-x86_64-i386-64bit Darwin ('64bit', '') ('Darwin', '21.6.0', 'Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64') Python 3.10.1 OSX: ('12.6', ('', '', ''), 'x8664') Interface language: None Successfully initialized third party plugins: DeDRM (10, 0, 3) QPA platform: cocoa devicePixelRatio: 2.0 logicalDpi: 72.0 x 72.0 physicalDpi: 129.00000193738563 x 129.00000193738563 [0.00] Starting up... [0.04] Showing splash screen... [0.26] splash screen shown [0.26] Initializing db... [0.27] db initialized [0.27] Constructing main UI... [1.06] main UI initialized... [1.06] Hiding splash screen Starting QuickView DeDRM v10.0.3: Trying to decrypt The Cloak An inspirational account of per - Virgnia Routh Lynch.epub DeDRM v10.0.3: Verifying zip archive integrity FontDecrypt: Checking OEBPS/content.opf for IETF font obfuscation keys ... not found FontDecrypt: Checking OEBPS/content.opf for Adobe font obfuscation keys ... found 'BB52360EE5104DF5BCB51517F642CD46' FontDecrypt: There's remaining entries in encryption.xml, adding file ... DeDRM v10.0.3: Post-processing took 0.2 seconds DeDRM v10.0.3: Finished after 0.4 seconds [16.13] splash screen hidden [16.13] Started up in 16.13 seconds with 19 books Added The Cloak: An inspirational account of personal transformation to db in: 0.3

ElleKayEm commented 2 years ago

Looks like it's a font. Take a look at that encryption.xml file and see what remaining entries there are.

theachard commented 2 years ago

This is the encryption.xml file. I have to admit, this is a bit beyond my understanding, as I've never come across this issue before. What can I do to fix it at this point? Thanks!

`<?xml version="1.0" encoding="UTF-8"?>

`

ElleKayEm commented 2 years ago

My best guess is the use of embedded fonts is causing the issue.

DB99 commented 2 years ago

Looking through this I wonder if this is actually a plugin problem. The Adobe font obfuscation key(s) are found and the book is added successfully. Presumably the imported e-book can be read in the Calibre viewer? With correctly rendered fonts? Is the only issue the warning when you send the file for publication?

The Calibre log did show an info or warning message that there were other entries in encryption.xml. But the message is from "Font_decrypt", not DeDrm. I understand that Calibre itself decrypts Adobe fonts, so I'm unlclear on whether the font decryption is handled by the plugin or by Calibre itself. And what are the implications of the remaining entries in encryption.xml? Are these superfluous? Or is the font decryption code, whether in Calibre or the plugin, not decrypting all entries?

Just some quick observations. Someone with more knowledge who knows the code will probably be able to resolve this fairly easily. If the font decryption code is in Calibre and not the plugin it may be worth asking Kovid, Calibre's creator, who usually responds very quickly to posts on Mobileread. However, if you do post on Mobileread please bear in mind the rules there about posting for assistance to remove DRM. I personally would not regard a Calibre related post about font decryption as infringing such rules, but other opinions may differ.

theachard commented 2 years ago

Thanks @DB99 ,

Yes, I can read it in Calibre viewer with the correctly rendered fonts. As I said, this is an ebook that I've converted myself using using the Adobe InDesign file (from my print edition), and then I import it into Calibre and clean up the code/TOC. I've never had a problem with the fonts causing an encryption error, and it's only giving me this message when I try to upload it to some of my distribution channels. It went through just fine on several sights, but it's flagging on others that have more intense encryption filters, I guess.

So far all the fonts seem to be appearing correctly, but I honestly don't know much about the Font_decrypt plugin—I honestly don't remember installing it (if it is in fact a plugin), though it sounds like you're saying it could be Calibre's own decryption process. Whatever it is, I haven't come across any font decryption errors at all. I did search through my plugins, and couldn't find anything with the word "decrypt" in it, so I think putting this to Kovid might be a good idea—I'll give it a try.

Thank you!

DB99 commented 2 years ago

I'm also no expert. So far as I know there isn't a font decryption plugin as such but I did see a post on Mobileread where Kovid said:

calibre decrypts encrypted fonts in epub.

See this link:

https://www.mobileread.com/forums/showpost.php?p=908106&postcount=2

I assume this is inbuilt in Calibre rather than a plugin. The entry in the log about other entries in encryption.xml is from "FontDecryptor". DeDRM plugin entries normally show as being from the plugin.

However, the DeDRM plugin apparently does have the ability to Deobfuscate epub fonts. If you go to Calibre Preferences you can sustomize the DeDRM plugin to enable this by ticking the box in the customize dialog. It may be worth you checking that this box is ticked.

If you have not tried this already it is probably worthwhile to run the quality check plugin which does check the embedded fonts.

Best of luck.

DB99 commented 2 years ago

Kovid replied on Mobileread at this link:

https://www.mobileread.com/forums/showpost.php?p=4264629&postcount=2

He suggests turning off font obfuscation in InDesign or editing the book to remove and re-add the fonts which Calibre can do with the edit book tool. May be worth checking the DeDrm plugin is set to Deobfuscate fonts first. I'm still not sure where the message about encryption.xml is coming from.

I also wonder If there is no drm and the obfuscated fonts have been unobfuscated is the encryption.xml file necessary? Could it be removed or empty. Finally a Google search shows that someone has posted a Youtube video showing how to remove unused fonts from InDesign files. I didn't look at the video and have myself never used InDesign. My hypothesis is that there may be obfuscated fonts in your document which are not used but are also not being unobfuscated.

theachard commented 2 years ago

Thanks so much! I'm trying not to go back to the InDesign conversion point of the process because I've already spent so much time cleaning up the code in Calibre, and I'd hate to start all over again there... But when I tried to remove the fonts and re-add them in Calibre, it messed up all the font styling from the original design.

I'm going to follow-up on that YouTube video and see if I can find some assistance that way. This has been such a pain... I may have to go back to InDesign and start over, but I'm very much hoping not. Thanks so much for all of your help!

DB99 commented 2 years ago

You're welcome. Let us know how you go.

noDRM commented 2 years ago

Sorry for the confusion. The "FontDecrypt" logs are from my DeDRM plugin, see the code in epubfontdecrypt.py. All the "font obfuscation" logs come from my plugin trying to de-obfuscate fonts.

Is that encryption.xml from the EPUB before you added it to Calibre, or from the one after it's been added to Calibre? The one in the EPUB that has been added to Calibre is supposed to be empty / nonexistant, but considering that it logged FontDecrypt: There's remaining entries in encryption.xml, adding file ... that seems to not be the case, so I'd be interested in seeing the encryption.xml from the file after it's been added to Calibre.

What Kovid meant when he said Calibre decrypts fonts in EPUB is probably at runtime (to read in the Viewer) or upon conversion. Calibre doesn't, to my knowledge, auto-decrypt fonts in imported eBooks.

DB99 commented 2 years ago

Thanks for clearing this up and for all of your hard work.