mirror of https://github.com/KingRan/KR.git
parent
c4e0a0fa1d
commit
aae0e32d1b
35
jd_wskey.py
35
jd_wskey.py
|
@ -32,7 +32,7 @@ except Exception as err:
|
|||
logger.debug(str(err))
|
||||
logger.info("无推送文件")
|
||||
|
||||
ver = 20203
|
||||
ver = 20218
|
||||
|
||||
|
||||
# 登录青龙 返回值 token
|
||||
|
@ -124,7 +124,7 @@ def get_ck():
|
|||
|
||||
# 返回值 bool
|
||||
def check_ck(ck):
|
||||
searchObj = re.search(r'pt_pin=([^;\s]+)', ck, re.M|re.I)
|
||||
searchObj = re.search(r'pt_pin=([^;\s]+)', ck, re.M | re.I)
|
||||
if searchObj:
|
||||
pin = searchObj.group(1)
|
||||
else:
|
||||
|
@ -135,7 +135,7 @@ def check_ck(ck):
|
|||
updateHour = int(os.environ["WSKEY_UPDATE_HOUR"])
|
||||
nowTime = time.time()
|
||||
updatedAt = 0.0
|
||||
searchObj = re.search(r'__time=([^;\s]+)', ck, re.M|re.I)
|
||||
searchObj = re.search(r'__time=([^;\s]+)', ck, re.M | re.I)
|
||||
if searchObj:
|
||||
updatedAt = float(searchObj.group(1))
|
||||
if nowTime - updatedAt >= (updateHour * 60 * 60) - (10 * 60):
|
||||
|
@ -147,7 +147,7 @@ def check_ck(ck):
|
|||
minute = int((remainingTime % 3600) / 60)
|
||||
logger.info(str(pin) + ";未到期,{0}时{1}分后更新\n".format(hour, minute))
|
||||
return True
|
||||
elif "QL_WSCK" in os.environ:
|
||||
elif "WSKEY_DISCHECK" in os.environ:
|
||||
logger.info("不检查账号有效性\n--------------------\n")
|
||||
return False
|
||||
else:
|
||||
|
@ -212,7 +212,7 @@ def getToken(wskey):
|
|||
def appjmp(wskey, tokenKey):
|
||||
wskey = "pt_" + str(wskey.split(";")[0])
|
||||
if tokenKey == 'xxx':
|
||||
logger.info(str(wskey) + ";WsKey状态失效\n--------------------\n")
|
||||
logger.info(str(wskey) + ";疑似IP风控等问题 默认为失效\n--------------------\n")
|
||||
return False, wskey
|
||||
headers = {
|
||||
'User-Agent': ua,
|
||||
|
@ -235,7 +235,10 @@ def appjmp(wskey, tokenKey):
|
|||
res_set = res.cookies.get_dict()
|
||||
pt_key = 'pt_key=' + res_set['pt_key']
|
||||
pt_pin = 'pt_pin=' + res_set['pt_pin']
|
||||
jd_ck = str(pt_key) + '; ' + str(pt_pin) + ';'
|
||||
if "WSKEY_UPDATE_HOUR" in os.environ:
|
||||
jd_ck = str(pt_key) + ';' + str(pt_pin) + ';__time=' + str(time.time()) + ';'
|
||||
else:
|
||||
jd_ck = str(pt_key) + ';' + str(pt_pin) + ';'
|
||||
except Exception as err:
|
||||
logger.info("JD_appjmp提取Cookie错误 请重试或者更换IP\n")
|
||||
logger.info(str(err))
|
||||
|
@ -414,14 +417,14 @@ def check_cloud():
|
|||
return i
|
||||
logger.info("\n云端地址全部失效, 请检查网络!")
|
||||
try:
|
||||
send('WSKEY转换', '云端地址失效. 请检查网络.')
|
||||
send('WSKEY转换', '云端地址失效. 请联系作者或者检查网络.')
|
||||
except Exception as err:
|
||||
logger.debug(str(err))
|
||||
logger.info("通知发送失败")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
def check_port():
|
||||
logger.info("\n--------------------\n")
|
||||
if "QL_PORT" in os.environ:
|
||||
try:
|
||||
|
@ -430,7 +433,7 @@ if __name__ == '__main__':
|
|||
logger.debug(str(err))
|
||||
logger.info("变量格式有问题...\n格式: export QL_PORT=\"端口号\"")
|
||||
logger.info("使用默认端口5700")
|
||||
port = 5700
|
||||
return 5700
|
||||
else:
|
||||
port = 5700
|
||||
if not ql_check(port):
|
||||
|
@ -439,6 +442,11 @@ if __name__ == '__main__':
|
|||
sys.exit(1)
|
||||
else:
|
||||
logger.info(str(port) + "端口检查通过")
|
||||
return port
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
port = check_port()
|
||||
token = ql_login() # 获取青龙 token
|
||||
s = requests.session()
|
||||
s.headers.update({"authorization": "Bearer " + str(token)})
|
||||
|
@ -450,7 +458,10 @@ if __name__ == '__main__':
|
|||
ua = cloud_arg['User-Agent']
|
||||
wslist = get_wskey()
|
||||
envlist = get_env()
|
||||
sleepTime = 10
|
||||
if "WSKEY_SLEEP" in os.environ and str(os.environ["WSKEY_SLEEP"]).isdigit():
|
||||
sleepTime = int(os.environ["WSKEY_SLEEP"])
|
||||
else:
|
||||
sleepTime = 10
|
||||
for ws in wslist:
|
||||
wspin = ws.split(";")[0]
|
||||
if "pin" in wspin:
|
||||
|
@ -480,12 +491,12 @@ if __name__ == '__main__':
|
|||
else:
|
||||
if "WSKEY_AUTO_DISABLE" in os.environ: # 从系统变量中获取 WSKEY_AUTO_DISABLE
|
||||
logger.info(str(wspin) + "账号失效")
|
||||
text = "账号: {0} WsKey失效".format(wspin)
|
||||
text = "账号: {0} WsKey疑似失效".format(wspin)
|
||||
else:
|
||||
eid = return_serch[2]
|
||||
logger.info(str(wspin) + "账号禁用")
|
||||
ql_disable(eid)
|
||||
text = "账号: {0} WsKey失效, 已禁用Cookie".format(wspin)
|
||||
text = "账号: {0} WsKey疑似失效, 已禁用Cookie".format(wspin)
|
||||
try:
|
||||
send('WsKey转换脚本', text)
|
||||
except Exception as err:
|
||||
|
|
Loading…
Reference in New Issue