🚚 add types module

This commit is contained in:
oskvr37
2024-07-20 18:22:44 +02:00
parent 0204ac1f87
commit 67a326dd8c
2 changed files with 53 additions and 11 deletions
+4 -11
View File
@@ -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",
+49
View File
@@ -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