From 29ad40c68c7befbd9007b997de7d76356a26f512 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Tue, 17 Sep 2024 19:09:43 +0800 Subject: [PATCH] :alien: Use new ambr api host --- metadata/scripts/honey.py | 6 +++--- metadata/scripts/metadatas.py | 6 +++--- utils/const/_url.py | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/metadata/scripts/honey.py b/metadata/scripts/honey.py index 84034602..83ede75f 100644 --- a/metadata/scripts/honey.py +++ b/metadata/scripts/honey.py @@ -8,7 +8,7 @@ from aiofiles import open as async_open from httpx import AsyncClient, HTTPError, Response from modules.wiki.base import HONEY_HOST -from utils.const import PROJECT_ROOT +from utils.const import PROJECT_ROOT, AMBR_API_HOST from utils.log import logger from utils.typedefs import StrOrInt @@ -90,7 +90,7 @@ async def get_material_data() -> DATA_TYPE: namecard = [HONEY_HOST.join("fam_nameplate/?lang=CHS")] urls = weapon + talent + namecard - response = await request("https://api.ambr.top/v2/chs/material") + response = await request(AMBR_API_HOST.join("v2/chs/material")) ambr_data = jsonlib.loads(response.text)["data"]["items"] for url in urls: @@ -120,7 +120,7 @@ async def get_artifact_data() -> DATA_TYPE: result = {} url = "https://gensh.honeyhunterworld.com/fam_art_set/?lang=CHS" - response = await request("https://api.ambr.top/v2/chs/reliquary") + response = await request(AMBR_API_HOST.join("v2/chs/reliquary")) ambr_data = jsonlib.loads(response.text)["data"]["items"] response = await request(url) diff --git a/metadata/scripts/metadatas.py b/metadata/scripts/metadatas.py index 4af223ed..458ddc20 100644 --- a/metadata/scripts/metadatas.py +++ b/metadata/scripts/metadatas.py @@ -4,7 +4,7 @@ from typing import Iterator, Dict from aiofiles import open as async_open from httpx import URL, AsyncClient, RemoteProtocolError, Response -from utils.const import AMBR_HOST, PROJECT_ROOT +from utils.const import PROJECT_ROOT, AMBR_API_HOST from utils.log import logger try: @@ -34,7 +34,7 @@ async def fix_metadata_from_ambr(json_data: Dict[str, Dict], data_type: str): need_append_ids = [11304] need_attr = ["id", "rank", "type", "name", "icon", "route"] for wid in need_append_ids: - url = AMBR_HOST.join(f"v2/chs/{data_type}/{wid}") + url = AMBR_API_HOST.join(f"v2/chs/{data_type}/{wid}") response = await client.get(url) json_data_ = jsonlib.loads(response.text)["data"] json_data[str(json_data_["id"])] = {k: json_data_[k] for k in need_attr} @@ -47,7 +47,7 @@ async def update_metadata_from_ambr(overwrite: bool = True): path = PROJECT_ROOT.joinpath(f"metadata/data/{target}.json") if not overwrite and path.exists(): continue - url = AMBR_HOST.join(f"v2/chs/{target}") + url = AMBR_API_HOST.join(f"v2/chs/{target}") path.parent.mkdir(parents=True, exist_ok=True) response = await client.get(url) json_data = jsonlib.loads(response.text)["data"]["items"] diff --git a/utils/const/_url.py b/utils/const/_url.py index 60e60542..08569c77 100644 --- a/utils/const/_url.py +++ b/utils/const/_url.py @@ -1,8 +1,9 @@ from httpx import URL -__all__ = ("HONEY_HOST", "ENKA_HOST", "AMBR_HOST", "CELESTIA_HOST") +__all__ = ("HONEY_HOST", "ENKA_HOST", "AMBR_HOST", "AMBR_API_HOST", "CELESTIA_HOST") HONEY_HOST = URL("https://gensh.honeyhunterworld.com/") ENKA_HOST = URL("https://enka.network/") -AMBR_HOST = URL("https://api.ambr.top/") +AMBR_HOST = URL("https://gi.yatta.top/") +AMBR_API_HOST = AMBR_HOST.join("api/") CELESTIA_HOST = URL("https://www.projectcelestia.com/")