Begin work on standalone version

Now the plugin ZIP file (DeDRM_plugin.zip) can be run with a normal
Python interpreter as if it were a Python file (try
`python3 DeDRM_plugin.zip --help`). This way I can begin building a
standalone version (that can run without Calibre) without having to
duplicate a ton of code.
This commit is contained in:
NoDRM
2021-12-29 09:26:29 +01:00
parent 9c40b3ce5a
commit dbf4b54026
13 changed files with 379 additions and 149 deletions

View File

@@ -72,26 +72,18 @@ import time
import html.entities
import json
# Calibre stuff - so we can import from our ZIP without absolute module name
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
class DrmException(Exception):
pass
if 'calibre' in sys.modules:
inCalibre = True
else:
inCalibre = False
if inCalibre:
from calibre_plugins.dedrm import mobidedrm
from calibre_plugins.dedrm import topazextract
from calibre_plugins.dedrm import kgenpids
from calibre_plugins.dedrm import androidkindlekey
from calibre_plugins.dedrm import kfxdedrm
else:
import mobidedrm
import topazextract
import kgenpids
import androidkindlekey
import kfxdedrm
import mobidedrm
import topazextract
import kgenpids
import androidkindlekey
import kfxdedrm
# Wrap a stream so that output gets flushed immediately
# and also make sure that any unicode strings get
@@ -243,7 +235,7 @@ def GetDecryptedBook(infile, kDatabases, androidFiles, serials, pids, starttime
try:
mb.processBook(totalpids)
except:
mb.cleanup
mb.cleanup()
raise
print("Decryption succeeded after {0:.1f} seconds".format(time.time()-starttime))