diff --git a/simnet/client/components/diary/base.py b/simnet/client/components/diary/base.py index 192203c..8d54c97 100644 --- a/simnet/client/components/diary/base.py +++ b/simnet/client/components/diary/base.py @@ -1,5 +1,5 @@ from datetime import timedelta, timezone, datetime -from typing import Optional, Any, Dict +from typing import Optional, Any, Dict, Union from simnet.client.base import BaseClient from simnet.client.routes import DETAIL_LEDGER_URL, INFO_LEDGER_URL @@ -22,7 +22,7 @@ class BaseDiaryClient(BaseClient): *, game: Optional[Game] = None, detail: bool = False, - month: Optional[int] = None, + month: Union[int, str, None] = None, lang: Optional[str] = None, params: Optional[Dict[str, Any]] = None, ) -> Dict[str, Any]: @@ -43,14 +43,8 @@ class BaseDiaryClient(BaseClient): player_id = player_id or self.player_id params = params or {} - url = ( - DETAIL_LEDGER_URL.get_url(self.region, game) - if detail - else INFO_LEDGER_URL.get_url( - self.region, - game, - ) - ) + base_url = DETAIL_LEDGER_URL if detail else INFO_LEDGER_URL + url = base_url.get_url(self.region, game) if self.region == Region.OVERSEAS or game == Game.STARRAIL: params["uid"] = player_id @@ -60,7 +54,11 @@ class BaseDiaryClient(BaseClient): params["bind_region"] = recognize_server(player_id, game) else: raise TypeError(f"{self.region!r} is not a valid region.") - params["month"] = month or (datetime.now().strftime("%Y%m") if game == Game.STARRAIL else datetime.now().month) + if game == Game.STARRAIL: + month = month or datetime.now(CN_TIMEZONE).strftime("%Y%m") + elif game == Game.GENSHIN: + month = month or str(datetime.now(CN_TIMEZONE).month) + params["month"] = month params["lang"] = lang or self.lang return await self.request_lab(url, params=params) diff --git a/simnet/client/components/diary/starrail.py b/simnet/client/components/diary/starrail.py index 6c041b0..a88ebc4 100644 --- a/simnet/client/components/diary/starrail.py +++ b/simnet/client/components/diary/starrail.py @@ -12,7 +12,7 @@ class StarrailDiaryClient(BaseDiaryClient): self, player_id: Optional[int] = None, *, - month: Optional[int] = None, + month: Optional[str] = None, lang: Optional[str] = None, ) -> StarRailDiary: """Get a traveler's diary with earning details for the month. diff --git a/simnet/client/routes.py b/simnet/client/routes.py index 18ac50f..e3c5167 100644 --- a/simnet/client/routes.py +++ b/simnet/client/routes.py @@ -253,7 +253,7 @@ CALCULATOR_URL = InternationalRoute( DETAIL_LEDGER_URL = GameRoute( overseas=dict( genshin="https://sg-hk4e-api.hoyolab.com/event/ysledgeros/month_detail", - hkrpg="", + hkrpg="https://sg-public-api.hoyolab.com/event/srledger/month_detail", ), chinese=dict( genshin="https://hk4e-api.mihoyo.com/event/ys_ledger/monthDetail", @@ -264,7 +264,7 @@ DETAIL_LEDGER_URL = GameRoute( INFO_LEDGER_URL = GameRoute( overseas=dict( genshin="https://sg-hk4e-api.hoyolab.com/event/ysledgeros/month_info", - hkrpg="", + hkrpg="https://sg-public-api.hoyolab.com/event/srledger/month_info", ), chinese=dict( genshin="https://hk4e-api.mihoyo.com/event/ys_ledger/monthInfo",