This commit is contained in:
2024
2025-01-25 18:50:03 +08:00
parent ce1af47cda
commit 987eeab917
3 changed files with 38 additions and 22 deletions

View File

@@ -236,14 +236,24 @@ def ql_login() -> str: # 方法 青龙登录(获取Token 功能同上)
path = '/ql/config/auth.json' # 设置青龙 auth文件地址
if not os.path.isfile(path):
path = '/ql/data/config/auth.json' # 尝试设置青龙 auth 新版文件地址
if os.path.isfile(path): # 进行文件真值判断
with open(path, "r") as file: # 上下文管理
auth = file.read() # 读取文件
file.close() # 关闭文件
auth = json.loads(auth) # 使用 json模块读取
username = auth["username"] # 提取 username
password = auth["password"] # 提取 password
token = auth["token"] # 提取 authkey
if not os.path.isfile(path):
path_latest = '/ql/data/db/keyv.sqlite' # 尝试设置青龙 auth 新版文件地址
if os.path.isfile(path) or os.path.isfile(path_latest): # 进行文件真值判断
if os.path.isfile(path):
with open(path, "r") as file: # 上下文管理
auth = file.read() # 读取文件
file.close() # 关闭文件
auth = json.loads(auth) # 使用 json模块读取
username = auth["username"] # 提取 username
password = auth["password"] # 提取 password
token = auth["token"] # 提取 authkey
else:
with open(path_latest, "r", encoding="latin1") as file:
auth = file.read() # 读取文件
matches = re.search(r'token":"([^"]+)"', auth)
token = matches.group(1)
try:
twoFactorSecret = auth["twoFactorSecret"]
except Exception as err: