mirror of
https://github.com/PaiGramTeam/SIMNet.git
synced 2024-11-22 06:17:57 +00:00
✨ Add custom device header
This commit is contained in:
parent
424c24a10b
commit
0161ec695c
@ -50,7 +50,7 @@ class BaseClient(AsyncContextManager["BaseClient"]):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
game: Optional[Game] = None
|
game: Optional[Game] = None
|
||||||
_device_id = str(uuid.uuid3(uuid.NAMESPACE_URL, "SIMNet"))
|
__device_id = str(uuid.uuid3(uuid.NAMESPACE_URL, "SIMNet"))
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -61,6 +61,8 @@ class BaseClient(AsyncContextManager["BaseClient"]):
|
|||||||
region: Region = Region.OVERSEAS,
|
region: Region = Region.OVERSEAS,
|
||||||
lang: str = "en-us",
|
lang: str = "en-us",
|
||||||
timeout: Optional[TimeoutTypes] = None,
|
timeout: Optional[TimeoutTypes] = None,
|
||||||
|
device_id: Optional[str] = None,
|
||||||
|
device_fp: Optional[str] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the client with the given parameters."""
|
"""Initialize the client with the given parameters."""
|
||||||
if timeout is None:
|
if timeout is None:
|
||||||
@ -78,6 +80,8 @@ class BaseClient(AsyncContextManager["BaseClient"]):
|
|||||||
self.client = AsyncClient(cookies=cookies, timeout=timeout)
|
self.client = AsyncClient(cookies=cookies, timeout=timeout)
|
||||||
self.region = region
|
self.region = region
|
||||||
self.lang = lang
|
self.lang = lang
|
||||||
|
self._device_id = device_id
|
||||||
|
self._device_fp = device_fp
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def cookies(self) -> Cookies:
|
def cookies(self) -> Cookies:
|
||||||
@ -96,15 +100,29 @@ class BaseClient(AsyncContextManager["BaseClient"]):
|
|||||||
@property
|
@property
|
||||||
def device_id(self) -> str:
|
def device_id(self) -> str:
|
||||||
"""Get the device id used for the client."""
|
"""Get the device id used for the client."""
|
||||||
|
if self._device_id:
|
||||||
|
return self._device_id
|
||||||
if self.account_id is not None:
|
if self.account_id is not None:
|
||||||
return str(uuid.uuid3(uuid.NAMESPACE_URL, str(self.account_id)))
|
return str(uuid.uuid3(uuid.NAMESPACE_URL, str(self.account_id)))
|
||||||
return self._device_id
|
return self.__device_id
|
||||||
|
|
||||||
|
@device_id.setter
|
||||||
|
def device_id(self, device_id: str) -> None:
|
||||||
|
"""Set the device id used for the client."""
|
||||||
|
self._device_id = device_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_fp(self) -> str:
|
def device_fp(self) -> str:
|
||||||
"""Get the device fingerprint used for the client."""
|
"""Get the device fingerprint used for the client."""
|
||||||
|
if self._device_fp:
|
||||||
|
return self._device_fp
|
||||||
return hex_digest(self.device_id)[:13]
|
return hex_digest(self.device_id)[:13]
|
||||||
|
|
||||||
|
@device_fp.setter
|
||||||
|
def device_fp(self, device_fp: str) -> None:
|
||||||
|
"""Set the device fingerprint used for the client."""
|
||||||
|
self._device_fp = device_fp
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def app_version(self) -> str:
|
def app_version(self) -> str:
|
||||||
"""Get the app version used for the client."""
|
"""Get the app version used for the client."""
|
||||||
|
Loading…
Reference in New Issue
Block a user