forked from Kohaku/maimaiDX-Api
Merge branch 'master' of github.com:Remik1r3n/maimaiDX-Api
This commit is contained in:
commit
f16be3bff6
@ -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("重试多次仍然不能成功请求")
|
||||
|
@ -55,7 +55,7 @@ def getFishRecords(importToken: str) -> dict:
|
||||
def updateFishRecords(importToken: str, records: list[dict]) -> dict:
|
||||
return apiDivingFish('POST', '/player/update_records', importToken, records)
|
||||
|
||||
def maimaiUserMusicDetailToDivingFish(userMusicDetailList: list) -> list:
|
||||
def maimaiUserMusicDetailToDivingFishFormat(userMusicDetailList: list) -> list:
|
||||
'''舞萌的 UserMusicDetail 成绩格式转换成水鱼的格式'''
|
||||
divingFishList = []
|
||||
for currentMusicDetail in userMusicDetailList:
|
||||
@ -89,6 +89,12 @@ def maimaiUserMusicDetailToDivingFish(userMusicDetailList: list) -> list:
|
||||
logger.error(f"Error: {currentMusicDetail}")
|
||||
return divingFishList
|
||||
|
||||
def implUserMusicToDivingFish(userId:int, fishImportToken:str):
|
||||
userFullMusicDetailList = getUserFullMusicDetail(userId)
|
||||
divingFishData = maimaiUserMusicDetailToDivingFishFormat(userFullMusicDetailList)
|
||||
updateFishRecords(fishImportToken, divingFishData)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if True:
|
||||
userId = testUid
|
||||
@ -102,7 +108,7 @@ if __name__ == '__main__':
|
||||
try:
|
||||
userFullMusicDetailList = getUserFullMusicDetail(userId)
|
||||
logger.warning("Now We Begin To Build DivingFish Data")
|
||||
divingFishData = maimaiUserMusicDetailToDivingFish(userFullMusicDetailList)
|
||||
divingFishData = maimaiUserMusicDetailToDivingFishFormat(userFullMusicDetailList)
|
||||
logger.debug(divingFishData)
|
||||
logger.warning("Now We Begin To Update DivingFish Data")
|
||||
updateFishRecords(importToken, divingFishData)
|
||||
|
@ -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