mirror of
https://github.com/oskvr37/tiddl.git
synced 2026-06-13 04:05:08 +03:00
🚚 add types module
This commit is contained in:
+4
-11
@@ -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",
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user