noDRM / DeDRM_tools

DeDRM tools for ebooks
7.04k stars 314 forks source link

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa7 in position 5: invalid start byte #549

Open nozonyan opened 4 months ago

nozonyan commented 4 months ago

Question / bug report

Some PDFs (always and only PDFs) fail to dedrm. This happens since calibre 5, both with the original alf dedrm and the new nodrm. This does not happen on calibre 4.X with the older 6.6.3 dedrm plugin. I used to use a calibre portable installation on a windows machine just to deal with these files but now I do not have that win anymore, and running multiple native calibre installations on linux can lead to bigger issues (calibre does not offert a portable version for linux). I did manage to somehow workaround it by using calibre portable on wine but this can lead to metadata&library mismatches if I ever forget to sync the 2 dbs. Happens on average in 1 on 100 PDFs. I have tried every suggested answer to no avail.

Which version of Calibre are you running?

7.10

Which version of the DeDRM plugin are you running?

10.0.9

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

No response

Log output

DeDRM v10.0.9: AN 635025.pdf - Unknown.pdf is a PDF ebook with encryption EBX_HANDLER
DeDRM v10.0.9: AN 635025.pdf - Unknown.pdf is a PDF ebook (EBX) for UUID 7d03cba3-REDACTED
DeDRM v10.0.9: Trying UUID-matched encryption key adobe_uuid_7d03cba3-REDACTED
error writing pdf: 'utf-8' codec can't decode byte 0xb7 in position 7: invalid start byte
Traceback (most recent call last):
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 2328, in decryptBook
    serializer.dump(outf)
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 2142, in dump
    obj = doc.getobj(objid)
          ^^^^^^^^^^^^^^^^^
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 1869, in getobj
    (_,obj) = self.parser.nextobject()
              ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 691, in nextobject
    (pos, token) = self.nexttoken()
                   ^^^^^^^^^^^^^^^^
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 565, in nexttoken
    (self.parse1, self.charpos) = self.parse1(self.buf, self.charpos)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 404, in parse_literal
    self.add_token(LIT(self.token))
                   ^^^^^^^^^^^^^^^
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 225, in intern
    lit = self.classe(name)
          ^^^^^^^^^^^^^^^^^
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 184, in __init__
    self.name = name.decode('utf-8')
                ^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb7 in position 7: invalid start byte
DeDRM v10.0.9: Trying encryption key adobe_uuid_6144f589-REDACTED
ebx_V is 4  and ebx_type is 6
length is 16 and len(bookkey) is 0
DeDRM v10.0.9: Exception when decrypting after 0.6 seconds
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 698, in PDFIneptDecrypt
    result = ineptpdf.decryptBook(userkey, path_to_ebook, of.name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 2324, in decryptBook
    serializer = PDFSerializer(inf, userkey, inept)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 2118, in __init__
    doc.initialize(userkey, inept)
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 1245, in initialize
    return self.initialize_ebx_inept(password, docid, param)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 1715, in initialize_ebx_inept
    raise ADEPTError('error decrypting book session key - mismatched length')
ineptpdf.ADEPTError: error decrypting book session key - mismatched length
DeDRM v10.0.9: Failed to decrypt with key adobe_uuid_6144f589-REDACTED after 0.6 seconds
DeDRM v10.0.9: Trying encryption key adobe_uuid_7d03cba3-REDACTED
error writing pdf: 'utf-8' codec can't decode byte 0xb7 in position 7: invalid start byte
Traceback (most recent call last):
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 2328, in decryptBook
    serializer.dump(outf)
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 2142, in dump
    obj = doc.getobj(objid)
          ^^^^^^^^^^^^^^^^^
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 1869, in getobj
    (_,obj) = self.parser.nextobject()
              ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 691, in nextobject
    (pos, token) = self.nexttoken()
                   ^^^^^^^^^^^^^^^^
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 565, in nexttoken
    (self.parse1, self.charpos) = self.parse1(self.buf, self.charpos)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 404, in parse_literal
    self.add_token(LIT(self.token))
                   ^^^^^^^^^^^^^^^
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 225, in intern
    lit = self.classe(name)
          ^^^^^^^^^^^^^^^^^
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 184, in __init__
    self.name = name.decode('utf-8')
                ^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb7 in position 7: invalid start byte
DeDRM v10.0.9: Failed to decrypt with key adobe_uuid_7d03cba3-REDACTED after 0.8 seconds
DeDRM v10.0.9: Trying encryption key adobe_uuid_8ae57039-REDACTED
ebx_V is 4  and ebx_type is 6
length is 16 and len(bookkey) is 0
DeDRM v10.0.9: Exception when decrypting after 0.8 seconds
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 698, in PDFIneptDecrypt
    result = ineptpdf.decryptBook(userkey, path_to_ebook, of.name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 2324, in decryptBook
    serializer = PDFSerializer(inf, userkey, inept)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 2118, in __init__
    doc.initialize(userkey, inept)
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 1245, in initialize
    return self.initialize_ebx_inept(password, docid, param)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nozomi/.config/calibre/plugins/DeDRM.zip/ineptpdf.py", line 1715, in initialize_ebx_inept
    raise ADEPTError('error decrypting book session key - mismatched length')
ineptpdf.ADEPTError: error decrypting book session key - mismatched length
DeDRM v10.0.9: Failed to decrypt with key adobe_uuid_8ae57039-REDACTED after 0.8 seconds
DeDRM v10.0.9: Looking for new default Adobe Digital Editions Keys after 0.8 seconds
Application could not be started, or no application associated with the specified file.
ShellExecuteEx failed: File not found.

DeDRM v10.0.9: wine py.exe -3 is not python3
Application could not be started, or no application associated with the specified file.
ShellExecuteEx failed: File not found.

DeDRM v10.0.9: wine python3.exe is not python3
Application could not be started, or no application associated with the specified file.
ShellExecuteEx failed: File not found.

DeDRM v10.0.9: wine python.exe is not python3
wine: failed to open "C:\\Python27\\python.exe": c0000135
DeDRM v10.0.9: wine C:\Python27\python.exe does not exist
DeDRM v10.0.9: Unable to find python3 executable in WINEPREFIX=""
DeDRM v10.0.9: Finished after 2.2 seconds
Added AN 635025.pdf - Unknown to db in: 0.3
Added 1 books in 3.3 seconds