👽 Use new ambr api host

This commit is contained in:
xtaodada 2024-09-17 19:09:43 +08:00
parent f13d9955f0
commit 29ad40c68c
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
3 changed files with 9 additions and 8 deletions

View File

@ -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)

View File

@ -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"]

View File

@ -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/")