mirror of
https://github.com/Leseratte10/acsm-calibre-plugin.git
synced 2024-12-22 09:19:55 +06:00
Bunch of cleanup
This commit is contained in:
parent
7a31e54024
commit
f641a1e72d
@ -61,7 +61,7 @@ __version__ = PLUGIN_VERSION = ".".join([str(x)for x in PLUGIN_VERSION_TUPLE])
|
|||||||
|
|
||||||
|
|
||||||
from calibre.utils.config import config_dir # type: ignore
|
from calibre.utils.config import config_dir # type: ignore
|
||||||
from calibre.constants import isosx, iswindows, islinux # type: ignore
|
from calibre.constants import islinux # type: ignore
|
||||||
|
|
||||||
import os, shutil, traceback, sys, time, io, random
|
import os, shutil, traceback, sys, time, io, random
|
||||||
import zipfile
|
import zipfile
|
||||||
@ -71,7 +71,7 @@ from lxml import etree
|
|||||||
|
|
||||||
class ACSMInput(FileTypePlugin):
|
class ACSMInput(FileTypePlugin):
|
||||||
name = PLUGIN_NAME
|
name = PLUGIN_NAME
|
||||||
description = "ACSM Input Plugin - Takes an Adobe ACSM file and converts that into a useable EPUB or PDF file. Python reimplementation of libgourou by Grégory Soutadé"
|
description = "Takes an Adobe ACSM file and converts that into a useable EPUB or PDF file. Formerly known as DeACSM. Based on the libgourou library by Grégory Soutadé"
|
||||||
supported_platforms = ['linux', 'osx', 'windows']
|
supported_platforms = ['linux', 'osx', 'windows']
|
||||||
author = "Leseratte10"
|
author = "Leseratte10"
|
||||||
version = PLUGIN_VERSION_TUPLE
|
version = PLUGIN_VERSION_TUPLE
|
||||||
@ -229,32 +229,8 @@ class ACSMInput(FileTypePlugin):
|
|||||||
print("{0} v{1}: Exception when copying needed library files".format(PLUGIN_NAME, PLUGIN_VERSION))
|
print("{0} v{1}: Exception when copying needed library files".format(PLUGIN_NAME, PLUGIN_VERSION))
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
if islinux:
|
|
||||||
# Also extract EXE files needed for WINE ADE key extraction
|
|
||||||
# EXE files are obfuscated with base64 so that stupid AV programs
|
|
||||||
# don't flag this whole plugin as malicious.
|
|
||||||
# See keyextractDecryptor.py and the folder "keyextract" for more information.
|
|
||||||
|
|
||||||
try:
|
|
||||||
print("{0} v{1}: Extracting WINE key tools ...".format(PLUGIN_NAME, PLUGIN_VERSION))
|
|
||||||
from keyextractDecryptor import get_win32_data, get_win64_data
|
|
||||||
|
|
||||||
file32 = os.path.join(rand_path, "decrypt_win32.exe")
|
|
||||||
f = open(file32, "wb")
|
|
||||||
f.write(get_win32_data())
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
file64 = os.path.join(rand_path, "decrypt_win64.exe")
|
|
||||||
f = open(file64, "wb")
|
|
||||||
f.write(get_win64_data())
|
|
||||||
f.close()
|
|
||||||
except:
|
|
||||||
print("{0} v{1}: Error while extracting packed WINE ADE key extraction EXE files ".format(PLUGIN_NAME, PLUGIN_VERSION))
|
|
||||||
traceback.print_exc()
|
|
||||||
|
|
||||||
|
|
||||||
# Write module ID
|
# Write module ID
|
||||||
if id_plugin is not None:
|
if id_plugin is not None:
|
||||||
mod_file = os.path.join(rand_path, "module_id.txt")
|
mod_file = os.path.join(rand_path, "module_id.txt")
|
||||||
@ -296,9 +272,6 @@ class ACSMInput(FileTypePlugin):
|
|||||||
config_widget.save_settings()
|
config_widget.save_settings()
|
||||||
|
|
||||||
def ADE_sanity_check(self):
|
def ADE_sanity_check(self):
|
||||||
import calibre_plugins.deacsm.prefs as prefs # type: ignore
|
|
||||||
deacsmprefs = prefs.ACSMInput_Prefs()
|
|
||||||
|
|
||||||
from libadobe import get_activation_xml_path
|
from libadobe import get_activation_xml_path
|
||||||
|
|
||||||
container = None
|
container = None
|
||||||
@ -343,7 +316,6 @@ class ACSMInput(FileTypePlugin):
|
|||||||
|
|
||||||
|
|
||||||
adobe_fulfill_response = etree.fromstring(replyData)
|
adobe_fulfill_response = etree.fromstring(replyData)
|
||||||
NSMAP = { "adept" : "http://ns.adobe.com/adept" }
|
|
||||||
adNS = lambda tag: '{%s}%s' % ('http://ns.adobe.com/adept', tag)
|
adNS = lambda tag: '{%s}%s' % ('http://ns.adobe.com/adept', tag)
|
||||||
|
|
||||||
|
|
||||||
@ -409,7 +381,6 @@ class ACSMInput(FileTypePlugin):
|
|||||||
elif filetype == ".pdf":
|
elif filetype == ".pdf":
|
||||||
adobe_fulfill_response = etree.fromstring(rights_xml_str)
|
adobe_fulfill_response = etree.fromstring(rights_xml_str)
|
||||||
|
|
||||||
NSMAP = { "adept" : "http://ns.adobe.com/adept" }
|
|
||||||
adNS = lambda tag: '{%s}%s' % ('http://ns.adobe.com/adept', tag)
|
adNS = lambda tag: '{%s}%s' % ('http://ns.adobe.com/adept', tag)
|
||||||
resource = adobe_fulfill_response.find("./%s/%s" % (adNS("licenseToken"), adNS("resource"))).text
|
resource = adobe_fulfill_response.find("./%s/%s" % (adNS("licenseToken"), adNS("resource"))).text
|
||||||
|
|
||||||
@ -457,10 +428,6 @@ class ACSMInput(FileTypePlugin):
|
|||||||
|
|
||||||
print("{0} v{1}: Try to fulfill ...".format(PLUGIN_NAME, PLUGIN_VERSION))
|
print("{0} v{1}: Try to fulfill ...".format(PLUGIN_NAME, PLUGIN_VERSION))
|
||||||
|
|
||||||
import calibre_plugins.deacsm.prefs as prefs # type: ignore
|
|
||||||
deacsmprefs = prefs.ACSMInput_Prefs()
|
|
||||||
|
|
||||||
|
|
||||||
success, replyData = fulfill(path_to_ebook, deacsmprefs["notify_fulfillment"])
|
success, replyData = fulfill(path_to_ebook, deacsmprefs["notify_fulfillment"])
|
||||||
|
|
||||||
if (success is False):
|
if (success is False):
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#@@CALIBRE_COMPAT_CODE@@
|
#@@CALIBRE_COMPAT_CODE@@
|
||||||
|
|
||||||
import sys, binascii
|
import sys, binascii, traceback
|
||||||
|
|
||||||
def GetMasterKey(wineprefix):
|
def GetMasterKey(wineprefix):
|
||||||
import subprocess, os, re
|
import subprocess, os, re
|
||||||
@ -64,6 +64,35 @@ def GetMasterKey(wineprefix):
|
|||||||
import os
|
import os
|
||||||
moddir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "keyextract")
|
moddir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "keyextract")
|
||||||
|
|
||||||
|
|
||||||
|
# extract the EXE file from Python code:
|
||||||
|
# EXE files are obfuscated with base64 so that stupid AV programs
|
||||||
|
# don't flag this whole plugin as malicious.
|
||||||
|
# See keyextractDecryptor.py and the folder "keyextract" for more information.
|
||||||
|
|
||||||
|
try:
|
||||||
|
print("Extracting WINE key tools ...")
|
||||||
|
from keyextractDecryptor import get_win32_data, get_win64_data
|
||||||
|
|
||||||
|
if winearch == "win32":
|
||||||
|
file32 = os.path.join(moddir, "decrypt_win32.exe")
|
||||||
|
f = open(file32, "wb")
|
||||||
|
f.write(get_win32_data())
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
elif winearch == "win64":
|
||||||
|
file64 = os.path.join(moddir, "decrypt_win64.exe")
|
||||||
|
f = open(file64, "wb")
|
||||||
|
f.write(get_win64_data())
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
else:
|
||||||
|
print("Invalid winearch: " + str(winearch))
|
||||||
|
|
||||||
|
except:
|
||||||
|
print("Error while extracting packed WINE ADE key extraction EXE files ")
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
# calls decrypt_win32.exe or decrypt_win64.exe
|
# calls decrypt_win32.exe or decrypt_win64.exe
|
||||||
proc = subprocess.Popen(["wine", "decrypt_" + winearch + ".exe"], shell=False, cwd=moddir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
proc = subprocess.Popen(["wine", "decrypt_" + winearch + ".exe"], shell=False, cwd=moddir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
prog_stdout, prog_stderr = proc.communicate()
|
prog_stdout, prog_stderr = proc.communicate()
|
||||||
|
@ -574,6 +574,7 @@ def addLoanRecordToConfigFile(new_loan_record):
|
|||||||
|
|
||||||
error_counter = 0
|
error_counter = 0
|
||||||
last_token = None
|
last_token = None
|
||||||
|
random_identifier = None
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user