From e3d38dacde7d7d6e82e625496803ee4e860e5f9c Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Sun, 25 Jun 2023 19:10:34 -0400 Subject: [PATCH] mai2: fix movies --- titles/mai2/base.py | 2 +- titles/mai2/config.py | 29 +++++++++++++++++++++++++++++ titles/mai2/index.py | 6 +++--- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/titles/mai2/base.py b/titles/mai2/base.py index e77b2e1..ef15abe 100644 --- a/titles/mai2/base.py +++ b/titles/mai2/base.py @@ -36,7 +36,7 @@ class Mai2Base: "rebootEndTime": "2020-01-01 07:59:59.0", "movieUploadLimit": 100, "movieStatus": 1, - "movieServerUri": self.old_server + "movie", + "movieServerUri": self.old_server + "api/movie" if self.game_config.uploads.movies else "movie", "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/" if self.can_deliver and self.game_config.deliver.udbdl_enable else "", diff --git a/titles/mai2/config.py b/titles/mai2/config.py index d5ed41f..d63c0b2 100644 --- a/titles/mai2/config.py +++ b/titles/mai2/config.py @@ -41,8 +41,37 @@ class Mai2DeliverConfig: self.__config, "mai2", "server", "content_folder", default="" ) +class Mai2UploadsConfig: + def __init__(self, parent: "Mai2Config") -> None: + self.__config = parent + + @property + def photos(self) -> bool: + return CoreConfig.get_config_field( + self.__config, "mai2", "uploads", "photos", default=False + ) + + @property + def photos_dir(self) -> str: + return CoreConfig.get_config_field( + self.__config, "mai2", "uploads", "photos_dir", default="" + ) + + @property + def movies(self) -> bool: + return CoreConfig.get_config_field( + self.__config, "mai2", "uploads", "movies", default=False + ) + + @property + def movies_dir(self) -> str: + return CoreConfig.get_config_field( + self.__config, "mai2", "uploads", "movies_dir", default="" + ) + class Mai2Config(dict): def __init__(self) -> None: self.server = Mai2ServerConfig(self) self.deliver = Mai2DeliverConfig(self) + self.uploads = Mai2UploadsConfig(self) diff --git a/titles/mai2/index.py b/titles/mai2/index.py index 1d9b8bf..c250894 100644 --- a/titles/mai2/index.py +++ b/titles/mai2/index.py @@ -113,7 +113,7 @@ class Mai2Servlet: if url_path.lower() == "ping": return zlib.compress(b'{"returnCode": "1"}') - elif url_path.startswith("movie/"): + elif url_path.startswith("api/movie/"): self.logger.info(f"Movie data: {url_path} - {request.content.getvalue()}") return b"" @@ -215,8 +215,8 @@ class Mai2Servlet: self.logger.info(f"v{version} GET {url_path}") url_split = url_path.split("/") - if url_split[0] == "movie": - if url_split[1] == "moviestart": + if (url_split[0] == "api" and url_split[1] == "movie") or url_split[0] == "movie": + if url_split[2] == "moviestart": return json.dumps({"moviestart":{"status":"OK"}}).encode() if url_split[0] == "old":