]> xmof Git - DeDRM.git/commitdiff
import ion correctly
authorxxyzz <gitpull@protonmail.com>
Sat, 28 Nov 2020 03:20:53 +0000 (11:20 +0800)
committerxxyzz <gitpull@protonmail.com>
Sat, 28 Nov 2020 03:20:53 +0000 (11:20 +0800)
DeDRM_plugin/kfxdedrm.py

index 8bacd87fdc1d62c57b240933672a6a8a1b64ff0d..4be73eaa1207651460b7f9f94f7ce5286b9c57d8 100644 (file)
@@ -11,6 +11,7 @@ import shutil
 import zipfile
 
 from io import BytesIO
+from calibre_plugins.dedrm.ion import DrmIon, DrmIonVoucher
 
 
 __license__ = 'GPL v3'
@@ -27,10 +28,6 @@ class KFXZipBook:
         return (None, None)
 
     def processBook(self, totalpids):
-        try:
-            import ion
-        except:
-            from calibre_plugins.dedrm import ion
         with zipfile.ZipFile(self.infile, 'r') as zf:
             for filename in zf.namelist():
                 with zf.open(filename) as fh:
@@ -42,7 +39,7 @@ class KFXZipBook:
                         self.decrypt_voucher(totalpids)
                     print("Decrypting KFX DRMION: {0}".format(filename))
                     outfile = BytesIO()
-                    ion.DrmIon(BytesIO(data[8:-8]), lambda name: self.voucher).parse(outfile)
+                    DrmIon(BytesIO(data[8:-8]), lambda name: self.voucher).parse(outfile)
                     self.decrypted[filename] = outfile.getvalue()
 
         if not self.decrypted:
@@ -72,7 +69,7 @@ class KFXZipBook:
                 continue
 
             try:
-                voucher = ion.DrmIonVoucher(BytesIO(data), pid[:dsn_len], pid[dsn_len:])
+                voucher = DrmIonVoucher(BytesIO(data), pid[:dsn_len], pid[dsn_len:])
                 voucher.parse()
                 voucher.decryptvoucher()
                 break