Huge Rewrite!
This commit is contained in:
@@ -13,7 +13,7 @@ from ctypes import c_int32
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Util.Padding import unpad
|
||||
|
||||
from Static_Settings import *
|
||||
from Config import *
|
||||
|
||||
# 舞萌DX 2024
|
||||
AesKey = "n7bx6:@Fg_:2;5E89Phy7AyIcpxEQ:R@"
|
||||
@@ -59,14 +59,15 @@ class aes_pkcs7(object):
|
||||
def SDGBApiHash(api):
|
||||
return hashlib.md5((api+"MaimaiChn"+ObfuscateParam).encode()).hexdigest()
|
||||
|
||||
def apiSDGB(data:str, useApi, agentExtraData, maxRetries=3):
|
||||
def apiSDGB(data:str, useApi, agentExtraData, noLog=False):
|
||||
'''
|
||||
舞萌DX 2024 API 通讯用函数
|
||||
:param data: 请求数据
|
||||
:param useApi: 使用的 API
|
||||
:param agentExtraData: UA 附加信息,机台相关则为狗号(如A63E01E9564),用户相关则为 UID
|
||||
:param maxRetry: 最大重试次数,
|
||||
:param noLog: 是否不记录日志
|
||||
'''
|
||||
maxRetries = 3
|
||||
|
||||
# 历史遗留代码有时候会传入 int,故先全部转 str
|
||||
agentExtra = str(agentExtraData)
|
||||
@@ -79,7 +80,8 @@ def apiSDGB(data:str, useApi, agentExtraData, maxRetries=3):
|
||||
requests.packages.urllib3.disable_warnings()
|
||||
endpoint = "https://maimai-gm.wahlap.com:42081/Maimai2Servlet/"
|
||||
|
||||
logger.debug("TitleServer Request Start: "+ str(useApi)+" , Data: "+str(data))
|
||||
if not noLog:
|
||||
logger.debug("TitleServer Request Start: "+ str(useApi)+" , Data: "+str(data))
|
||||
|
||||
retries = 0
|
||||
while retries < maxRetries:
|
||||
@@ -124,7 +126,8 @@ def apiSDGB(data:str, useApi, agentExtraData, maxRetries=3):
|
||||
# 解压成功,解密请求并返回
|
||||
resultResponse = unpad(aes.decrypt(responseDecompressed), 16).decode()
|
||||
logger.info("TitleServer:" + useApi + " Response: " + str(responseRaw.status_code))
|
||||
logger.debug("TitleServer Response: " + str(resultResponse))
|
||||
if not noLog:
|
||||
logger.debug("TitleServer Response: " + str(resultResponse))
|
||||
return resultResponse
|
||||
|
||||
# 除了 404 和 500 之外的错误重试
|
||||
|
||||
Reference in New Issue
Block a user