Module genshin.client.components.chronicle.starrail
StarRail battle chronicle component.
Classes
class StarRailBattleChronicleClient (cookies: Union[ForwardRef('http.cookies.BaseCookie[Any]'), Mapping[Any, Any], str, Sequence[Union[ForwardRef('http.cookies.BaseCookie[Any]'), Mapping[Any, Any], str]], ForwardRef(None)] = None, *, authkey: Optional[str] = None, lang: str = 'en-us', region: Region = Region.OVERSEAS, proxy: Optional[str] = None, game: Optional[Game] = None, uid: Optional[int] = None, hoyolab_id: Optional[int] = None, device_id: Optional[str] = None, device_fp: Optional[str] = None, headers: Union[Mapping[str, str], Mapping[multidict._multidict.istr, str], multidict._multidict.CIMultiDict, multidict._multidict.CIMultiDictProxy, Iterable[Tuple[Union[str, multidict._multidict.istr], str]], ForwardRef(None)] = None, cache: Optional[BaseCache] = None, debug: bool = False)
-
StarRail battle chronicle component.
Expand source code
class StarRailBattleChronicleClient(base.BaseBattleChronicleClient): """StarRail battle chronicle component.""" async def _request_starrail_record( self, endpoint: str, uid: typing.Optional[int] = None, *, method: str = "GET", lang: typing.Optional[str] = None, payload: typing.Optional[typing.Mapping[str, typing.Any]] = None, cache: bool = False, ) -> typing.Mapping[str, typing.Any]: """Get an arbitrary starrail object.""" payload = dict(payload or {}) original_payload = payload.copy() uid = uid or await self._get_uid(types.Game.STARRAIL) payload = dict(role_id=uid, server=utility.recognize_starrail_server(uid), **payload) data, params = None, None if method == "POST": data = payload else: params = payload cache_key: typing.Optional[base.ChronicleCacheKey] = None if cache: cache_key = base.ChronicleCacheKey( types.Game.STARRAIL, endpoint, uid, lang=lang or self.lang, params=tuple(original_payload.values()), ) return await self.request_game_record( endpoint, lang=lang, game=types.Game.STARRAIL, region=utility.recognize_region(uid, game=types.Game.STARRAIL), params=params, data=data, cache=cache_key, ) async def get_starrail_notes( self, uid: typing.Optional[int] = None, *, lang: typing.Optional[str] = None, autoauth: bool = True, ) -> models.StarRailNote: """Get starrail real-time notes.""" try: data = await self._request_starrail_record("note", uid, lang=lang) except errors.DataNotPublic as e: # error raised only when real-time notes are not enabled if uid and (await self._get_uid(types.Game.STARRAIL)) != uid: raise errors.GenshinException(e.response, "Cannot view real-time notes of other users.") from e if not autoauth: raise errors.GenshinException(e.response, "Real-time notes are not enabled.") from e await self.update_settings(3, True, game=types.Game.STARRAIL) data = await self._request_starrail_record("note", uid, lang=lang) return models.StarRailNote(**data) async def get_starrail_user( self, uid: typing.Optional[int] = None, *, lang: typing.Optional[str] = None, ) -> models.StarRailUserStats: """Get starrail user.""" index_data, basic_info = await asyncio.gather( self._request_starrail_record("index", uid, lang=lang), self._request_starrail_record("role/basicInfo", uid, lang=lang), ) basic_data = models.StarRailUserInfo(**basic_info) return models.StarRailUserStats(**index_data, info=basic_data) async def get_starrail_characters( self, uid: typing.Optional[int] = None, *, lang: typing.Optional[str] = None, ) -> models.StarRailDetailCharacters: """Get starrail characters.""" payload = {"need_wiki": "true"} data = await self._request_starrail_record("avatar/info", uid, lang=lang, payload=payload) return models.StarRailDetailCharacters(**data) async def get_starrail_challenge( self, uid: typing.Optional[int] = None, *, previous: bool = False, lang: typing.Optional[str] = None, ) -> models.StarRailChallenge: """Get starrail challenge runs.""" payload = dict(schedule_type=2 if previous else 1, need_all="true") data = await self._request_starrail_record("challenge", uid, lang=lang, payload=payload) return models.StarRailChallenge(**data) async def get_starrail_rogue( self, uid: typing.Optional[int] = None, *, schedule_type: int = 3, lang: typing.Optional[str] = None, ) -> models.StarRailRogue: """Get starrail rogue runs.""" payload = dict(schedule_type=schedule_type, need_detail="true") data = await self._request_starrail_record("rogue", uid, lang=lang, payload=payload) return models.StarRailRogue(**data) async def get_starrail_pure_fiction( self, uid: typing.Optional[int] = None, *, previous: bool = False, lang: typing.Optional[str] = None, ) -> models.StarRailPureFiction: """Get starrail pure fiction runs.""" payload = dict(schedule_type=2 if previous else 1, need_all="true") data = await self._request_starrail_record("challenge_story", uid, lang=lang, payload=payload) return models.StarRailPureFiction(**data) async def get_starrail_apc_shadow( self, uid: typing.Optional[int] = None, *, previous: bool = False, lang: typing.Optional[str] = None, ) -> models.StarRailAPCShadow: """Get starrail apocalyptic shadow runs.""" payload = dict(schedule_type=2 if previous else 1, need_all="true") data = await self._request_starrail_record("challenge_boss", uid, lang=lang, payload=payload) return models.StarRailAPCShadow(**data) async def get_starrail_event_calendar( self, uid: typing.Optional[int] = None, *, lang: typing.Optional[str] = None, ) -> models.HSREventCalendar: """Get HSR event calendar.""" data = await self._request_starrail_record("get_act_calender", uid, lang=lang, cache=True) return models.HSREventCalendar(**data)
Ancestors
- BaseBattleChronicleClient
- BaseClient
- abc.ABC
Subclasses
Class variables
var logger : logging.Logger
Instance variables
var authkeys : dict[Game, str]
var cache : BaseCache
var custom_headers : multidict._multidict.CIMultiDict[str]
var uids : dict[Game, int]
Methods
async def get_starrail_apc_shadow(self, uid: Optional[int] = None, *, previous: bool = False, lang: Optional[str] = None) ‑> StarRailAPCShadow
-
Get starrail apocalyptic shadow runs.
async def get_starrail_challenge(self, uid: Optional[int] = None, *, previous: bool = False, lang: Optional[str] = None) ‑> StarRailChallenge
-
Get starrail challenge runs.
async def get_starrail_characters(self, uid: Optional[int] = None, *, lang: Optional[str] = None) ‑> StarRailDetailCharacters
-
Get starrail characters.
async def get_starrail_event_calendar(self, uid: Optional[int] = None, *, lang: Optional[str] = None) ‑> HSREventCalendar
-
Get HSR event calendar.
async def get_starrail_notes(self, uid: Optional[int] = None, *, lang: Optional[str] = None, autoauth: bool = True) ‑> StarRailNote
-
Get starrail real-time notes.
async def get_starrail_pure_fiction(self, uid: Optional[int] = None, *, previous: bool = False, lang: Optional[str] = None) ‑> StarRailPureFiction
-
Get starrail pure fiction runs.
async def get_starrail_rogue(self, uid: Optional[int] = None, *, schedule_type: int = 3, lang: Optional[str] = None) ‑> StarRailRogue
-
Get starrail rogue runs.
async def get_starrail_user(self, uid: Optional[int] = None, *, lang: Optional[str] = None) ‑> StarRailUserStats
-
Get starrail user.
Inherited members
BaseBattleChronicleClient
:authkey
debug
default_game
device_fp
device_id
game
genshin_accounts
get_game_accounts
get_record_card
get_record_cards
hoyolab_id
lang
proxy
region
request
request_bbs
request_game_record
request_hoyolab
request_webstatic
set_authkey
set_browser_cookies
set_cache
set_cookies
set_redis_cache
set_visibility
uid
update_settings