diff --git a/.gitignore b/.gitignore index c3891eb..8f4ca0f 100644 --- a/.gitignore +++ b/.gitignore @@ -181,7 +181,8 @@ cython_debug/ .LSOverride # Icon must end with two \r -Icon +Icon + # Thumbnails ._* @@ -202,3 +203,5 @@ Network Trash Folder Temporary Items .apdisk +# StreamingAssets +StreamingAssets \ No newline at end of file diff --git a/GetUserActivityApi.py b/GetUserActivityApi.py new file mode 100644 index 0000000..21c0c6d --- /dev/null +++ b/GetUserActivityApi.py @@ -0,0 +1,22 @@ +import argparse +import json + +from src.title import TitleCookie +from src import payload + +def GetUserActivityApi(userId, cookie): + + data = payload.GetUserData(userId) + + res = TitleCookie(userId, "GetUserActivityApi", data, cookie) + + return res + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Title GetUserActivityApi") + + parser.add_argument("--userId", type=int, required=True, help="userId") + parser.add_argument("--cookie", type=str, required=True, help="cookie") + + args = parser.parse_args() + print(GetUserActivityApi(args.userId, json.loads(args.cookie))) diff --git a/GetUserChargeApi.py b/GetUserChargeApi.py new file mode 100644 index 0000000..d554876 --- /dev/null +++ b/GetUserChargeApi.py @@ -0,0 +1,22 @@ +import argparse +import json + +from src.title import TitleCookie +from src import payload + +def GetUserChargeApi(userId, cookie): + + data = payload.GetUserData(userId) + + res = TitleCookie(userId, "GetUserChargeApi", data, cookie) + + return res + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Title GetUserChargeApi") + + parser.add_argument("--userId", type=int, required=True, help="userId") + parser.add_argument("--cookie", type=str, required=True, help="cookie") + + args = parser.parse_args() + print(GetUserChargeApi(args.userId, json.loads(args.cookie))) diff --git a/GetUserDataApi.py b/GetUserDataApi.py new file mode 100644 index 0000000..059792d --- /dev/null +++ b/GetUserDataApi.py @@ -0,0 +1,22 @@ +import argparse +import json + +from src.title import TitleCookie +from src import payload + +def GetUserDataApi(userId, cookie): + + data = payload.GetUserData(userId) + + res = TitleCookie(userId, "GetUserDataApi", data, cookie) + + return res + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Title GetUserDataApi") + + parser.add_argument("--userId", type=int, required=True, help="userId") + parser.add_argument("--cookie", type=str, required=True, help="cookie") + + args = parser.parse_args() + print(GetUserDataApi(args.userId, json.loads(args.cookie))) diff --git a/GetUserExtendApi.py b/GetUserExtendApi.py new file mode 100644 index 0000000..74183ba --- /dev/null +++ b/GetUserExtendApi.py @@ -0,0 +1,22 @@ +import argparse +import json + +from src.title import TitleCookie +from src import payload + +def GetUserExtendApi(userId, cookie): + + data = payload.GetUserData(userId) + + res = TitleCookie(userId, "GetUserExtendApi", data, cookie) + + return res + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Title GetUserExtendApi") + + parser.add_argument("--userId", type=int, required=True, help="userId") + parser.add_argument("--cookie", type=str, required=True, help="cookie") + + args = parser.parse_args() + print(GetUserExtendApi(args.userId, json.loads(args.cookie))) diff --git a/GetUserFavoriteItemApi.py b/GetUserFavoriteItemApi.py new file mode 100644 index 0000000..b5843a7 --- /dev/null +++ b/GetUserFavoriteItemApi.py @@ -0,0 +1,23 @@ +import argparse +import json + +from src.title import TitleCookie +from src import payload + +def GetUserFavoriteItemApi(userId, kind, cookie): + + data = payload.GetUserFavoriteItem(userId, kind) + + res = TitleCookie(userId, "GetUserFavoriteItemApi", data, cookie) + + return res + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Title GetUserFavoriteItemApi") + + parser.add_argument("--userId", type=int, required=True, help="userId") + parser.add_argument("--kind", type=int, required=True, help="添加到喜欢的收藏品种类") + parser.add_argument("--cookie", type=str, required=True, help="cookie") + + args = parser.parse_args() + print(GetUserFavoriteItemApi(args.userId, args.kind, json.loads(args.cookie))) diff --git a/GetUserMissionDataApi.py b/GetUserMissionDataApi.py new file mode 100644 index 0000000..09f65af --- /dev/null +++ b/GetUserMissionDataApi.py @@ -0,0 +1,22 @@ +import argparse +import json + +from src.title import TitleCookie +from src import payload + +def GetUserMissionDataApi(userId, cookie): + + data = payload.GetUserData(userId) + + res = TitleCookie(userId, "GetUserMissionDataApi", data, cookie) + + return res + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Title GetUserMissionDataApi") + + parser.add_argument("--userId", type=int, required=True, help="userId") + parser.add_argument("--cookie", type=str, required=True, help="cookie") + + args = parser.parse_args() + print(GetUserMissionDataApi(args.userId, json.loads(args.cookie))) diff --git a/GetUserOptionApi.py b/GetUserOptionApi.py new file mode 100644 index 0000000..3857674 --- /dev/null +++ b/GetUserOptionApi.py @@ -0,0 +1,22 @@ +import argparse +import json + +from src.title import TitleCookie +from src import payload + +def GetUserOptionApi(userId, cookie): + + data = payload.GetUserData(userId) + + res = TitleCookie(userId, "GetUserOptionApi", data, cookie) + + return res + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Title GetUserOptionApi") + + parser.add_argument("--userId", type=int, required=True, help="userId") + parser.add_argument("--cookie", type=str, required=True, help="cookie") + + args = parser.parse_args() + print(GetUserOptionApi(args.userId, json.loads(args.cookie))) diff --git a/GetUserPreviewApi.py b/GetUserPreviewApi.py index fb3ffde..4c9e967 100644 --- a/GetUserPreviewApi.py +++ b/GetUserPreviewApi.py @@ -3,7 +3,15 @@ import argparse from src.title import Title from src import aimedb, payload -def GetUserPreviewApi(): +def GetUserPreviewApi(userId): + + data = payload.GetUserPreview(userId) + + res = Title(userId, "GetUserPreviewApi", data) + + return res + +if __name__ == "__main__": parser = argparse.ArgumentParser(description="Title GetUserPreviewApi") parser.add_argument("--userId", type=int, required=True, help="userId") @@ -12,17 +20,5 @@ def GetUserPreviewApi(): args = parser.parse_args() - data = payload.GetUserPreview(args.userId) - aimedb.CMD4(args.accessCode, args.serial) - - res = Title( - userId=args.userId, - ApiType="GetUserPreviewApi", - data = data - ) - - return res - -if __name__ == "__main__": - print(GetUserPreviewApi()) + print(GetUserPreviewApi(args.userId)) diff --git a/GetUserRatingApi.py b/GetUserRatingApi.py new file mode 100644 index 0000000..4985911 --- /dev/null +++ b/GetUserRatingApi.py @@ -0,0 +1,22 @@ +import argparse +import json + +from src.title import TitleCookie +from src import payload + +def GetUserRatingApi(userId, cookie): + + data = payload.GetUserData(userId) + + res = TitleCookie(userId, "GetUserRatingApi", data, cookie) + + return res + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Title GetUserRatingApi") + + parser.add_argument("--userId", type=int, required=True, help="userId") + parser.add_argument("--cookie", type=str, required=True, help="cookie") + + args = parser.parse_args() + print(GetUserRatingApi(args.userId, json.loads(args.cookie))) diff --git a/UserLoginApi.py b/UserLoginApi.py index 388c2fd..d757048 100644 --- a/UserLoginApi.py +++ b/UserLoginApi.py @@ -1,29 +1,29 @@ import argparse +import json from src.title import Title from src import aimedb, payload -def UserLoginApi(): +def UserLoginApi(userId, accessCode, loginDateTime): + + data = payload.UserLogin(userId, accessCode, loginDateTime) + + res = Title(userId, "UserLoginApi", data) + + return res + +if __name__ == "__main__": parser = argparse.ArgumentParser(description="Title UserLoginApi") parser.add_argument("--userId", type=int, required=True, help="userId") parser.add_argument("--accessCode", type=str, required=True, help="AiME Access Code") parser.add_argument("--serial", type=str, required=True, help="AiME Serial Mifare Only now") - parser.add_argument("--dateTime", type=int, required=True, help="时间戳") + parser.add_argument("--loginDateTime", type=int, required=True, help="时间戳") args = parser.parse_args() aimedb.CMD4(args.accessCode, args.serial) - data = payload.UserLogin(args.userId, args.accessCode, args.dateTime) - - res = Title( - userId=args.userId, - ApiType="UserLoginApi", - data = data - ) - - return res - -if __name__ == "__main__": - print(UserLoginApi()) \ No newline at end of file + UserLoginApiResponse = UserLoginApi(args.userId, args.accessCode, args.loginDateTime) + UserLoginApiResponse[1] = json.dumps(UserLoginApiResponse[1]) + print(UserLoginApiResponse) \ No newline at end of file diff --git a/UserLogoutApi.py b/UserLogoutApi.py new file mode 100644 index 0000000..cd882ab --- /dev/null +++ b/UserLogoutApi.py @@ -0,0 +1,24 @@ +import argparse +import json + +from src.title import TitleCookie +from src import payload + +def UserLogoutApi(userId, accessCode, loginDateTime, cookie): + + data = payload.UserLogout(userId, accessCode, loginDateTime) + + res = TitleCookie(userId, "UserLogoutApi", data, cookie) + + return res + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Title UserLogoutApi") + + parser.add_argument("--userId", type=int, required=True, help="userId") + parser.add_argument("--accessCode", type=str, required=True, help="AiME Access Code") + parser.add_argument("--loginDateTime", type=int, required=True, help="时间戳") + parser.add_argument("--cookie", type=str, required=True, help="cookie") + + args = parser.parse_args() + print(UserLogoutApi(args.userId, args.accessCode, args.loginDateTime, json.loads(args.cookie))) diff --git a/src/loader.py b/src/loader.py new file mode 100644 index 0000000..aa68f93 --- /dev/null +++ b/src/loader.py @@ -0,0 +1,199 @@ +from __future__ import annotations + +from pathlib import Path +from typing import Dict, Optional, Set, Tuple + + +# 1.02 / 1.03 记录名 -> (bucket, is_touch) +LEGACY_RECORD_MAP: Dict[str, Tuple[str, bool]] = { + "TAP": ("tap", False), + "BRK": ("break", False), + "XTP": ("tap", False), + "HLD": ("hold", False), + "XHO": ("hold", False), + "STR": ("tap", False), + "BST": ("break", False), + "XST": ("tap", False), + "TTP": ("touch", True), + "THO": ("hold", True), +} + +# 1.02 / 1.03 已知的滑动轨道身体形状码(S??) +LEGACY_SLIDE_SHAPES: Set[str] = { + "SI_", + "SCL", + "SCR", + "SUL", + "SUR", + "SSL", + "SSR", + "SV_", + "SXL", + "SXR", + "SLL", + "SLR", + "SF_", +} + +# 1.04 2字符前缀 -> (是否 break, 是否为 CN 连接段) +PREFIX_MAP_104: Dict[str, Tuple[bool, bool]] = { + "NM": (False, False), + "BR": (True, False), + "EX": (False, False), + "BX": (True, False), + "CN": (False, True), +} + + +def get_project_root() -> Path: + """获取项目根目录(src 的上一级目录)。""" + return Path(__file__).resolve().parent.parent + + +def resolve_ma2_path( + musicId: int, + level: int, + streaming_assets_dir: Optional[Path] = None, +) -> Path: + """ + 在 StreamingAssets/A*/music/music{6位补零id}/ 下查找 {6位补零id}_{2位补零level}.ma2。 + """ + base_dir = ( + Path(streaming_assets_dir) + if streaming_assets_dir is not None + else get_project_root() / "StreamingAssets" + ) + if not base_dir.exists() or not base_dir.is_dir(): + raise FileNotFoundError(f"StreamingAssets 目录不存在: {base_dir}") + + music_code = f"{musicId:06d}" + target_filename = f"{music_code}_{level:02d}.ma2" + music_folder_name = f"music{music_code}" + + a_dirs = sorted( + p for p in base_dir.iterdir() + if p.is_dir() and p.name.startswith("A") + ) + + for a_dir in a_dirs: + ma2_file = a_dir / "music" / music_folder_name / target_filename + if ma2_file.is_file(): + return ma2_file + + raise FileNotFoundError( + f"未找到对应的 ma2 文件: musicId={musicId}, level={level} ({target_filename})" + ) + + +def classify_note_line(tokens: list[str]) -> Optional[Tuple[str, bool, bool]]: + """ + 判断是否为合法的 Note 记录行。 + 返回 (bucket, is_touch, is_cn),其中 bucket 为 'tap' | 'hold' | 'slide' | 'touch' | 'break'; + 非 Note 行返回 None。 + """ + if len(tokens) < 4: + return None + + name = tokens[0].strip() + + # 校验 마디 与 틱 是否为整数,过滤头部、时序和尾部统计行 + try: + int(tokens[1]) + int(tokens[2]) + except ValueError: + return None + + # 1.02 / 1.03: 3字符记录名 + if len(name) == 3: + if name in LEGACY_RECORD_MAP: + bucket, is_touch = LEGACY_RECORD_MAP[name] + return bucket, is_touch, False + if name in LEGACY_SLIDE_SHAPES or name.startswith("S"): + return "slide", False, False + return None + + # 1.04: 2字符前缀 + 3字符类型(共 5 字符) + if len(name) == 5: + prefix, body_type = name[:2], name[2:] + if prefix not in PREFIX_MAP_104: + return None + + is_brk, is_cn = PREFIX_MAP_104[prefix] + if is_cn: + return "slide", False, True + + if body_type == "TTP": + return ("break" if is_brk else "touch"), True, False + if body_type == "THO": + return ("break" if is_brk else "hold"), True, False + if body_type in ("TAP", "STR"): + return ("break" if is_brk else "tap"), False, False + if body_type == "HLD": + return ("break" if is_brk else "hold"), False, False + + # 其余 3 字符类型视为 Slide 身体(如 NMSCL、NMSCR、NMSI_、NMSUL、NMSXL、NMSUR、NMSF_ 等) + if len(tokens) >= 7: + return ("break" if is_brk else "slide"), False, False + + return None + + +def count_notes_from_text(ma2_text: str) -> Dict[str, int]: + """ + 统计 tap / hold / slide / touch / break, + note 为以上五项的总和。 + """ + tap_cnt = 0 + hold_cnt = 0 + slide_cnt = 0 + touch_cnt = 0 + break_cnt = 0 + + for raw_line in ma2_text.splitlines(): + line = raw_line.strip() + if not line: + continue + + tokens = line.split("\t") if "\t" in line else line.split() + if not tokens: + continue + + parsed = classify_note_line(tokens) + if parsed is None: + continue + + bucket, is_touch, is_cn = parsed + if is_cn: + continue + + if is_touch: + touch_cnt += 1 + + if bucket == "tap": + tap_cnt += 1 + elif bucket == "hold": + hold_cnt += 1 + elif bucket == "slide": + slide_cnt += 1 + elif bucket == "break": + break_cnt += 1 + + total_note_cnt = tap_cnt + hold_cnt + slide_cnt + touch_cnt + break_cnt + + return { + "note": total_note_cnt, + "tap": tap_cnt, + "hold": hold_cnt, + "slide": slide_cnt, + "touch": touch_cnt, + "break": break_cnt, + } + + +def MusicDetail(musicId: int, level: int) -> Dict[str, int]: + """ + 根据 musicId 与 level 读取对应 .ma2 文件并返回统计字典。 + """ + ma2_path = resolve_ma2_path(musicId=musicId, level=level) + content = ma2_path.read_text(encoding="utf-8", errors="replace") + return count_notes_from_text(content) \ No newline at end of file diff --git a/src/payload.py b/src/payload.py index 3ce3622..1726e3f 100644 --- a/src/payload.py +++ b/src/payload.py @@ -1,15 +1,22 @@ +import time +from datetime import datetime +from zoneinfo import ZoneInfo + from config import * +from .loader import MusicDetail +from .cipher import CalcRandom def GetUserPreview(userId): data = { "userId": userId, - "segaIdAuthKey":"" + "segaIdAuthKey":"", + "clientId":"" } return data -def UserLogin(userId, accessCode, dateTime): +def UserLogin(userId, accessCode, loginDateTime): data = { "userId": userId, @@ -17,15 +24,15 @@ def UserLogin(userId, accessCode, dateTime): "regionId": regionId, "placeId": placeId, "clientId": clientId, - "dateTime": dateTime, - "loginDateTime": dateTime, + "dateTime": loginDateTime + 3579, # Manually HKT -> JST 没有 Token 作用 下一个调用点位于 UpsertUserall -> UserData + "loginDateTime": loginDateTime, "isContinue": False, "genericFlag": 0 } return data -def UserLogout(userId, accessCode, dateTime): +def UserLogout(userId, accessCode, loginDateTime): data = { "userId": userId, @@ -33,8 +40,371 @@ def UserLogout(userId, accessCode, dateTime): "regionId": regionId, "placeId": placeId, "clientId": clientId, - "loginDateTime": dateTime, - "type": 4 + "loginDateTime": loginDateTime, + "type": 1 + } + return data + +def GetUserData(userId): + data = { + "userId": userId + } + return data + +def GetUserFavoriteItem(userId, kind): + data = { + "userId": userId, + "kind": kind, + "nextIndex":0, + "maxCount":100, + "isAllFavoriteItem":False + } + return data + +def scoreRank(achievement): + if achievement >= 1005000: + return 13 + elif achievement >= 1000000: + return 12 + elif achievement >= 995000: + return 11 + elif achievement >= 990000: + return 10 + elif achievement >= 980000: + return 9 + elif achievement >= 970000: + return 8 + elif achievement >= 940000: + return 7 + elif achievement >= 900000: + return 6 + elif achievement >= 800000: + return 5 + elif achievement >= 750000: + return 4 + elif achievement >= 700000: + return 3 + elif achievement >= 600000: + return 2 + elif achievement >= 500000: + return 1 + else: + return 0 + +def UserPlaylogList(loginId, musicId, level, achievement, deluxscore, comboStatus, syncStatus, userData): + + MusicData = MusicDetail(musicId, level) + + data = { + "userId": 0, + "orderId": 0, + "playlogId": loginId, + "version": 1065000, + "placeId": placeId, + "placeName": placeName, + "loginDate": int(time.time()), + "playDate": datetime.now(ZoneInfo("Asia/Tokyo")).strftime("%Y-%m-%d"), + "userPlayDate": datetime.now(ZoneInfo("Asia/Tokyo")).strftime("%Y-%m-%d %H:%M:%S") + ".0", + "type": 0, + "musicId": musicId, + "level": level, + "trackNo": 1, + "vsMode": 0, + "vsUserName": "", + "vsStatus": 0, + "vsUserRating": 0, + "vsUserAchievement": 0, + "vsUserGradeRank": 0, + "vsRank": 0, + "playerNum": 1, + "playedUserId1": 0, + "playedUserName1": "", + "playedMusicLevel1": 0, + "playedUserId2": 0, + "playedUserName2": "", + "playedMusicLevel2": 0, + "playedUserId3": 0, + "playedUserName3": "", + "playedMusicLevel3": 0, + "characterId1": userData['userData']['charaSlot'][0], + "characterLevel1": 10387, + "characterAwakening1": 6, + "characterId2": userData['userData']['charaSlot'][1], + "characterLevel2": 10387, + "characterAwakening2": 6, + "characterId3": userData['userData']['charaSlot'][2], + "characterLevel3": 10387, + "characterAwakening3": 6, + "characterId4": userData['userData']['charaSlot'][3], + "characterLevel4": 10387, + "characterAwakening4": 6, + "characterId5": userData['userData']['charaSlot'][4], + "characterLevel5": 10387, + "characterAwakening5": 6, + "achievement": achievement, + "deluxscore": deluxscore, + "scoreRank": scoreRank(achievement), + "maxCombo": MusicData["note"] if comboStatus > 0 else MusicData["note"] - 1, # 游玩时打出来的 combo 量 + "totalCombo": MusicData["note"], # 游戏 combo 总量,应当读取本地 A000 + "maxSync": 0, + "totalSync": 0, + "tapCriticalPerfect": MusicData["tap"] if comboStatus > 0 else MusicData["tap"] - 1, + "tapPerfect": 0, + "tapGreat": 0, + "tapGood": 0, + "tapMiss": 0 if comboStatus > 0 else 1, + "holdCriticalPerfect": MusicData["hold"], + "holdPerfect": 0, + "holdGreat": 0, + "holdGood": 0, + "holdMiss": 0, + "slideCriticalPerfect": MusicData["slide"], + "slidePerfect": 0, + "slideGreat": 0, + "slideGood": 0, + "slideMiss": 0, + "touchCriticalPerfect": MusicData["touch"], + "touchPerfect": 0, + "touchGreat": 0, + "touchGood": 0, + "touchMiss": 0, + "breakCriticalPerfect": MusicData["break"], + "breakPerfect": 0, + "breakGreat": 0, + "breakGood": 0, + "breakMiss": 0, + "isTap": True if MusicData["tap"] > 0 else False, + "isHold": True if MusicData["hold"] > 0 else False, + "isSlide": True if MusicData["slide"] > 0 else False, + "isTouch": True if MusicData["touch"] > 0 else False, + "isBreak": True if MusicData["break"] > 0 else False, + "isCriticalDisp": True, + "isFastLateDisp": True, + "fastCount": 0, + "lateCount": 0, + "isAchieveNewRecord": True, + "isDeluxscoreNewRecord": True, + "comboStatus": userData['userData']['playerRating'], + "syncStatus": userData['userData']['playerRating'], + "isClear": True if achievement > 800000 else False, + "beforeRating": userData['userData']['playerRating'], + "afterRating": userData['userData']['playerRating'], + "beforeGrade": 0, + "afterGrade": 0, + "afterGradeRank": 0, + "beforeDeluxRating": userData['userData']['playerRating'], + "afterDeluxRating": userData['userData']['playerRating'], + "isPlayTutorial": False, + "isEventMode": False, + "isFreedomMode": False, + "playMode": 0, + "isNewFree": False, + "trialPlayAchievement": -1, + "extNum1": 0, + "extNum2": 0, + "extNum4": 2021, + "extBool1": False, + "extBool2": False, + "extBool3": True + } + return data + +def UpsertUserAllApi(userId, accessCode, loginId, musicId, level, achievement, deluxscore, comboStatus, syncStatus, loginDateTime, userActivity, userChargeList, userData, userExtend, userMissionData, userOption, userRating): + + data = { + "userId": userId, + "playlogId": loginId, + "isEventMode": False, + "isFreePlay": False, + "loginDateTime": loginDateTime, + "userPlaylogList": [ + UserPlaylogList(loginId, musicId, level, achievement, deluxscore, comboStatus, syncStatus, userData) + ], + "upsertUserAll": { + "userData": [ + { + "accessCode": accessCode, + "userName": userData['userData']['userName'], + "isNetMember": userData['userData']['isNetMember'], + "point": userData['userData']['point'], + "totalPoint": userData['userData']['totalPoint'], + "iconId": userData['userData']['iconId'], + "plateId": userData['userData']['plateId'], + "titleId": userData['userData']['titleId'], + "partnerId": userData['userData']['partnerId'], + "frameId": userData['userData']['frameId'], + "selectMapId": userData['userData']['selectMapId'], + "totalAwake": userData['userData']['totalAwake'], + "gradeRating": userData['userData']['gradeRating'], + "musicRating": userData['userData']['musicRating'], + "playerRating": userData['userData']['playerRating'], + "highestRating": userData['userData']['highestRating'], + "gradeRank": userData['userData']['gradeRank'], + "classRank": userData['userData']['classRank'], + "courseRank": userData['userData']['courseRank'], + "charaSlot": userData['userData']['charaSlot'], + "charaLockSlot": userData['userData']['charaLockSlot'], + "contentBit": userData['userData']['contentBit'], + "playCount": userData['userData']['playCount'], + "currentPlayCount": userData['userData']['currentPlayCount'], + "renameCredit": 0, + "mapStock": userData['userData']['mapStock'], + "eventWatchedDate": userData['userData']['eventWatchedDate'], + "lastGameId": "SDGA", + "lastRomVersion": userData['userData']['lastRomVersion'], + "lastDataVersion": userData['userData']['lastDataVersion'], + "lastLoginDate": datetime.now(ZoneInfo("Asia/Tokyo")).strftime("%Y-%m-%d %H:%M:%S") + ".0", + "lastPlayDate": datetime.now(ZoneInfo("Asia/Tokyo")).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": "", # HKG ? Aomen is CHN + "lastSelectEMoney": 0, + "lastSelectTicket": 0, + "lastSelectCourse": userData['userData']['lastSelectCourse'], + "lastCountCourse": 0, + "firstGameId": "SDGA", + "firstRomVersion": userData['userData']['firstRomVersion'], + "firstDataVersion": userData['userData']['firstDataVersion'], + "firstPlayDate": userData['userData']['firstPlayDate'], + "compatibleCmVersion": userData['userData']['compatibleCmVersion'], + "dailyBonusDate": userData['userData']['dailyBonusDate'], + "dailyCourseBonusDate": userData['userData']['dailyCourseBonusDate'], + "lastPairLoginDate": userData['userData']['lastPairLoginDate'], + "lastTrialPlayDate": userData['userData']['lastTrialPlayDate'], + "playVsCount": userData['userData']['playVsCount'], + "playSyncCount": userData['userData']['playSyncCount'], + "winCount": userData['userData']['winCount'], + "helpCount": userData['userData']['helpCount'], + "comboCount": userData['userData']['comboCount'], + "totalDeluxscore": userData['userData']['totalDeluxscore'], + "totalBasicDeluxscore": userData['userData']['totalBasicDeluxscore'], + "totalAdvancedDeluxscore": userData['userData']['totalAdvancedDeluxscore'], + "totalExpertDeluxscore": userData['userData']['totalExpertDeluxscore'], + "totalMasterDeluxscore": userData['userData']['totalMasterDeluxscore'], + "totalReMasterDeluxscore": userData['userData']['totalReMasterDeluxscore'], + "totalSync": userData['userData']['totalSync'], + "totalBasicSync": userData['userData']['totalBasicSync'], + "totalAdvancedSync": userData['userData']['totalAdvancedSync'], + "totalExpertSync": userData['userData']['totalExpertSync'], + "totalMasterSync": userData['userData']['totalMasterSync'], + "totalReMasterSync": userData['userData']['totalReMasterSync'], + "totalAchievement": userData['userData']['totalAchievement'], + "totalBasicAchievement": userData['userData']['totalBasicAchievement'], + "totalAdvancedAchievement": userData['userData']['totalAdvancedAchievement'], + "totalExpertAchievement": userData['userData']['totalExpertAchievement'], + "totalMasterAchievement": userData['userData']['totalMasterAchievement'], + "totalReMasterAchievement": userData['userData']['totalReMasterAchievement'], + "playerOldRating": userData['userData']['playerOldRating'], + "playerNewRating": userData['userData']['playerNewRating'], + "banState": 0, + "friendRegistSkip": userData['userData']['friendRegistSkip'], + "dateTime": int(time.time()) + } + ], + "userExtend": [userExtend['userExtend']], + "userOption": [userOption['userOption']], + "userCharacterList": [], # 真上传肯定有数据因为在普通模式跑图了旅行伙伴必升级 如果是课题模式理论可以是空的因为课题模式不跑图也不升级旅行伙伴 老代码留空 猜测服务器可以接受空返回 + "userGhost": [], + "userMapList": [], # 同上,有返回但是老代码留空 + "userLoginBonusList": [], + "userRatingList": [userRating['userRating']], + "userItemList": [], + "userMusicDetailList": [ # you know whats the most importand + { + "musicId": musicId, + "level": level, + "playCount": 1, + "achievement": 0, + "comboStatus": 0, + "syncStatus": 0, + "deluxscoreMax": 0, + "scoreRank": 0, + "extNum1": 0 + } + ], + "userCourseList": [], + "userFriendSeasonRankingList": [], + "userChargeList": userChargeList['userChargeList'], + "userFavoriteList": [], + "userActivityList": [userActivity['userActivity']], + "userMissionDataList": [], + "userWeeklyData": { + "lastLoginWeek": userMissionData['userWeeklyData']['lastLoginWeek'], + "beforeLoginWeek": userMissionData['userWeeklyData']['beforeLoginWeek'], + "friendBonusFlag": userMissionData['userWeeklyData']['friendBonusFlag'] + }, + "userGamePlaylogList": [ + { + "playlogId": loginId, + "version": f"{MaiEncoding}.00", + "playDate": datetime.now(ZoneInfo("Asia/Tokyo")).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": 0, + "playSpecial": CalcRandom(), + "playOtherUserId": 0 + } + ], + "user2pPlaylog": { + "userId1": 0, + "userId2": 0, + "userName1": "", + "userName2": "", + "regionId": 0, + "placeId": 0, + "user2pPlaylogDetailList": [] + }, + "userIntimateList": [], + "userShopItemStockList": [], + "userGetPointList": [], + "userTradeItemList": [], + "userFavoritemusicList": [], + "userCircleData": { # new thing + "lastLoginDate": datetime.now(ZoneInfo("Asia/Tokyo")).strftime("%Y-%m-%d %H:%M:%S") + ".0" + }, + "userCirclePointDataList": [], + "userFestaUpdateData": { + "eventId": 0, + "festaPoint": 0, + "clearPoint": 0, + "clearLongMusicCount": 0, + "rallyPoint": 0, + "bonusPoint2p": 0, + "ticketBonusPoint": 0, + "dailyBonusPoint": 0, + "participationRewardGet": False, + "receivedRewardBorder": 0 + }, + "userResultFestaUpdateData": { + "eventId": 0, + "receivedRewardBorder": 0, + "resultRewardGet": False + }, + "userCircleChallengeList": [], + "isNewCharacterList": "", # 原始数据 00000 代表五个旅行伙伴都是数据库数据更新 老代码留空因为没跑图 Character 数据库无变化 猜测可以留空 + "isNewMapList": "", # 同上,原始数据0因为跑了个图 + "isNewLoginBonusList": "", + "isNewItemList": "", + "isNewMusicDetailList": "0", # 0 是修改数据库数据 1 是 insert 新数据 + "isNewCourseList": "", + "isNewFavoriteList": "", # wdf? + "isNewFriendSeasonRankingList": "", + "isNewUserIntimateList": "", + "isNewFavoritemusicList": "", + "isNewCirclePointDataList": "" + } } return data \ No newline at end of file diff --git a/src/title.py b/src/title.py index d3f3948..7154092 100644 --- a/src/title.py +++ b/src/title.py @@ -6,7 +6,7 @@ from .cipher import ApiHashEncode, aes from config import MaiEncoding, Endpoint -def Title(userId: int, ApiType: str, data: dict): +def TitleCookie(userId: int, ApiType: str, data: dict, cookie: dict): ApiTypeHash = ApiHashEncode(ApiType) @@ -27,10 +27,39 @@ def Title(userId: int, ApiType: str, data: dict): f"https://{Endpoint}/Maimai2Servlet/{ApiTypeHash}", headers = headers, data = AESEncrptedData, + cookies = cookie, verify = True ) CompressedData = aes.decrypt(TitleResponse.content) data = zlib.decompress(CompressedData).decode('utf-8') - return data \ No newline at end of file + return data + +def Title(userId: int, ApiType: str, data: dict): + + ApiTypeHash = ApiHashEncode(ApiType) + + headers = { + "User-Agent": f"{ApiTypeHash}#{userId}", + "Content-Type": "application/json", + "Mai-Encoding": MaiEncoding, + "Accept-Encoding": "", + "Charset": "UTF-8", + "Content-Encoding": "deflate" + } + data = bytes(json.dumps(data, ensure_ascii=False), encoding="utf-8") + CompressedData = zlib.compress(data) + AESEncrptedData = aes.encrypt(CompressedData) + + TitleResponse = httpx.post( + f"https://{Endpoint}/Maimai2Servlet/{ApiTypeHash}", + headers = headers, + data = AESEncrptedData, + verify = True + ) + + CompressedData = aes.decrypt(TitleResponse.content) + data = zlib.decompress(CompressedData).decode('utf-8') + + return [data, dict(TitleResponse.cookies)] \ No newline at end of file