From 37e2da205185ded3e3597ea9c734e2bf7e835fd0 Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Sun, 27 Aug 2023 11:53:29 -0400 Subject: [PATCH] maimai: fix usbdl endpoints --- titles/mai2/index.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/titles/mai2/index.py b/titles/mai2/index.py index 053c7d4..be756da 100644 --- a/titles/mai2/index.py +++ b/titles/mai2/index.py @@ -234,6 +234,10 @@ class Mai2Servlet: 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() + + else: + request.setResponseCode(404) + return b"" if url_split[0] == "old": if url_split[1] == "ping": @@ -247,18 +251,35 @@ class Mai2Servlet: elif url_split[1].startswith("friend"): self.logger.info(f"v{version} old server friend inquire") return zlib.compress(b"{}") + + else: + request.setResponseCode(404) + return 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") + return b"" + + elif self.game_cfg.deliver.udbdl_enable and path.exists(f"{self.game_cfg.deliver.content_folder}/usb/{url_split[-1]}"): + with open(f"{self.game_cfg.deliver.content_folder}/usb/{url_split[-1]}", 'rb') as f: + return f.read() + + else: + request.setResponseCode(404) + return b"" elif url_split[0] == "deliver": file = url_split[len(url_split) - 1] self.logger.info(f"v{version} {file} deliver inquire") - if not self.game_cfg.deliver.enable or not path.exists(f"{self.game_cfg.deliver.content_folder}/{file}"): - return zlib.compress(b"") - + if self.game_cfg.deliver.enable and path.exists(f"{self.game_cfg.deliver.content_folder}/{file}"): + with open(f"{self.game_cfg.deliver.content_folder}/deliver/{url_split[-1]}", 'rb') as f: + return f.read() + + else: + request.setResponseCode(404) + return b"" + else: return zlib.compress(b"{}")