]> xmof Git - DeDRM.git/commitdiff
Some untested Python2 Kindle bugfixes
authorNoDRM <no_drm123@protonmail.com>
Sat, 19 Mar 2022 14:23:07 +0000 (15:23 +0100)
committerNoDRM <no_drm123@protonmail.com>
Sat, 19 Mar 2022 14:23:07 +0000 (15:23 +0100)
DeDRM_plugin/k4mobidedrm.py

index ec108d4dccc99a19e5cb59d035a0851804e1cb4c..e048a036f1664eebc0d38dc64cac590993e0759d 100644 (file)
@@ -69,7 +69,11 @@ import getopt
 import re
 import traceback
 import time
-import html.entities
+try: 
+    import html.entities as htmlentitydefs
+except:
+    import htmlentitydefs
+
 import json
 
 #@@CALIBRE_COMPAT_CODE@@
@@ -188,7 +192,7 @@ def unescape(text):
         else:
             # named entity
             try:
-                text = chr(html.entities.name2codepoint[text[1:-1]])
+                text = chr(htmlentitydefs.name2codepoint[text[1:-1]])
             except KeyError:
                 pass
         return text # leave as is
@@ -215,8 +219,11 @@ def GetDecryptedBook(infile, kDatabases, androidFiles, serials, pids, starttime
     else:
         mb = topazextract.TopazBook(infile)
 
-    bookname = unescape(mb.getBookTitle())
-    print("Decrypting {1} ebook: {0}".format(bookname, mb.getBookType()))
+    try: 
+        bookname = unescape(mb.getBookTitle())
+        print("Decrypting {1} ebook: {0}".format(bookname, mb.getBookType()))
+    except: 
+        print("Decrypting {0} ebook.".format(mb.getBookType()))
 
     # copy list of pids
     totalpids = list(pids)