From 4dad93178cc9008fde481d47f4a1c028340d847d Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Thu, 15 May 2025 13:26:10 -0700 Subject: wmmt: fix navi-scratch image path --- bandai_namco/wmmt.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bandai_namco/wmmt.py b/bandai_namco/wmmt.py index 9ce2147..8695d92 100644 --- a/bandai_namco/wmmt.py +++ b/bandai_namco/wmmt.py @@ -26,6 +26,15 @@ TYPE_MAP = { "ニュース": "NEWS" } +def fix_image_url_path(base_url: str, image_path): + if image_path.startswith(base_url): + return image_path + elif base_url in image_path: + common_path_index = image_path.find(base_url) + len(base_url) + return base_url + image_path[common_path_index:] + else: + return urljoin(base_url, image_path) + def make_wmmt_parser(version: constants.WANGAN_MAXI_VERSION): def five_dx_plus_parser(html: str): soup = BeautifulSoup(html, "html.parser") @@ -144,8 +153,6 @@ def make_wmmt_news_extractor(identifier: str, version: constants.WANGAN_MAXI_VER src = "special/" + src elif data["type"] == "FUTURE LAB": src = "miraiken/" + src - elif data["type"] == "NAVI-SCRATCH": - src = "navi/" elif data["type"] == "UPDATE": src = "update/" + src img_url = image_base + "/" + src if src else None @@ -188,9 +195,10 @@ def make_wmmt_news_extractor(identifier: str, version: constants.WANGAN_MAXI_VER elif data["type"] == "FUTURE LAB": src = "miraiken/" + src elif data["type"] == "NAVI-SCRATCH": - src = "navi/" + src = "navi/" + src elif data["type"] == "UPDATE": src = "update/" + src + src = src.replace("./", "").lstrip("/") img_url = f"{image_base}/{src}" parent = img.find_parent("a") @@ -230,7 +238,7 @@ def make_wmmt_news_extractor(identifier: str, version: constants.WANGAN_MAXI_VER elif data["type"] == "SPECIAL": src = "special/" + src elif data["type"] == "NAVI-SCRATCH": - src = "navi/" + src = "navi/" + src elif data["type"] == "FUTURE LAB": src = "miraiken/" + src elif data["type"] == "UPDATE": -- cgit v1.2.3