Leseratte10 / acsm-calibre-plugin

Calibre plugin for ACSM->EPUB and ACSM->PDF conversion.
https://www.mobileread.com/forums/showthread.php?t=341975
GNU General Public License v3.0
593 stars 23 forks source link

Error: Did not find ENC #44

Closed michal-devel closed 1 year ago

michal-devel commented 1 year ago

Bug description

Hi!

DeACSM fails with some (I have two files *.acsm files). I checked one of these.

Here's end of Calibre log:

</envelope>Traceback (most recent call last):
  File "calibre/customize/ui.py", line 432, in get_file_type_metadata
  File "calibre/customize/builtins.py", line 315, in get_metadata
  File "calibre/ebooks/metadata/pdf.py", line 124, in get_metadata
ValueError: Could not read info dict from PDF

Not notifying any server since that was disabled.
DeACSM v0.0.16: Downloading book ...
DeACSM v0.0.16: Loading book from <removed>
Download took 30188 ms (HTTP 200)
That's a PDF file
DeACSM v0.0.16: Downloaded PDF, adding encryption config ...
Searching for startxref ...
Got startxref: 21779570
Error: Did not find ENC - took 285 ms
Error, enc not found
DeACSM v0.0.16: There was an error patching the PDF file.
Syntax Error: Document stream is empty
pdfinfo errored out with return code: 1
Added 0 books in 35.4 seconds

I have the full log and *.acsm file. Unfortunately, I cannot download the book by ADE, because I have different credentials on my Windows installation with ADE and different on my Linux system.

I'm happy to help you investigate this issue.

Operating system

Linux

Which version of Calibre are you running?

5.37

Which version of the ACSM Input plugin are you running?

v0.0.16

Further information

No response

Leseratte10 commented 1 year ago

Thanks for the report. PDFs can sometimes be a bit weird. EPUBs are easy, they're ZIP files and the DRM is handled by adding / removing an XML file to that ZIP. PDFs on the other hand are a complex binary format that only Adobe software can really 100% understand. That PDF file is probably using something weird for its encryption that my plugin doesn't yet support.

Can you send me the ACSM file and the URL you've removed from that log ("Loading book from ...") to the address \<address removed> , then I'll take a look and see if I can find something.

michal-devel commented 1 year ago

I've just send you an e-mail.

Leseratte10 commented 1 year ago

Thanks for the full log. Can you test this version and see if that fixes the issue?

https://github.com/Leseratte10/acsm-calibre-plugin/suites/9848969646/artifacts/474757622 (c50828031973d9b5a5aa0e97213b0d4a2c0fcf22)

Please make a backup of your authorization before installing this (plugin settings -> Export account activation data) as this is a newer version that changes some more stuff and it's a bit experimental.

Then just install the version from that link (install the "calibre-plugin.zip", ignore the "calibre-migration-plugin.zip" file), restart Calibre, try to import the ACSM file again, and see if that works then. If that still doesn't work, please send me another mail with the new log, and with the PDF file as created by that version of the plugin.

michal-devel commented 1 year ago

Sure, please give a second.

michal-devel commented 1 year ago

Bum! It did the trick!

EDIT:

Please give a sec, I will test some other ACSM files that hadn't been successfully processed before.

EDIT2:

I checked another file. No luck this time. I'll send log and the ACSM file.

Leseratte10 commented 1 year ago

Quoting from the log file you've sent me:

DeDRM v10.0.3: Trying to decrypt ooqmsq26.pdf
DeDRM v10.0.3: ooqmsq26.pdf is a PDF ebook with encryption EBX_HANDLER
DeDRM v10.0.3: ooqmsq26.pdf is a PDF ebook (EBX) for UUID xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
DeDRM v10.0.3: Trying UUID-matched encryption key adobe_uuid_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
error writing pdf: Invalid object number: objid=3290
Traceback (most recent call last):
  File "/home/michal/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 1820, in getobj
    obj = objs[i]
IndexError: list index out of range

My plugin seems to have created a valid PDF file but the DeDRM plugin failed to remove the DRM from the file. While this could in theory be a bug with my plugin creating an invalid PDF, this is more likely to be a bug in the DeDRM plugin so you would need to open an issue in that repository as I have nothing to do with the DeDRM plugin.

Leseratte10 commented 1 year ago

Looks like this was indeed a bug with the DeDRM plugin which is now fixed, so I'm going to close this issue. If it comes up again just reopen this or make a new report.