2022-10-21 11:34:49 +00:00
|
|
|
from utils.const import PROJECT_ROOT
|
|
|
|
from aiofiles import open as async_open
|
|
|
|
from httpx import AsyncClient, URL
|
|
|
|
|
2022-10-21 17:13:10 +00:00
|
|
|
GACHA_LOG_PAIMON_MOE_PATH = PROJECT_ROOT.joinpath("metadata/data/paimon_moe_zh.json")
|
|
|
|
|
2022-10-21 11:34:49 +00:00
|
|
|
|
|
|
|
async def update_paimon_moe_zh(overwrite: bool = True):
|
2022-10-21 17:13:10 +00:00
|
|
|
if not overwrite and GACHA_LOG_PAIMON_MOE_PATH.exists():
|
2022-10-21 11:34:49 +00:00
|
|
|
return
|
|
|
|
host = URL("https://raw.fastgit.org/MadeBaruna/paimon-moe/main/src/locales/items/zh.json")
|
|
|
|
client = AsyncClient()
|
|
|
|
text = (await client.get(host)).text
|
2022-10-21 17:13:10 +00:00
|
|
|
async with async_open(GACHA_LOG_PAIMON_MOE_PATH, mode="w", encoding="utf-8") as file:
|
2022-10-21 11:34:49 +00:00
|
|
|
await file.write(text)
|