From 400413df4555d18cc0c2b2f21dbd1e169cf1f301 Mon Sep 17 00:00:00 2001 From: "James, Zonghan JI" Date: Sat, 21 Nov 2026 11:19:58 +0800 Subject: [PATCH] add GetUserMusicApi & fix wrong in payload & add type args in UserLogoutApi & update README.md --- GetUserMusicApi.py | 23 ++++++++++++ README.md | 89 +++++++++++++++++++++++++++++++++++++++++++++- UserLogoutApi.py | 5 +-- src/payload.py | 56 ++++++++++++++++++++++------- 4 files changed, 158 insertions(+), 15 deletions(-) create mode 100644 GetUserMusicApi.py diff --git a/GetUserMusicApi.py b/GetUserMusicApi.py new file mode 100644 index 0000000..31b66e7 --- /dev/null +++ b/GetUserMusicApi.py @@ -0,0 +1,23 @@ +import argparse +import json + +from src.title import TitleCookie +from src import payload + +def GetUserMusicApi(userId, musicId, cookie): + + data = payload.GetUserMusic(userId, musicId) + + res = TitleCookie(userId, "GetUserMusicApi", data, cookie) + + return res + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Title GetUserMusicApi") + + parser.add_argument("--userId", type=int, required=True, help="userId") + parser.add_argument("--musicId", type=int, required=True, help="musicId") + parser.add_argument("--cookie", type=str, required=True, help="cookie") + + args = parser.parse_args() + print(GetUserMusicApi(args.userId, args.musicId, json.loads(args.cookie))) diff --git a/README.md b/README.md index 01e4b18..7cd1427 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,90 @@ # Kou -SDGA \ No newline at end of file +A Python 3 based「maimai DX International」title server interaction emulator. Inspired by Fragrance/eaquira. + +`SteamingAssets` dumped from .app file is required. Place it in the root of the project. + +## Usage + +Currently, Mifare AiME is the only supported type. + +### `UserLoginApi` + +#### Parameters & Returns + +| Parameter | Type | Required | +| :--- | :--- | :--- | +| `--userId` | `int` | Yes | +| `--accessCode` | `str` | Yes | +| `--serial` | `str` | Yes | +| `--loginDateTime` | `int` | Yes | + +Returns a two-element list containing ```[ResponseBodyFromTitleServer, CookiesFromTitleServer]```, both are string. + +#### Example + +```bash +python3 UserLogin.py \ + --userId 6964139 \ + --accessCode "01036000000000000000" \ + --serial "00000000" \ + --loginDateTime 1700000000 +``` +``` +[ + '{"returnCode":1,"lastLoginDate":"2026-11-21 11:09:25","loginCount":125,"consecutiveLoginCount":3,"loginId":7710449444398826983}', + '{"JSESSIONID": "85F1E8EABB944B94CB581BA05EC6A312"}' +] +``` +--- + +### `UserLogoutApi` + +#### Parameters & Returns + +| Parameter | Type | Required | +| :--- | :--- | :--- | +| `--userId` | `int` | Yes | +| `--accessCode` | `str` | Yes | +| `--logoutType` | `int` | Version-dependent | +| `--loginDateTime` | `int` | Yes | +| `--cookie` | `str` | Yes | + +Returns a string. Just the response from Title Server. + +#### Example + +```bash +python3 UserLogoutApi.py \ + --userId 6964139 \ + --accessCode "01036000000000000000" \ + --logoutType 1 \ + --loginDateTime 1700000000 \ + --cookie '{"JSESSIONID":"TRGISALEAKER"}' +``` +``` +{'returnCode': 1} +``` + +--- + +## 3. `GetUserDataApi` / `GetUserChargeApi` / `GetUserExtendApi` / `GetUserMissionDataApi` / `GetUserOptionApi` / `GetUserRatingApi` + +These scripts share the same parameter signature, requiring only `--userId` and `--cookie`. + +### Parameters + +| Parameter | Type | Required | Notes | +| :--- | :--- | :--- | :--- | +| `--userId` | `int` | Yes | - | +| `--cookie` | `str` | Yes | JSON string | + +Returns a string. Just the response from Title Server. + +### Examples + +```bash +python3 GetUserData.py \ + --userId 6964139 \ + --cookie '{"JSESSIONID": "TRGISALEAKER"}' +``` \ No newline at end of file diff --git a/UserLogoutApi.py b/UserLogoutApi.py index cd882ab..b259067 100644 --- a/UserLogoutApi.py +++ b/UserLogoutApi.py @@ -4,9 +4,9 @@ import json from src.title import TitleCookie from src import payload -def UserLogoutApi(userId, accessCode, loginDateTime, cookie): +def UserLogoutApi(userId, accessCode, loginDateTime, logoutType, cookie): - data = payload.UserLogout(userId, accessCode, loginDateTime) + data = payload.UserLogout(userId, accessCode, loginDateTime, logoutType) res = TitleCookie(userId, "UserLogoutApi", data, cookie) @@ -17,6 +17,7 @@ if __name__ == "__main__": 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("--logoutType", type=int, required=True, help="登出的方法 1 或 4") parser.add_argument("--loginDateTime", type=int, required=True, help="时间戳") parser.add_argument("--cookie", type=str, required=True, help="cookie") diff --git a/src/payload.py b/src/payload.py index 1726e3f..69e1ae1 100644 --- a/src/payload.py +++ b/src/payload.py @@ -6,6 +6,8 @@ from config import * from .loader import MusicDetail from .cipher import CalcRandom +from GetUserMusicApi import GetUserMusicApi + def GetUserPreview(userId): data = { @@ -32,7 +34,7 @@ def UserLogin(userId, accessCode, loginDateTime): return data -def UserLogout(userId, accessCode, loginDateTime): +def UserLogout(userId, accessCode, loginDateTime, logoutType): data = { "userId": userId, @@ -41,7 +43,7 @@ def UserLogout(userId, accessCode, loginDateTime): "placeId": placeId, "clientId": clientId, "loginDateTime": loginDateTime, - "type": 1 + "type": logoutType } return data @@ -61,6 +63,14 @@ def GetUserFavoriteItem(userId, kind): } return data +def GetUserMusic(userId, musicId): + data = { + "userId": userId, + "nextIndex": musicId, + "maxCount": 1 + } + return data + def scoreRank(achievement): if achievement >= 1005000: return 13 @@ -91,6 +101,28 @@ def scoreRank(achievement): else: return 0 +def isNewMusicDetailList(userMusicList): + + user_music_list = userMusicList.get("userMusicList") or [] + if not user_music_list: + return 1 + + detail_list = user_music_list[0].get("userMusicDetailList") or [] + if not detail_list: + return 1 + + # 1. 先核对第一条(或整体)的 musicId 是否与传入的 musicId 相等 + if detail_list[0].get("musicId") != musicId: + return 1 + + # 2. 遍历 list,查找是否存在目标 level(0~4) + for item in detail_list: + if item.get("musicId") == musicId and item.get("level") == level: + return 0 + + # 有该 musicId 的数据(或其他 level),但没有目标 level + return 1 + def UserPlaylogList(loginId, musicId, level, achievement, deluxscore, comboStatus, syncStatus, userData): MusicData = MusicDetail(musicId, level) @@ -184,8 +216,8 @@ def UserPlaylogList(loginId, musicId, level, achievement, deluxscore, comboStatu "lateCount": 0, "isAchieveNewRecord": True, "isDeluxscoreNewRecord": True, - "comboStatus": userData['userData']['playerRating'], - "syncStatus": userData['userData']['playerRating'], + "comboStatus": comboStatus, + "syncStatus": syncStatus, "isClear": True if achievement > 800000 else False, "beforeRating": userData['userData']['playerRating'], "afterRating": userData['userData']['playerRating'], @@ -209,7 +241,7 @@ def UserPlaylogList(loginId, musicId, level, achievement, deluxscore, comboStatu } return data -def UpsertUserAllApi(userId, accessCode, loginId, musicId, level, achievement, deluxscore, comboStatus, syncStatus, loginDateTime, userActivity, userChargeList, userData, userExtend, userMissionData, userOption, userRating): +def UpsertUserAllApi(userId, accessCode, loginId, musicId, level, achievement, deluxscore, comboStatus, syncStatus, loginDateTime, userActivity, userChargeList, userData, userExtend, userMissionData, userMusicList, userOption, userRating): data = { "userId": userId, @@ -319,12 +351,12 @@ def UpsertUserAllApi(userId, accessCode, loginId, musicId, level, achievement, d { "musicId": musicId, "level": level, - "playCount": 1, - "achievement": 0, - "comboStatus": 0, - "syncStatus": 0, - "deluxscoreMax": 0, - "scoreRank": 0, + "playCount": 1, # how can we read from userMusicList? + "achievement": achievement, + "comboStatus": comboStatus, + "syncStatus": syncStatus, + "deluxscoreMax": deluxscore, + "scoreRank": scoreRank(achievement), "extNum1": 0 } ], @@ -397,7 +429,7 @@ def UpsertUserAllApi(userId, accessCode, loginId, musicId, level, achievement, d "isNewMapList": "", # 同上,原始数据0因为跑了个图 "isNewLoginBonusList": "", "isNewItemList": "", - "isNewMusicDetailList": "0", # 0 是修改数据库数据 1 是 insert 新数据 + "isNewMusicDetailList": isNewMusicDetailList(userMusicList), # 0 是修改数据库数据 1 是 insert 新数据 "isNewCourseList": "", "isNewFavoriteList": "", # wdf? "isNewFriendSeasonRankingList": "",