From 42ed222095e7087f0ae65de9a6f98c9892372629 Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Wed, 10 May 2023 02:31:30 -0400 Subject: [PATCH] mai2: add gamesetting urls --- titles/mai2/base.py | 8 +++++--- titles/mai2/config.py | 29 +++++++++++++++++++++++++++++ titles/mai2/dx.py | 6 ++++++ titles/mai2/finale.py | 8 ++++++++ titles/mai2/index.py | 30 +++++++++++++++++++++++++++--- 5 files changed, 75 insertions(+), 6 deletions(-) diff --git a/titles/mai2/base.py b/titles/mai2/base.py index 46143ec..ff2a0c5 100644 --- a/titles/mai2/base.py +++ b/titles/mai2/base.py @@ -15,6 +15,9 @@ class Mai2Base: self.version = Mai2Constants.VER_MAIMAI self.data = Mai2Data(cfg) self.logger = logging.getLogger("mai2") + self.can_deliver = False + self.can_usbdl = False + self.old_server = "" if self.core_config.server.is_develop and self.core_config.title.port > 0: self.old_server = f"http://{self.core_config.title.hostname}:{self.core_config.title.port}/SDEY/197/" @@ -32,9 +35,9 @@ class Mai2Base: "movieUploadLimit": 10000, "movieStatus": 0, "movieServerUri": "", - "deliverServerUri": self.old_server + "deliver", + "deliverServerUri": self.old_server + "deliver/" if self.can_deliver and self.game_config.deliver.enable else "", "oldServerUri": self.old_server + "old", - "usbDlServerUri": self.old_server + "usbdl", + "usbDlServerUri": self.old_server + "usbdl/" if self.can_deliver and self.game_config.deliver.udbdl_enable else "", "rebootInterval": 0, }, "isAouAccession": "true", @@ -49,7 +52,6 @@ class Mai2Base: def handle_get_game_event_api_request(self, data: Dict) -> Dict: events = self.data.static.get_enabled_events(self.version) - print(self.version) events_lst = [] if events is None or not events: self.logger.warn("No enabled events, did you run the reader?") diff --git a/titles/mai2/config.py b/titles/mai2/config.py index 3a20065..91cdd87 100644 --- a/titles/mai2/config.py +++ b/titles/mai2/config.py @@ -19,7 +19,36 @@ class Mai2ServerConfig: ) ) +class Mai2DeliverConfig: + def __init__(self, parent: "Mai2Config") -> None: + self.__config = parent + + @property + def enable(self) -> bool: + return CoreConfig.get_config_field( + self.__config, "mai2", "deliver", "enable", default=False + ) + + @property + def udbdl_enable(self) -> bool: + return CoreConfig.get_config_field( + self.__config, "mai2", "deliver", "udbdl_enable", default=False + ) + + @property + def list_folder(self) -> int: + return CoreConfig.get_config_field( + self.__config, "mai2", "server", "list_folder", default="" + ) + + @property + def list_folder(self) -> int: + return CoreConfig.get_config_field( + self.__config, "mai2", "server", "content_folder", default="" + ) + class Mai2Config(dict): def __init__(self) -> None: self.server = Mai2ServerConfig(self) + self.deliver = Mai2DeliverConfig(self) diff --git a/titles/mai2/dx.py b/titles/mai2/dx.py index 9d07d49..0ada84b 100644 --- a/titles/mai2/dx.py +++ b/titles/mai2/dx.py @@ -14,6 +14,12 @@ class Mai2DX(Mai2Base): def __init__(self, cfg: CoreConfig, game_cfg: Mai2Config) -> None: super().__init__(cfg, game_cfg) self.version = Mai2Constants.VER_MAIMAI_DX + + if self.core_config.server.is_develop and self.core_config.title.port > 0: + self.old_server = f"http://{self.core_config.title.hostname}:{self.core_config.title.port}/SDEZ/100/" + + else: + self.old_server = f"http://{self.core_config.title.hostname}/SDEZ/100/" def handle_get_user_preview_api_request(self, data: Dict) -> Dict: p = self.data.profile.get_profile_detail(data["userId"], self.version) diff --git a/titles/mai2/finale.py b/titles/mai2/finale.py index bb4b67e..e29196f 100644 --- a/titles/mai2/finale.py +++ b/titles/mai2/finale.py @@ -13,3 +13,11 @@ class Mai2Finale(Mai2Base): def __init__(self, cfg: CoreConfig, game_cfg: Mai2Config) -> None: super().__init__(cfg, game_cfg) self.version = Mai2Constants.VER_MAIMAI_FINALE + self.can_deliver = True + self.can_usbdl = True + + if self.core_config.server.is_develop and self.core_config.title.port > 0: + self.old_server = f"http://{self.core_config.title.hostname}:{self.core_config.title.port}/SDEY/197/" + + else: + self.old_server = f"http://{self.core_config.title.hostname}/SDEY/197/" diff --git a/titles/mai2/index.py b/titles/mai2/index.py index be73c36..0bb8b44 100644 --- a/titles/mai2/index.py +++ b/titles/mai2/index.py @@ -207,7 +207,31 @@ class Mai2Servlet: return zlib.compress(json.dumps(resp, ensure_ascii=False).encode("utf-8")) def render_GET(self, request: Request, version: int, url_path: str) -> bytes: - if url_path.endswith("ping"): - return zlib.compress(b"ok") + self.logger.info(f"v{version} GET {url_path}") + url_split = url_path.split("/") + + if url_split[0] == "old": + if url_split[1] == "ping": + self.logger.info(f"v{version} old server ping") + return zlib.compress(b"ok") + + elif url_split[1].startswith("userdata"): + self.logger.info(f"v{version} old server userdata inquire") + return zlib.compress(b"{}") + + elif url_split[1].startswith("friend"): + self.logger.info(f"v{version} old server friend inquire") + return zlib.compress(b"{}") + + elif url_split[0] == "usbdl": + if url_split[1] == "CONNECTIONTEST": + self.logger.info(f"v{version} usbdl server test") + return zlib.compress(b"ok") + + elif url_split[0] == "deliver": + if url_split[len(url_split) - 1] == "maimai_deliver.list": + self.logger.info(f"v{version} maimai_deliver.list inquire") + return zlib.compress(b"") + else: - return zlib.compress(b"{}") \ No newline at end of file + return zlib.compress(b"{}")