Skip to content

Commit

Permalink
Fix mi18n route not working for ZZZ
Browse files Browse the repository at this point in the history
  • Loading branch information
seriaati committed Nov 5, 2024
1 parent 8c87967 commit 7465c23
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 6 additions & 3 deletions genshin/client/components/hoyolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,13 @@ async def check_in_community(self) -> None:
"""Check in to the hoyolab community and claim your daily 5 community exp."""
raise RuntimeError("This API is deprecated.")

async def fetch_mi18n(self, filename: str, *, lang: typing.Optional[str] = None) -> typing.Mapping[str, str]:
@base.region_specific(types.Region.OVERSEAS)
async def fetch_mi18n(
self, filename: str, game: types.Game, *, lang: typing.Optional[str] = None
) -> typing.Mapping[str, str]:
"""Fetch a mi18n file."""
data = await self.request(
routes.MI18N_URL.get_url() / f"{filename}/{filename}-{lang or self.lang}.json",
cache=client_cache.cache_key("mi18n", filename=filename, lang=lang or self.lang),
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),
)
return data
9 changes: 8 additions & 1 deletion genshin/client/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,11 @@ 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 = Route("https://fastcdn.hoyoverse.com/mi18n/bbs_oversea")
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",
),
chinese=dict(),
)

0 comments on commit 7465c23

Please sign in to comment.