From 85c14225d5d7bb27c759fb1b602966fb9ba07be3 Mon Sep 17 00:00:00 2001 From: zaphkito Date: Thu, 11 Apr 2024 08:35:13 +0000 Subject: [PATCH 1/8] mai2: remove dx movieServerUri, deliverServerUri and usbDlServerUri defined dx and newer version request these but no used, they are just exist in game code, only found `oldServerUrl` used in SDEZ 1.00, this should also fix SDGA and SDGB try to visit `ServerUrl + movieServerUrl` although that just because of SEGA shit code --- titles/mai2/dx.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/titles/mai2/dx.py b/titles/mai2/dx.py index 0d3bddd..5113d69 100644 --- a/titles/mai2/dx.py +++ b/titles/mai2/dx.py @@ -48,10 +48,10 @@ class Mai2DX(Mai2Base): "rebootEndTime": reboot_end, "movieUploadLimit": 100, "movieStatus": 1, - "movieServerUri": self.old_server + "movie/", - "deliverServerUri": self.old_server + "deliver/" if self.can_deliver and self.game_config.deliver.enable else "", + "movieServerUri": "", + "deliverServerUri": "", "oldServerUri": self.old_server + "old", - "usbDlServerUri": self.old_server + "usbdl/" if self.can_deliver and self.game_config.deliver.udbdl_enable else "", + "usbDlServerUri": "", "rebootInterval": 0, }, "isAouAccession": False, -- 2.39.2 From b4671eca3d0ca5d34917587a6e45e34ab6f37445 Mon Sep 17 00:00:00 2001 From: zaphkito Date: Sun, 14 Apr 2024 09:43:20 +0000 Subject: [PATCH 2/8] mai2: correct check JP version maimai DX is 1.00.00~1.06.00 maimai DX PLUS is 1.10.01~1.13.00 maimai DX Splash is 1.14.00~1.16.00 maimai DX Splash PLUS is 1.17.00~1.19.00 --- titles/mai2/index.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/titles/mai2/index.py b/titles/mai2/index.py index a1cd7b1..27248c2 100644 --- a/titles/mai2/index.py +++ b/titles/mai2/index.py @@ -252,13 +252,13 @@ class Mai2Servlet(BaseServlet): req_raw = await request.body() internal_ver = 0 client_ip = Utils.get_ip_addr(request) - if version < 105: # 1.0 + if version < 110: # 1.0 internal_ver = Mai2Constants.VER_MAIMAI_DX - elif version >= 105 and version < 110: # PLUS + elif version >= 110 and version < 114: # PLUS internal_ver = Mai2Constants.VER_MAIMAI_DX_PLUS - elif version >= 110 and version < 115: # Splash + elif version >= 114 and version < 117: # Splash internal_ver = Mai2Constants.VER_MAIMAI_DX_SPLASH - elif version >= 115 and version < 120: # Splash PLUS + elif version >= 117 and version < 120: # Splash PLUS internal_ver = Mai2Constants.VER_MAIMAI_DX_SPLASH_PLUS elif version >= 120 and version < 125: # UNiVERSE internal_ver = Mai2Constants.VER_MAIMAI_DX_UNIVERSE -- 2.39.2 From b406ebb833b47bf049bfa4f3503b6fa1ceacd52b Mon Sep 17 00:00:00 2001 From: zaphkito Date: Sun, 14 Apr 2024 10:17:34 +0000 Subject: [PATCH 3/8] mai2: add Int version check --- titles/mai2/index.py | 54 +++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/titles/mai2/index.py b/titles/mai2/index.py index 27248c2..6599d08 100644 --- a/titles/mai2/index.py +++ b/titles/mai2/index.py @@ -252,24 +252,42 @@ class Mai2Servlet(BaseServlet): req_raw = await request.body() internal_ver = 0 client_ip = Utils.get_ip_addr(request) - if version < 110: # 1.0 - internal_ver = Mai2Constants.VER_MAIMAI_DX - elif version >= 110 and version < 114: # PLUS - internal_ver = Mai2Constants.VER_MAIMAI_DX_PLUS - elif version >= 114 and version < 117: # Splash - internal_ver = Mai2Constants.VER_MAIMAI_DX_SPLASH - elif version >= 117 and version < 120: # Splash PLUS - internal_ver = Mai2Constants.VER_MAIMAI_DX_SPLASH_PLUS - elif version >= 120 and version < 125: # UNiVERSE - internal_ver = Mai2Constants.VER_MAIMAI_DX_UNIVERSE - elif version >= 125 and version < 130: # UNiVERSE PLUS - internal_ver = Mai2Constants.VER_MAIMAI_DX_UNIVERSE_PLUS - elif version >= 130 and version < 135: # FESTiVAL - internal_ver = Mai2Constants.VER_MAIMAI_DX_FESTIVAL - elif version >= 135 and version < 140: # FESTiVAL PLUS - internal_ver = Mai2Constants.VER_MAIMAI_DX_FESTIVAL_PLUS - elif version >= 140: # BUDDiES - internal_ver = Mai2Constants.VER_MAIMAI_DX_BUDDIES + if game_code == "SDEZ": # JP + if version < 110: # 1.0 + internal_ver = Mai2Constants.VER_MAIMAI_DX + elif version >= 110 and version < 114: # PLUS + internal_ver = Mai2Constants.VER_MAIMAI_DX_PLUS + elif version >= 114 and version < 117: # Splash + internal_ver = Mai2Constants.VER_MAIMAI_DX_SPLASH + elif version >= 117 and version < 120: # Splash PLUS + internal_ver = Mai2Constants.VER_MAIMAI_DX_SPLASH_PLUS + elif version >= 120 and version < 125: # UNiVERSE + internal_ver = Mai2Constants.VER_MAIMAI_DX_UNIVERSE + elif version >= 125 and version < 130: # UNiVERSE PLUS + internal_ver = Mai2Constants.VER_MAIMAI_DX_UNIVERSE_PLUS + elif version >= 130 and version < 135: # FESTiVAL + internal_ver = Mai2Constants.VER_MAIMAI_DX_FESTIVAL + elif version >= 135 and version < 140: # FESTiVAL PLUS + internal_ver = Mai2Constants.VER_MAIMAI_DX_FESTIVAL_PLUS + elif version >= 140: # BUDDiES + internal_ver = Mai2Constants.VER_MAIMAI_DX_BUDDIES + elif game_code == "SDGA": # Int + if version < 105: # 1.0 + internal_ver = Mai2Constants.VER_MAIMAI_DX + elif version >= 105 and version < 110: # PLUS + internal_ver = Mai2Constants.VER_MAIMAI_DX_PLUS + elif version >= 110 and version < 115: # Splash + internal_ver = Mai2Constants.VER_MAIMAI_DX_SPLASH + elif version >= 115 and version < 120: # Splash PLUS + internal_ver = Mai2Constants.VER_MAIMAI_DX_SPLASH_PLUS + elif version >= 120 and version < 125: # UNiVERSE + internal_ver = Mai2Constants.VER_MAIMAI_DX_UNIVERSE + elif version >= 125 and version < 130: # UNiVERSE PLUS + internal_ver = Mai2Constants.VER_MAIMAI_DX_UNIVERSE_PLUS + elif version >= 130 and version < 135: # FESTiVAL + internal_ver = Mai2Constants.VER_MAIMAI_DX_FESTIVAL + elif version >= 135 and version < 140: # FESTiVAL PLUS + internal_ver = Mai2Constants.VER_MAIMAI_DX_FESTIVAL_PLUS if ( request.headers.get("Mai-Encoding") is not None -- 2.39.2 From 52a9cce5855afddc3eb78d6b46f35815519b3156 Mon Sep 17 00:00:00 2001 From: zaphkito Date: Sun, 14 Apr 2024 19:47:00 +0800 Subject: [PATCH 4/8] mai2: defined correct uri to DX --- titles/mai2/dx.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/titles/mai2/dx.py b/titles/mai2/dx.py index 5113d69..ec1bf3c 100644 --- a/titles/mai2/dx.py +++ b/titles/mai2/dx.py @@ -5,6 +5,7 @@ import json from random import randint from core.config import CoreConfig +from core.utils import Utils from titles.mai2.base import Mai2Base from titles.mai2.config import Mai2Config from titles.mai2.const import Mai2Constants @@ -15,6 +16,13 @@ class Mai2DX(Mai2Base): super().__init__(cfg, game_cfg) self.version = Mai2Constants.VER_MAIMAI_DX + # DX earlier version need a efficient old server uri to work + if not self.core_config.server.is_using_proxy and Utils.get_title_port(self.core_config) != 80: + self.old_server = f"http://{self.core_config.server.hostname}:{Utils.get_title_port(cfg)}/197/" + + else: + self.old_server = f"http://{self.core_config.server.hostname}/197/" + async def handle_get_game_setting_api_request(self, data: Dict): # if reboot start/end time is not defined use the default behavior of being a few hours ago if self.core_config.title.reboot_start_time == "" or self.core_config.title.reboot_end_time == "": @@ -50,7 +58,7 @@ class Mai2DX(Mai2Base): "movieStatus": 1, "movieServerUri": "", "deliverServerUri": "", - "oldServerUri": self.old_server + "old", + "oldServerUri": self.old_server, "usbDlServerUri": "", "rebootInterval": 0, }, -- 2.39.2 From f5d78225e3bb13f7ec20dcb30794160459beb55a Mon Sep 17 00:00:00 2001 From: zaphkito Date: Sun, 14 Apr 2024 19:51:59 +0800 Subject: [PATCH 5/8] mai2: return game code in uri --- titles/cm/base.py | 2 +- titles/mai2/base.py | 4 ++-- titles/mai2/dx.py | 4 ++-- titles/mai2/index.py | 25 ++++++++++--------------- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/titles/cm/base.py b/titles/cm/base.py index e4fd1cb..4a49832 100644 --- a/titles/cm/base.py +++ b/titles/cm/base.py @@ -51,7 +51,7 @@ class CardMakerBase: { "modelKind": 1, "type": 1, - "titleUri": f"{uri}/{self._parse_int_ver(games_ver['maimai'])}/Maimai2Servlet/", + "titleUri": f"{uri}/SDEZ/{self._parse_int_ver(games_ver['maimai'])}/Maimai2Servlet/", }, # ONGEKI { diff --git a/titles/mai2/base.py b/titles/mai2/base.py index 5a5edb9..69abb59 100644 --- a/titles/mai2/base.py +++ b/titles/mai2/base.py @@ -26,10 +26,10 @@ class Mai2Base: self.date_time_format = "%Y-%m-%d %H:%M:%S" if not self.core_config.server.is_using_proxy and Utils.get_title_port(self.core_config) != 80: - self.old_server = f"http://{self.core_config.server.hostname}:{Utils.get_title_port(cfg)}/197/MaimaiServlet/" + self.old_server = f"http://{self.core_config.server.hostname}:{Utils.get_title_port(cfg)}/SDEY/197/MaimaiServlet/" else: - self.old_server = f"http://{self.core_config.server.hostname}/197/MaimaiServlet/" + self.old_server = f"http://{self.core_config.server.hostname}/SDEY/197/MaimaiServlet/" async def handle_get_game_setting_api_request(self, data: Dict): # if reboot start/end time is not defined use the default behavior of being a few hours ago diff --git a/titles/mai2/dx.py b/titles/mai2/dx.py index ec1bf3c..0d2c874 100644 --- a/titles/mai2/dx.py +++ b/titles/mai2/dx.py @@ -18,10 +18,10 @@ class Mai2DX(Mai2Base): # DX earlier version need a efficient old server uri to work if not self.core_config.server.is_using_proxy and Utils.get_title_port(self.core_config) != 80: - self.old_server = f"http://{self.core_config.server.hostname}:{Utils.get_title_port(cfg)}/197/" + self.old_server = f"http://{self.core_config.server.hostname}:{Utils.get_title_port(cfg)}/SDEY/197/" else: - self.old_server = f"http://{self.core_config.server.hostname}/197/" + self.old_server = f"http://{self.core_config.server.hostname}/SDEY/197/" async def handle_get_game_setting_api_request(self, data: Dict): # if reboot start/end time is not defined use the default behavior of being a few hours ago diff --git a/titles/mai2/index.py b/titles/mai2/index.py index 6599d08..1346ba3 100644 --- a/titles/mai2/index.py +++ b/titles/mai2/index.py @@ -105,31 +105,26 @@ class Mai2Servlet(BaseServlet): def get_routes(self) -> List[Route]: return [ - Route("/{version:int}/MaimaiServlet/api/movie/{endpoint:str}", self.handle_movie, methods=['GET', 'POST']), - Route("/{version:int}/MaimaiServlet/old/{endpoint:str}", self.handle_old_srv), - Route("/{version:int}/MaimaiServlet/old/{endpoint:str}/{placeid:str}/{keychip:str}/{userid:int}", self.handle_old_srv_userdata), - Route("/{version:int}/MaimaiServlet/old/{endpoint:str}/{userid:int}", self.handle_old_srv_userdata), - Route("/{version:int}/MaimaiServlet/old/{endpoint:str}/{userid:int}", self.handle_old_srv_userdata), - Route("/{version:int}/MaimaiServlet/usbdl/{endpoint:str}", self.handle_usbdl), - Route("/{version:int}/MaimaiServlet/deliver/{endpoint:str}", self.handle_deliver), - Route("/{version:int}/MaimaiServlet/{endpoint:str}", self.handle_mai, methods=['POST']), + Route("/{game:str}/{version:int}/MaimaiServlet/api/movie/{endpoint:str}", self.handle_movie, methods=['GET', 'POST']), + Route("/{game:str}/{version:int}/MaimaiServlet/old/{endpoint:str}", self.handle_old_srv), + Route("/{game:str}/{version:int}/MaimaiServlet/old/{endpoint:str}/{placeid:str}/{keychip:str}/{userid:int}", self.handle_old_srv_userdata), + Route("/{game:str}/{version:int}/MaimaiServlet/old/{endpoint:str}/{userid:int}", self.handle_old_srv_userdata), + Route("/{game:str}/{version:int}/MaimaiServlet/old/{endpoint:str}/{userid:int}", self.handle_old_srv_userdata), + Route("/{game:str}/{version:int}/MaimaiServlet/usbdl/{endpoint:str}", self.handle_usbdl), + Route("/{game:str}/{version:int}/MaimaiServlet/deliver/{endpoint:str}", self.handle_deliver), + Route("/{game:str}/{version:int}/MaimaiServlet/{endpoint:str}", self.handle_mai, methods=['POST']), Route("/{game:str}/{version:int}/Maimai2Servlet/{endpoint:str}", self.handle_mai2, methods=['POST']), ] def get_allnet_info(self, game_code: str, game_ver: int, keychip: str) -> Tuple[str, str]: - if game_code in {Mai2Constants.GAME_CODE_DX, Mai2Constants.GAME_CODE_DX_INT}: - path = f"{game_code}/{game_ver}" - else: - path = game_ver - if not self.core_cfg.server.is_using_proxy and Utils.get_title_port(self.core_cfg) != 80: return ( - f"http://{self.core_cfg.server.hostname}:{Utils.get_title_port(self.core_cfg)}/{path}/", + f"http://{self.core_cfg.server.hostname}:{Utils.get_title_port(self.core_cfg)}/{game_code}/{game_ver}/", f"{self.core_cfg.server.hostname}", ) return ( - f"http://{self.core_cfg.server.hostname}/{path}/", + f"http://{self.core_cfg.server.hostname}/{game_code}/{game_ver}/", f"{self.core_cfg.server.hostname}", ) -- 2.39.2 From 270f46947f5b1355dde768d0c089fdc12f776c5b Mon Sep 17 00:00:00 2001 From: zaphkito Date: Sun, 14 Apr 2024 19:54:09 +0800 Subject: [PATCH 6/8] chu: improve endpoint replace code --- titles/chuni/index.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/titles/chuni/index.py b/titles/chuni/index.py index b102d5e..f781898 100644 --- a/titles/chuni/index.py +++ b/titles/chuni/index.py @@ -272,7 +272,11 @@ class ChuniServlet(BaseServlet): self.logger.info(f"v{version} {endpoint} request from {client_ip}") self.logger.debug(req_data) - endpoint = endpoint.replace("C3Exp", "") if game_code == "SDGS" else endpoint + endpoint = ( + endpoint.replace("C3Exp", "") + if game_code == "SDGS" + else endpoint + ) func_to_find = "handle_" + inflection.underscore(endpoint) + "_request" handler_cls = self.versions[internal_ver](self.core_cfg, self.game_cfg) -- 2.39.2 From 4964a57b669cc639f6c6c0352acbfcc6954b7b6f Mon Sep 17 00:00:00 2001 From: zaphkito Date: Thu, 25 Apr 2024 14:47:38 +0000 Subject: [PATCH 7/8] ongeki: add missing await --- titles/ongeki/schema/score.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/titles/ongeki/schema/score.py b/titles/ongeki/schema/score.py index dc3a91d..f5ab4e1 100644 --- a/titles/ongeki/schema/score.py +++ b/titles/ongeki/schema/score.py @@ -131,7 +131,7 @@ class OngekiScoreData(BaseData): async def get_tech_count(self, aime_id: int) -> Optional[List[Dict]]: sql = select(tech_count).where(tech_count.c.user == aime_id) - result = self.execute(sql) + result = await self.execute(sql) if result is None: return None -- 2.39.2 From 346b26c4b852468d5c0b22cdb8c7da1f1181ce87 Mon Sep 17 00:00:00 2001 From: zaphkito Date: Wed, 1 May 2024 08:09:44 +0000 Subject: [PATCH 8/8] add warning comment about dx.py old_server --- titles/mai2/dx.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/titles/mai2/dx.py b/titles/mai2/dx.py index 0de0950..4423824 100644 --- a/titles/mai2/dx.py +++ b/titles/mai2/dx.py @@ -17,6 +17,8 @@ class Mai2DX(Mai2Base): self.version = Mai2Constants.VER_MAIMAI_DX # DX earlier version need a efficient old server uri to work + # game will auto add MaimaiServlet endpoint behind return uri + # so do not add "MaimaiServlet" if not self.core_config.server.is_using_proxy and Utils.get_title_port(self.core_config) != 80: self.old_server = f"http://{self.core_config.server.hostname}:{Utils.get_title_port(cfg)}/SDEY/197/" -- 2.39.2