Skip to content

Commit

Permalink
fix: Support ambr version fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
seriaati committed Jan 3, 2025
1 parent 9f2fef5 commit 703db61
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions genshin/utility/extdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import asyncio
import json
import logging
import random
import string
import time
import typing
import warnings
Expand Down Expand Up @@ -48,6 +46,7 @@
ENKA_LOC_URL = "https://raw.githubusercontent.com/EnkaNetwork/API-docs/master/store/loc.json"

AMBR_URL = "https://gi.yatta.moe/api/v2/{lang}/avatar"
AMBR_VERSION_URL = "https://gi.yatta.moe/api/v2/static/version"

ELEMENTS_MAP = {
"Fire": "Pyro",
Expand Down Expand Up @@ -191,11 +190,9 @@ async def update_characters_enka(langs: typing.Sequence[str] = ()) -> None:

async def update_characters_ambr(langs: typing.Sequence[str] = ()) -> None:
"""Update characters with https://ambr.top/."""
version = (await _fetch_jsons(AMBR_VERSION_URL))[0]["data"]["vh"]
langs = langs or list(LANGS.keys())
urls = [
AMBR_URL.format(lang=LANG_MAP[lang]) + f"?{''.join(random.choices(string.ascii_letters, k=5))}"
for lang in langs
]
urls = [AMBR_URL.format(lang=LANG_MAP[lang]) + f"?vh={version}" for lang in langs]

characters_list = await _fetch_jsons(*urls)

Expand Down

0 comments on commit 703db61

Please sign in to comment.