2022-10-21 11:34:49 +00:00
|
|
|
from aiofiles import open as async_open
|
2023-03-14 01:27:22 +00:00
|
|
|
from httpx import URL, AsyncClient
|
|
|
|
|
|
|
|
from utils.const import PROJECT_ROOT
|
2022-10-21 11:34:49 +00:00
|
|
|
|
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
|
2023-03-27 01:04:08 +00:00
|
|
|
host = URL("https://raw.githubusercontent.com/MadeBaruna/paimon-moe/main/src/locales/items/zh.json")
|
2022-10-21 11:34:49 +00:00
|
|
|
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)
|