mirror of
https://github.com/Remik1r3n/maimaiDX-Api.git
synced 2025-05-20 04:17:28 +08:00
Merge branch 'master' of https://github.com/Remik1r3n/maimaiDX-Api
This commit is contained in:
commit
c2fa4e7770
@ -1,9 +1,16 @@
|
||||
# 100% Standalone 的国服 AimeDB 通讯实现
|
||||
|
||||
import hashlib
|
||||
import time
|
||||
import requests
|
||||
import json
|
||||
import re
|
||||
|
||||
# 常量
|
||||
CHIP_ID = "A63E-01E68606624"
|
||||
COMMON_KEY = "XcW5FW4cPArBXEk4vzKz3CIrMuA5EVVW"
|
||||
API_URL = "http://ai.sys-allnet.cn/wc_aime/api/get_data"
|
||||
|
||||
# 计算 SHA256
|
||||
def getSHA256(input_str):
|
||||
"""SHA256计算"""
|
||||
@ -21,15 +28,11 @@ def calcSEGAAimeDBAuthKey(varString:str, timestamp:str, commonKey:str="XcW5FW4cP
|
||||
|
||||
def apiAimeDB(qrCode):
|
||||
"""AimeDB 扫码 API 实现"""
|
||||
CHIP_ID = "A63E-01E68606624"
|
||||
COMMON_KEY = "XcW5FW4cPArBXEk4vzKz3CIrMuA5EVVW"
|
||||
API_URL = "http://ai.sys-allnet.cn/wc_aime/api/get_data"
|
||||
|
||||
# 生成一个时间戳
|
||||
timestamp = generateSEGATimestamp()
|
||||
|
||||
# 使用时间戳计算 key
|
||||
currentKey = calcSEGAAimeDBAuthKey(qrCode, timestamp, COMMON_KEY)
|
||||
currentKey = calcSEGAAimeDBAuthKey(CHIP_ID, timestamp, COMMON_KEY)
|
||||
|
||||
# 构造请求数据
|
||||
payload = {
|
||||
|
@ -138,7 +138,7 @@ def apiSDGB(data:str, useApi, agentExtraData, noLog=False):
|
||||
except Exception as e:
|
||||
logger.warning(f"Request Failed! Will now retry.. {e}")
|
||||
retries += 1
|
||||
time.sleep(4)
|
||||
time.sleep(3)
|
||||
else:
|
||||
# 重试次数用尽,WahlapServerBoomedError
|
||||
raise WahlapServerBoomedError("重试多次仍然不能成功请求")
|
||||
|
@ -23,21 +23,21 @@ def apiBuyTicket(userId:int, ticketType:int, price:int, playerRating:int, playCo
|
||||
# 构造请求数据 Payload
|
||||
data = json.dumps({
|
||||
"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": {
|
||||
"chargeId": ticketType,
|
||||
"stock": 1,
|
||||
"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")
|
||||
},
|
||||
"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 回执
|
||||
|
Loading…
x
Reference in New Issue
Block a user