From 5413c27818c5270442993c17cf3b827e10b29edc Mon Sep 17 00:00:00 2001 From: seria Date: Mon, 9 Dec 2024 16:17:11 +0900 Subject: [PATCH] imp: Make fetch_mi18n method more versatile --- genshin/client/components/hoyolab.py | 8 +++++--- genshin/client/routes.py | 10 ---------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/genshin/client/components/hoyolab.py b/genshin/client/components/hoyolab.py index e6139372..4c446086 100644 --- a/genshin/client/components/hoyolab.py +++ b/genshin/client/components/hoyolab.py @@ -4,6 +4,8 @@ import typing import warnings +import yarl + from genshin import types, utility from genshin.client import cache as client_cache from genshin.client import routes @@ -235,12 +237,12 @@ async def check_in_community(self) -> None: @base.region_specific(types.Region.OVERSEAS) async def fetch_mi18n( - self, filename: str, game: types.Game, *, lang: typing.Optional[str] = None + self, url: typing.Union[str, yarl.URL], filename: str, *, lang: typing.Optional[str] = None ) -> typing.Mapping[str, str]: """Fetch a mi18n file.""" return await self.request( - routes.MI18N_URL.get_url(types.Region.OVERSEAS, game) / f"{filename}/{filename}-{lang or self.lang}.json", - cache=client_cache.cache_key("mi18n", filename=filename, game=game, lang=lang or self.lang), + yarl.URL(url) / f"{filename}/{filename}-{lang or self.lang}.json", + cache=client_cache.cache_key("mi18n", filename=filename, url=url, lang=lang or self.lang), ) @base.region_specific(types.Region.OVERSEAS) diff --git a/genshin/client/routes.py b/genshin/client/routes.py index 77d4249c..c2b6a04d 100644 --- a/genshin/client/routes.py +++ b/genshin/client/routes.py @@ -329,14 +329,4 @@ def get_url(self, region: types.Region, game: types.Game) -> yarl.URL: chinese="https://public-data-api.mihoyo.com/device-fp/api/getFp", ) -MI18N_URL = GameRoute( - overseas=dict( - genshin="https://fastcdn.hoyoverse.com/mi18n/bbs_oversea", - hkrpg="https://webstatic.hoyoverse.com/admin/mi18n/bbs_oversea", - nap="https://fastcdn.hoyoverse.com/mi18n/nap_global", - honkai3rd="https://fastcdn.hoyoverse.com/mi18n/bbs_oversea", - ), - chinese=dict(), -) - MIMO_URL = Route("https://sg-public-api.hoyolab.com/event/e2023mimotravel")