mirror of
https://github.com/6dylan6/jdpro.git
synced 2026-04-15 03:18:36 +08:00
Compare commits
2 Commits
ce1af47cda
...
8e5bfb1a6d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e5bfb1a6d | ||
|
|
987eeab917 |
29
jd_taskop.py
29
jd_taskop.py
@@ -7,7 +7,7 @@ new Env('重复任务优化');
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys,re
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
@@ -157,20 +157,29 @@ def disable_duplicate_tasks(ids: list) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def get_token() -> str or None:
|
def get_token() -> str or None:
|
||||||
path = '/ql/config/auth.json' # 设置青龙 auth文件地址
|
if os.path.exists("/ql/data/db/keyv.sqlite"):
|
||||||
global flag1
|
path="/ql/data/db/keyv.sqlite"
|
||||||
flag1 = True
|
elif os.path.exists("/ql/config/auth.json"):
|
||||||
if not os.path.isfile(path):
|
path="/ql/config/auth.json"
|
||||||
path = '/ql/data/config/auth.json' # 尝试设置青龙 auth 新版文件地址
|
elif os.path.exists("/ql/data/config/auth.json"):
|
||||||
flag1 = False
|
path="/ql/data/config/auth.json"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(path, "r", encoding="utf-8") as f:
|
if 'keyv' in path:
|
||||||
data = json.load(f)
|
with open(path, "r", encoding="latin1") as file:
|
||||||
|
auth = file.read()
|
||||||
|
matches = re.search(r'token":"([^"]+)"', auth)
|
||||||
|
token = matches.group(1)
|
||||||
|
else:
|
||||||
|
with open(path, "r") as file:
|
||||||
|
auth = file.read()
|
||||||
|
auth = json.loads(auth)
|
||||||
|
token = auth["token"]
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.info(f"❌无法获取 token!!!\n{traceback.format_exc()}")
|
logger.info(f"❌无法获取 token!!!\n{traceback.format_exc()}")
|
||||||
send("禁用重复任务失败", "无法获取 token!!!")
|
send("禁用重复任务失败", "无法获取 token!!!")
|
||||||
exit(1)
|
exit(1)
|
||||||
return data.get("token")
|
return token
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
26
jd_wsck.py
26
jd_wsck.py
@@ -441,7 +441,9 @@ def main():
|
|||||||
if os.path.exists("/ql/config/auth.json"):
|
if os.path.exists("/ql/config/auth.json"):
|
||||||
config="/ql/config/auth.json"
|
config="/ql/config/auth.json"
|
||||||
envtype="ql"
|
envtype="ql"
|
||||||
|
if os.path.exists("/ql/data/db/keyv.sqlite"):
|
||||||
|
config="/ql/data/db/keyv.sqlite"
|
||||||
|
envtype="ql_latest"
|
||||||
if os.path.exists("/ql/data/config/auth.json"):
|
if os.path.exists("/ql/data/config/auth.json"):
|
||||||
config="/ql/data/config/auth.json"
|
config="/ql/data/config/auth.json"
|
||||||
envtype="ql"
|
envtype="ql"
|
||||||
@@ -499,9 +501,21 @@ def main():
|
|||||||
url = 'http://127.0.0.1:5678/openApi/count'
|
url = 'http://127.0.0.1:5678/openApi/count'
|
||||||
headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer ', 'api-token': f'{token}'}
|
headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer ', 'api-token': f'{token}'}
|
||||||
datas = get(url, headers=headers).json()["data"]["accountCount"]
|
datas = get(url, headers=headers).json()["data"]["accountCount"]
|
||||||
|
elif envtype == "ql_latest":
|
||||||
# printf(f"token:{token}")
|
with open(config, "r", encoding="latin1") as f1:
|
||||||
# printf(f"datas:{datas}")
|
content = f1.read()
|
||||||
|
matches = re.search(r'token":"([^"]+)"', content)
|
||||||
|
try:
|
||||||
|
token = matches.group(1)
|
||||||
|
except Exception as e:
|
||||||
|
sys.exit(0)
|
||||||
|
url = 'http://127.0.0.1:5600/api/envs'
|
||||||
|
headers = {'Authorization': f'Bearer {token}'}
|
||||||
|
body = {
|
||||||
|
'searchValue': 'JD_WSCK',
|
||||||
|
'Authorization': f'Bearer {token}'
|
||||||
|
}
|
||||||
|
datas = get(url, params=body, headers=headers).json()['data']
|
||||||
|
|
||||||
|
|
||||||
if datas > 0 if isinstance(datas, int) else len(datas) > 0:
|
if datas > 0 if isinstance(datas, int) else len(datas) > 0:
|
||||||
@@ -510,7 +524,7 @@ def main():
|
|||||||
printf("\n错误:没有需要转换的JD_WSCK,退出脚本!")
|
printf("\n错误:没有需要转换的JD_WSCK,退出脚本!")
|
||||||
return
|
return
|
||||||
|
|
||||||
if envtype == "ql":
|
if envtype in ('ql','ql_latest'):
|
||||||
for data in datas:
|
for data in datas:
|
||||||
randomuserAgent()
|
randomuserAgent()
|
||||||
if data['status']!=0:
|
if data['status']!=0:
|
||||||
@@ -527,7 +541,7 @@ def main():
|
|||||||
else:
|
else:
|
||||||
newpin=getRemark(pin,token)
|
newpin=getRemark(pin,token)
|
||||||
if "fake_" in cookie:
|
if "fake_" in cookie:
|
||||||
message = f"pin为{newpin}的wskey过期了!"
|
message = f"{newpin}的wskey过期了!"
|
||||||
printf(message)
|
printf(message)
|
||||||
url = 'http://127.0.0.1:5600/api/envs/disable'
|
url = 'http://127.0.0.1:5600/api/envs/disable'
|
||||||
try:
|
try:
|
||||||
|
|||||||
26
jd_wskey.py
26
jd_wskey.py
@@ -236,14 +236,24 @@ def ql_login() -> str: # 方法 青龙登录(获取Token 功能同上)
|
|||||||
path = '/ql/config/auth.json' # 设置青龙 auth文件地址
|
path = '/ql/config/auth.json' # 设置青龙 auth文件地址
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
path = '/ql/data/config/auth.json' # 尝试设置青龙 auth 新版文件地址
|
path = '/ql/data/config/auth.json' # 尝试设置青龙 auth 新版文件地址
|
||||||
if os.path.isfile(path): # 进行文件真值判断
|
if not os.path.isfile(path):
|
||||||
with open(path, "r") as file: # 上下文管理
|
path_latest = '/ql/data/db/keyv.sqlite' # 尝试设置青龙 auth 新版文件地址
|
||||||
auth = file.read() # 读取文件
|
if os.path.isfile(path) or os.path.isfile(path_latest): # 进行文件真值判断
|
||||||
file.close() # 关闭文件
|
|
||||||
auth = json.loads(auth) # 使用 json模块读取
|
if os.path.isfile(path):
|
||||||
username = auth["username"] # 提取 username
|
with open(path, "r") as file: # 上下文管理
|
||||||
password = auth["password"] # 提取 password
|
auth = file.read() # 读取文件
|
||||||
token = auth["token"] # 提取 authkey
|
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:
|
try:
|
||||||
twoFactorSecret = auth["twoFactorSecret"]
|
twoFactorSecret = auth["twoFactorSecret"]
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user