mirror of
https://github.com/Remik1r3n/maimaiDX-Api.git
synced 2025-05-20 10:37:28 +08:00
!Important Bugfix!
This commit is contained in:
parent
90d8b74c45
commit
16ab36c45f
@ -1,9 +1,16 @@
|
|||||||
|
# 100% Standalone 的国服 AimeDB 通讯实现
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import time
|
import time
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
# 常量
|
||||||
|
CHIP_ID = "A63E-01E68606624"
|
||||||
|
COMMON_KEY = "XcW5FW4cPArBXEk4vzKz3CIrMuA5EVVW"
|
||||||
|
API_URL = "http://ai.sys-allnet.cn/wc_aime/api/get_data"
|
||||||
|
|
||||||
# 计算 SHA256
|
# 计算 SHA256
|
||||||
def getSHA256(input_str):
|
def getSHA256(input_str):
|
||||||
"""SHA256计算"""
|
"""SHA256计算"""
|
||||||
@ -21,15 +28,11 @@ def calcSEGAAimeDBAuthKey(varString:str, timestamp:str, commonKey:str="XcW5FW4cP
|
|||||||
|
|
||||||
def apiAimeDB(qrCode):
|
def apiAimeDB(qrCode):
|
||||||
"""AimeDB 扫码 API 实现"""
|
"""AimeDB 扫码 API 实现"""
|
||||||
CHIP_ID = "A63E-01E68606624"
|
|
||||||
COMMON_KEY = "XcW5FW4cPArBXEk4vzKz3CIrMuA5EVVW"
|
|
||||||
API_URL = "http://ai.sys-allnet.cn/wc_aime/api/get_data"
|
|
||||||
|
|
||||||
# 生成一个时间戳
|
# 生成一个时间戳
|
||||||
timestamp = generateSEGATimestamp()
|
timestamp = generateSEGATimestamp()
|
||||||
|
|
||||||
# 使用时间戳计算 key
|
# 使用时间戳计算 key
|
||||||
currentKey = calcSEGAAimeDBAuthKey(qrCode, timestamp, COMMON_KEY)
|
currentKey = calcSEGAAimeDBAuthKey(CHIP_ID, timestamp, COMMON_KEY)
|
||||||
|
|
||||||
# 构造请求数据
|
# 构造请求数据
|
||||||
payload = {
|
payload = {
|
||||||
|
@ -138,7 +138,7 @@ def apiSDGB(data:str, useApi, agentExtraData, noLog=False):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Request Failed! Will now retry.. {e}")
|
logger.warning(f"Request Failed! Will now retry.. {e}")
|
||||||
retries += 1
|
retries += 1
|
||||||
time.sleep(4)
|
time.sleep(3)
|
||||||
else:
|
else:
|
||||||
# 重试次数用尽,WahlapServerBoomedError
|
# 重试次数用尽,WahlapServerBoomedError
|
||||||
raise WahlapServerBoomedError("重试多次仍然不能成功请求")
|
raise WahlapServerBoomedError("重试多次仍然不能成功请求")
|
||||||
|
@ -23,21 +23,21 @@ def apiBuyTicket(userId:int, ticketType:int, price:int, playerRating:int, playCo
|
|||||||
# 构造请求数据 Payload
|
# 构造请求数据 Payload
|
||||||
data = json.dumps({
|
data = json.dumps({
|
||||||
"userId": userId,
|
"userId": userId,
|
||||||
|
"userChargelog": {
|
||||||
|
"chargeId": ticketType,
|
||||||
|
"price": price,
|
||||||
|
"purchaseDate": (datetime.now(pytz.timezone('Asia/Shanghai')) - timedelta(hours=1)).strftime("%Y-%m-%d %H:%M:%S.0"),
|
||||||
|
"playCount": playCount,
|
||||||
|
"playerRating": playerRating,
|
||||||
|
"placeId": placeId,
|
||||||
|
"regionId": regionId,
|
||||||
|
"clientId": clientId
|
||||||
|
},
|
||||||
"userCharge": {
|
"userCharge": {
|
||||||
"chargeId": ticketType,
|
"chargeId": ticketType,
|
||||||
"stock": 1,
|
"stock": 1,
|
||||||
"purchaseDate": (datetime.now(pytz.timezone('Asia/Shanghai')) - timedelta(hours=1)).strftime("%Y-%m-%d %H:%M:%S.0"),
|
"purchaseDate": (datetime.now(pytz.timezone('Asia/Shanghai')) - timedelta(hours=1)).strftime("%Y-%m-%d %H:%M:%S.0"),
|
||||||
"validDate": (datetime.now(pytz.timezone('Asia/Shanghai')) - timedelta(hours=1) + timedelta(days=90)).replace(hour=4, minute=0, second=0).strftime("%Y-%m-%d %H:%M:%S")
|
"validDate": (datetime.now(pytz.timezone('Asia/Shanghai')) - timedelta(hours=1) + timedelta(days=90)).replace(hour=4, minute=0, second=0).strftime("%Y-%m-%d %H:%M:%S")
|
||||||
},
|
|
||||||
"userChargelog": {
|
|
||||||
"chargeId": ticketType,
|
|
||||||
"price": price,
|
|
||||||
"purchaseDate": (datetime.now(pytz.timezone('Asia/Shanghai')) - timedelta(hours=1)).strftime("%Y-%m-%d %H:%M:%S.0"),
|
|
||||||
"playcount": playCount,
|
|
||||||
"playerRating": playerRating,
|
|
||||||
"placeId": placeId,
|
|
||||||
"regionId": regionId,
|
|
||||||
"clientId": clientId
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
# 发送请求,返回最终得到的 Json String 回执
|
# 发送请求,返回最终得到的 Json String 回执
|
||||||
|
Loading…
x
Reference in New Issue
Block a user