diff --git a/genshin/client/components/chronicle/base.py b/genshin/client/components/chronicle/base.py index 7c29e51d..f3077871 100644 --- a/genshin/client/components/chronicle/base.py +++ b/genshin/client/components/chronicle/base.py @@ -43,10 +43,20 @@ async def request_game_record( *, lang: typing.Optional[str] = None, region: typing.Optional[types.Region] = None, + game: typing.Optional[types.Game] = None, + is_card_wapi: bool = False, **kwargs: typing.Any, ) -> typing.Mapping[str, typing.Any]: """Make a request towards the game record endpoint.""" - base_url = routes.RECORD_URL.get_url(region or self.region) + game = game or self.default_game + if game is None: + raise RuntimeError("No default game set.") + + base_url = ( + routes.RECORD_URL.get_url(region or self.region, game) + if not is_card_wapi + else routes.CARD_WAPI_URL.get_url(region or self.region) + ) url = base_url / endpoint mi18n_task = asyncio.create_task(self._fetch_mi18n("bbs", lang=lang or self.lang)) @@ -74,9 +84,10 @@ async def get_record_cards( cache_key = cache.cache_key("records", hoyolab_id=hoyolab_id, lang=lang or self.lang) if not (data := await self.cache.get(cache_key)): data = await self.request_game_record( - "card/wapi/getGameRecordCard", + "getGameRecordCard", lang=lang, params=dict(uid=hoyolab_id), + is_card_wapi=True, ) if data["list"]: @@ -124,9 +135,10 @@ async def update_settings( game_id = {types.Game.HONKAI: 1, types.Game.GENSHIN: 2, types.Game.STARRAIL: 6, types.Game.ZZZ: 8}[game] await self.request_game_record( - "card/wapi/changeDataSwitch", + "changeDataSwitch", method="POST", data=dict(switch_id=int(setting), is_public=on, game_id=game_id), + is_card_wapi=True, ) @deprecation.deprecated("update_settings") diff --git a/genshin/client/routes.py b/genshin/client/routes.py index 1288c067..cd7eb5dc 100644 --- a/genshin/client/routes.py +++ b/genshin/client/routes.py @@ -13,6 +13,7 @@ "BBS_REFERER_URL", "BBS_URL", "CALCULATOR_URL", + "CARD_WAPI_URL", "CHECK_QRCODE_URL", "CN_WEB_LOGIN_URL", "COMMUNITY_URL", @@ -134,9 +135,23 @@ def get_url(self, region: types.Region, game: types.Game) -> yarl.URL: overseas="https://bbs-api-os.hoyolab.com/community/", chinese="https://api-takumi-record.mihoyo.com/community/", ) -RECORD_URL = InternationalRoute( - overseas="https://bbs-api-os.hoyolab.com/game_record/", - chinese="https://api-takumi-record.mihoyo.com/game_record/app/", +RECORD_URL = GameRoute( + overseas=dict( + genshin="https://bbs-api-os.hoyolab.com/game_record/genshin/api", + hkrpg="https://bbs-api-os.hoyolab.com/game_record/hkrpg/api", + honkai3rd="https://bbs-api-os.hoyolab.com/game_record/honkai3rd/api", + nap="https://sg-act-nap-api.hoyolab.com/event/game_record_zzz/api/zzz", + ), + chinese=dict( + genshin="https://api-takumi-record.mihoyo.com/game_record/app/genshin/api", + hkrpg="https://api-takumi-record.mihoyo.com/game_record/app/hkrpg/api", + honkai3rd="https://api-takumi-record.mihoyo.com/game_record/app/honkai3rd/api", + nap="https://api-takumi-record.mihoyo.com/event/game_record_zzz/api/zzz", + ), +) +CARD_WAPI_URL = InternationalRoute( + overseas="https://bbs-api-os.hoyolab.com/game_record/card/wapi", + chinese="https://api-takumi-record.mihoyo.com/game_record/app/card/wapi", ) LINEUP_URL = InternationalRoute( overseas="https://sg-public-api.hoyoverse.com/event/simulatoros/", @@ -184,11 +199,13 @@ def get_url(self, region: types.Region, game: types.Game) -> yarl.URL: genshin="https://sg-hk4e-api.hoyolab.com/event/sol?act_id=e202102251931481", honkai3rd="https://sg-public-api.hoyolab.com/event/mani?act_id=e202110291205111", hkrpg="https://sg-public-api.hoyolab.com/event/luna/os?act_id=e202303301540311", + nap="https://sg-act-nap-api.hoyolab.com/event/luna/zzz/os?act_id=e202406031448091", ), chinese=dict( genshin="https://api-takumi.mihoyo.com/event/luna/?act_id=e202311201442471", honkai3rd="https://api-takumi.mihoyo.com/event/luna/?act_id=e202306201626331", hkrpg="https://api-takumi.mihoyo.com/event/luna/?act_id=e202304121516551", + nap="https://act-nap-api.mihoyo.com/event/luna/zzz/?act_id=e202406242138391", ), ) @@ -196,6 +213,7 @@ def get_url(self, region: types.Region, game: types.Game) -> yarl.URL: overseas=dict( genshin="https://sg-hk4e-api.hoyoverse.com/common/apicdkey/api/webExchangeCdkey", hkrpg="https://sg-hkrpg-api.hoyoverse.com/common/apicdkey/api/webExchangeCdkey", + nap="https://public-operation-nap.hoyoverse.com/common/apicdkey/api/webExchangeCdkey", ), chinese=dict(), )