diff --git a/tiddl/api.py b/tiddl/api.py index 5aa8c21..4471573 100644 --- a/tiddl/api.py +++ b/tiddl/api.py @@ -1,20 +1,13 @@ from requests import request, Response -from typing import TypedDict, Literal +from typing import Literal + +from .types import DeviceAuthData, AuthData AUTH_URL = "https://auth.tidal.com/v1/oauth2" CLIENT_ID = "7m7Ap0JC9j1cOM3n" CLIENT_SECRET = "vRAdA108tlvkJpTsGZS8rGZ7xTlbJ0qaZ2K9saEzsgY=" -class DeviceAuthData(TypedDict): - deviceCode: str - userCode: str - verificationUri: str - verificationUriComplete: str - expiresIn: int - interval: int - - class TidalApi: def request( self, method: Literal["GET", "POST"], url: str, data=None, auth=None @@ -33,7 +26,7 @@ class TidalApi: {"client_id": CLIENT_ID, "scope": "r_usr+w_usr+w_sub"}, ).json() - def getToken(self, device_code: str): + def getToken(self, device_code: str) -> AuthData: return self.request( "POST", f"{AUTH_URL}/token", diff --git a/tiddl/types.py b/tiddl/types.py new file mode 100644 index 0000000..5370c97 --- /dev/null +++ b/tiddl/types.py @@ -0,0 +1,49 @@ +from typing import TypedDict, Optional + + +class DeviceAuthData(TypedDict): + deviceCode: str + userCode: str + verificationUri: str + verificationUriComplete: str + expiresIn: int + interval: int + + +class User(TypedDict): + userId: int + email: str + countryCode: str + fullName: Optional[str] + firstName: Optional[str] + lastName: Optional[str] + nickname: Optional[str] + username: str + address: Optional[str] + city: Optional[str] + postalcode: Optional[str] + usState: Optional[str] + phoneNumber: Optional[str] + birthday: Optional[str] + channelId: int + parentId: int + acceptedEULA: bool + created: int + updated: int + facebookUid: int + appleUid: Optional[str] + googleUid: Optional[str] + accountLinkCreated: bool + emailVerified: bool + newUser: bool + + +class AuthData(TypedDict): + scope: str + user: User + clientName: str + token_type: str + access_token: str + refresh_token: str + expires_in: int + user_id: int