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