forked from GuChen/maimaiDX-API-Web-Server
Initial commit: Add maimaiDX API web application with AimeDB scanning and logging features
This commit is contained in:
270
backend/HelperUserAll.py
Normal file
270
backend/HelperUserAll.py
Normal file
@@ -0,0 +1,270 @@
|
||||
# UserAll 有关的一些辅助函数
|
||||
|
||||
import pytz
|
||||
from datetime import datetime
|
||||
from loguru import logger
|
||||
|
||||
from HelperGetUserThing import implGetUser_
|
||||
from HelperGetUserMusicDetail import getUserMusicDetail
|
||||
|
||||
from Config import (
|
||||
clientId,
|
||||
placeName,
|
||||
placeId,
|
||||
regionId,
|
||||
regionName,
|
||||
)
|
||||
|
||||
|
||||
def isNewMusicType(userId, musicId, level) -> str:
|
||||
"""判断这首 musicId 在 isNewMusicDetailList 应该填什么
|
||||
0: Edit
|
||||
1: Insert
|
||||
一次只能处理一首歌,所以返回值是 str
|
||||
|
||||
未完工,仅供测试
|
||||
"""
|
||||
userMusicDetailList = getUserMusicDetail(userId, musicId, 1)["userMusicList"][0][
|
||||
"userMusicDetailList"
|
||||
]
|
||||
logger.info(userMusicDetailList)
|
||||
try:
|
||||
if (
|
||||
userMusicDetailList[0]["musicId"] == musicId
|
||||
and userMusicDetailList[0]["level"] == level
|
||||
):
|
||||
logger.info(f"We think {musicId} Level {level} should use EDIT.")
|
||||
return "0"
|
||||
except Exception:
|
||||
return "1"
|
||||
|
||||
|
||||
def generateFullUserAll(
|
||||
userId,
|
||||
currentLoginResult,
|
||||
currentLoginTimestamp,
|
||||
currentUserData2,
|
||||
currentPlaySpecial,
|
||||
):
|
||||
"""从服务器取得必要的数据并构建一个比较完整的 UserAll"""
|
||||
|
||||
# 先构建一个基础 UserAll
|
||||
currentUserAll = generateUserAllData(
|
||||
userId,
|
||||
currentLoginResult,
|
||||
currentLoginTimestamp,
|
||||
currentUserData2,
|
||||
currentPlaySpecial,
|
||||
)
|
||||
|
||||
# 然后从服务器取得必要的数据
|
||||
currentUserExtend = implGetUser_("Extend", userId, True)
|
||||
currentUserOption = implGetUser_("Option", userId, True)
|
||||
currentUserRating = implGetUser_("Rating", userId, True)
|
||||
currentUserActivity = implGetUser_("Activity", userId, True)
|
||||
currentUserCharge = implGetUser_("Charge", userId, True)
|
||||
currentUserMissionData = implGetUser_("MissionData", userId, True)
|
||||
|
||||
# 把这些数据都追加进去
|
||||
currentUserAll["upsertUserAll"]["userExtend"] = [currentUserExtend["userExtend"]]
|
||||
currentUserAll["upsertUserAll"]["userOption"] = [currentUserOption["userOption"]]
|
||||
currentUserAll["upsertUserAll"]["userRatingList"] = [
|
||||
currentUserRating["userRating"]
|
||||
]
|
||||
currentUserAll["upsertUserAll"]["userActivityList"] = [
|
||||
currentUserActivity["userActivity"]
|
||||
]
|
||||
currentUserAll["upsertUserAll"]["userChargeList"] = currentUserCharge[
|
||||
"userChargeList"
|
||||
]
|
||||
currentUserAll["upsertUserAll"]["userWeeklyData"] = currentUserMissionData[
|
||||
"userWeeklyData"
|
||||
]
|
||||
|
||||
# 完事
|
||||
return currentUserAll
|
||||
|
||||
|
||||
def generateUserAllData(
|
||||
userId,
|
||||
currentLoginResult,
|
||||
currentLoginTimestamp,
|
||||
currentUserData2,
|
||||
currentPlaySpecial,
|
||||
):
|
||||
"""构建一个非常基础的 UserAll 数据,必须手动填充一些数据"""
|
||||
|
||||
data = {
|
||||
"userId": userId,
|
||||
"playlogId": currentLoginResult["loginId"],
|
||||
"isEventMode": False,
|
||||
"isFreePlay": False,
|
||||
"upsertUserAll": {
|
||||
"userData": [
|
||||
{
|
||||
"accessCode": "",
|
||||
"userName": currentUserData2["userName"],
|
||||
"isNetMember": 1,
|
||||
"point": currentUserData2["point"],
|
||||
"totalPoint": currentUserData2["totalPoint"],
|
||||
"iconId": currentUserData2["iconId"],
|
||||
"plateId": currentUserData2["plateId"],
|
||||
"titleId": currentUserData2["titleId"],
|
||||
"partnerId": currentUserData2["partnerId"],
|
||||
"frameId": currentUserData2["frameId"],
|
||||
"selectMapId": currentUserData2["selectMapId"],
|
||||
"totalAwake": currentUserData2["totalAwake"],
|
||||
"gradeRating": currentUserData2["gradeRating"],
|
||||
"musicRating": currentUserData2["musicRating"],
|
||||
"playerRating": currentUserData2["playerRating"],
|
||||
"highestRating": currentUserData2["highestRating"],
|
||||
"gradeRank": currentUserData2["gradeRank"],
|
||||
"classRank": currentUserData2["classRank"],
|
||||
"courseRank": currentUserData2["courseRank"],
|
||||
"charaSlot": currentUserData2["charaSlot"],
|
||||
"charaLockSlot": currentUserData2["charaLockSlot"],
|
||||
"contentBit": currentUserData2["contentBit"],
|
||||
"playCount": currentUserData2["playCount"],
|
||||
"currentPlayCount": currentUserData2["currentPlayCount"],
|
||||
"renameCredit": 0,
|
||||
"mapStock": currentUserData2["mapStock"],
|
||||
"eventWatchedDate": currentUserData2["eventWatchedDate"],
|
||||
"lastGameId": "SDGB",
|
||||
"lastRomVersion": currentUserData2["lastRomVersion"],
|
||||
"lastDataVersion": currentUserData2["lastDataVersion"],
|
||||
# "lastLoginDate": currentLoginResult['lastLoginDate'], # sb
|
||||
"lastLoginDate": currentUserData2["lastLoginDate"], # 等待测试
|
||||
"lastPlayDate": datetime.now(
|
||||
pytz.timezone("Asia/Shanghai")
|
||||
).strftime("%Y-%m-%d %H:%M:%S")
|
||||
+ ".0",
|
||||
"lastPlayCredit": 1,
|
||||
"lastPlayMode": 0,
|
||||
"lastPlaceId": placeId,
|
||||
"lastPlaceName": placeName,
|
||||
"lastAllNetId": 0,
|
||||
"lastRegionId": regionId,
|
||||
"lastRegionName": regionName,
|
||||
"lastClientId": clientId,
|
||||
"lastCountryCode": "CHN",
|
||||
"lastSelectEMoney": 0,
|
||||
"lastSelectTicket": 0,
|
||||
"lastSelectCourse": currentUserData2["lastSelectCourse"],
|
||||
"lastCountCourse": 0,
|
||||
"firstGameId": "SDGB",
|
||||
"firstRomVersion": currentUserData2["firstRomVersion"],
|
||||
"firstDataVersion": currentUserData2["firstDataVersion"],
|
||||
"firstPlayDate": currentUserData2["firstPlayDate"],
|
||||
"compatibleCmVersion": currentUserData2["compatibleCmVersion"],
|
||||
"dailyBonusDate": currentUserData2["dailyBonusDate"],
|
||||
"dailyCourseBonusDate": currentUserData2["dailyCourseBonusDate"],
|
||||
"lastPairLoginDate": currentUserData2["lastPairLoginDate"],
|
||||
"lastTrialPlayDate": currentUserData2["lastTrialPlayDate"],
|
||||
"playVsCount": 0,
|
||||
"playSyncCount": 0,
|
||||
"winCount": 0,
|
||||
"helpCount": 0,
|
||||
"comboCount": 0,
|
||||
"totalDeluxscore": currentUserData2["totalDeluxscore"],
|
||||
"totalBasicDeluxscore": currentUserData2["totalBasicDeluxscore"],
|
||||
"totalAdvancedDeluxscore": currentUserData2[
|
||||
"totalAdvancedDeluxscore"
|
||||
],
|
||||
"totalExpertDeluxscore": currentUserData2["totalExpertDeluxscore"],
|
||||
"totalMasterDeluxscore": currentUserData2["totalMasterDeluxscore"],
|
||||
"totalReMasterDeluxscore": currentUserData2[
|
||||
"totalReMasterDeluxscore"
|
||||
],
|
||||
"totalSync": currentUserData2["totalSync"],
|
||||
"totalBasicSync": currentUserData2["totalBasicSync"],
|
||||
"totalAdvancedSync": currentUserData2["totalAdvancedSync"],
|
||||
"totalExpertSync": currentUserData2["totalExpertSync"],
|
||||
"totalMasterSync": currentUserData2["totalMasterSync"],
|
||||
"totalReMasterSync": currentUserData2["totalReMasterSync"],
|
||||
"totalAchievement": currentUserData2["totalAchievement"],
|
||||
"totalBasicAchievement": currentUserData2["totalBasicAchievement"],
|
||||
"totalAdvancedAchievement": currentUserData2[
|
||||
"totalAdvancedAchievement"
|
||||
],
|
||||
"totalExpertAchievement": currentUserData2[
|
||||
"totalExpertAchievement"
|
||||
],
|
||||
"totalMasterAchievement": currentUserData2[
|
||||
"totalMasterAchievement"
|
||||
],
|
||||
"totalReMasterAchievement": currentUserData2[
|
||||
"totalReMasterAchievement"
|
||||
],
|
||||
"playerOldRating": currentUserData2["playerOldRating"],
|
||||
"playerNewRating": currentUserData2["playerNewRating"],
|
||||
"banState": 0,
|
||||
"friendRegistSkip": currentUserData2["friendRegistSkip"],
|
||||
"dateTime": currentLoginTimestamp,
|
||||
}
|
||||
],
|
||||
"userExtend": [], # 需要填上
|
||||
"userOption": [], # 需要填上
|
||||
"userGhost": [],
|
||||
"userCharacterList": [],
|
||||
"userMapList": [],
|
||||
"userLoginBonusList": [],
|
||||
"userRatingList": [], # 需要填上
|
||||
"userItemList": [], # 可选,但经常要填上
|
||||
"userMusicDetailList": [], # 需要填上
|
||||
"userCourseList": [],
|
||||
"userFriendSeasonRankingList": [],
|
||||
"userChargeList": [], # 需要填上
|
||||
"userFavoriteList": [],
|
||||
"userActivityList": [], # 需要填上
|
||||
"userMissionDataList": [],
|
||||
"userWeeklyData": [], # 应该需要填上
|
||||
"userGamePlaylogList": [
|
||||
{
|
||||
"playlogId": currentLoginResult["loginId"],
|
||||
"version": "1.51.00",
|
||||
"playDate": datetime.now(pytz.timezone("Asia/Shanghai")).strftime(
|
||||
"%Y-%m-%d %H:%M:%S"
|
||||
)
|
||||
+ ".0",
|
||||
"playMode": 0,
|
||||
"useTicketId": -1,
|
||||
"playCredit": 1,
|
||||
"playTrack": 1,
|
||||
"clientId": clientId,
|
||||
"isPlayTutorial": False,
|
||||
"isEventMode": False,
|
||||
"isNewFree": False,
|
||||
"playCount": currentUserData2["playCount"],
|
||||
"playSpecial": currentPlaySpecial,
|
||||
"playOtherUserId": 0,
|
||||
}
|
||||
],
|
||||
"user2pPlaylog": {
|
||||
"userId1": 0,
|
||||
"userId2": 0,
|
||||
"userName1": "",
|
||||
"userName2": "",
|
||||
"regionId": 0,
|
||||
"placeId": 0,
|
||||
"user2pPlaylogDetailList": [],
|
||||
},
|
||||
"userIntimateList": [],
|
||||
"userShopItemStockList": [],
|
||||
"userGetPointList": [],
|
||||
"userTradeItemList": [],
|
||||
"userFavoritemusicList": [],
|
||||
"userKaleidxScopeList": [],
|
||||
"isNewCharacterList": "",
|
||||
"isNewMapList": "",
|
||||
"isNewLoginBonusList": "",
|
||||
"isNewItemList": "",
|
||||
"isNewMusicDetailList": "", # 可选但经常要填上
|
||||
"isNewCourseList": "0",
|
||||
"isNewFavoriteList": "",
|
||||
"isNewFriendSeasonRankingList": "",
|
||||
"isNewUserIntimateList": "",
|
||||
"isNewFavoritemusicList": "",
|
||||
"isNewKaleidxScopeList": "",
|
||||
},
|
||||
}
|
||||
return data
|
||||
Reference in New Issue
Block a user