Module genshin.client.components.teapot
Teapot component.
Classes
class TeapotClient (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)
-
teapot component.
Expand source code
class TeapotClient(base.BaseClient): """teapot component.""" async def request_teapot( self, endpoint: str, *, method: str = "GET", lang: typing.Optional[str] = None, params: typing.Optional[typing.Mapping[str, typing.Any]] = None, **kwargs: typing.Any, ) -> typing.Mapping[str, typing.Any]: """Make a request towards the teapot endpoint.""" params = dict(params or {}) base_url = routes.TEAPOT_URL.get_url(self.region) url = base_url / endpoint params["lang"] = lang or self.lang return await self.request(url, method=method, params=params, **kwargs) async def _get_teapot_replica_page( self, page: int, *, zip_type: int = 1, block_id: typing.Optional[str] = None, module_id: typing.Optional[str] = None, region: typing.Optional[str] = None, version: typing.Optional[str] = None, limit: int = 20, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.TeapotReplica]: """Get a teapot replica page.""" params = dict( next=page * limit, # weirdest sorting ever zip_type=zip_type, block_id=block_id or "", module_id=module_id or "", target_region=region or "", version=version or "", limit=limit, ) data = await self.request_teapot("list", lang=lang, params=params) return [models.TeapotReplica(**entry) for entry in data["articles"]] def teapot_replicas( self, *, limit: typing.Optional[int] = None, zip_type: int = 1, block_id: typing.Optional[str] = None, module_id: typing.Optional[str] = None, region: typing.Optional[str] = None, uid: typing.Optional[int] = None, version: typing.Optional[str] = None, page_size: int = 20, lang: typing.Optional[str] = None, ) -> paginators.PagedPaginator[models.TeapotReplica]: """Get a teapot replica paginator.""" if not region and uid: region = utility.recognize_genshin_server(uid) return paginators.PagedPaginator( functools.partial( self._get_teapot_replica_page, zip_type=zip_type, block_id=block_id, module_id=module_id, region=region, version=version, limit=page_size, lang=lang, ), limit=limit, page_size=page_size, )
Ancestors
- 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 request_teapot(self, endpoint: str, *, method: str = 'GET', lang: Optional[str] = None, params: Optional[Mapping[str, Any]] = None, **kwargs: Any) ‑> Mapping[str, Any]
-
Make a request towards the teapot endpoint.
def teapot_replicas(self, *, limit: Optional[int] = None, zip_type: int = 1, block_id: Optional[str] = None, module_id: Optional[str] = None, region: Optional[str] = None, uid: Optional[int] = None, version: Optional[str] = None, page_size: int = 20, lang: Optional[str] = None) ‑> PagedPaginator[TeapotReplica]
-
Get a teapot replica paginator.
Inherited members