mirror of
https://github.com/oskvr37/tiddl.git
synced 2026-06-13 12:15:13 +03:00
♻️ add limit consts
This commit is contained in:
+12
-3
@@ -16,6 +16,11 @@ from .types import (
|
||||
|
||||
API_URL = "https://api.tidal.com/v1"
|
||||
|
||||
# Tidal default limits
|
||||
ARTIST_ALBUMS_LIMIT = 50
|
||||
ALBUM_ITEMS_LIMIT = 10
|
||||
PLAYLIST_LIMIT = 50
|
||||
|
||||
|
||||
class TidalApi:
|
||||
def __init__(self, token: str, user_id: str, country_code: str) -> None:
|
||||
@@ -56,7 +61,7 @@ class TidalApi:
|
||||
return self._request(f"tracks/{id}", {"countryCode": self.country_code})
|
||||
|
||||
def getArtistAlbums(
|
||||
self, id: str | int, limit=50, offset=0, onlyNonAlbum=False
|
||||
self, id: str | int, limit=ARTIST_ALBUMS_LIMIT, offset=0, onlyNonAlbum=False
|
||||
) -> AristAlbumsItems:
|
||||
params = {"countryCode": self.country_code, "limit": limit, "offset": offset}
|
||||
|
||||
@@ -71,7 +76,9 @@ class TidalApi:
|
||||
def getAlbum(self, id: str | int) -> Album:
|
||||
return self._request(f"albums/{id}", {"countryCode": self.country_code})
|
||||
|
||||
def getAlbumItems(self, id: str | int, limit=10, offset=0) -> AlbumItems:
|
||||
def getAlbumItems(
|
||||
self, id: str | int, limit=ALBUM_ITEMS_LIMIT, offset=0
|
||||
) -> AlbumItems:
|
||||
return self._request(
|
||||
f"albums/{id}/items",
|
||||
{"countryCode": self.country_code, "limit": limit, "offset": offset},
|
||||
@@ -83,7 +90,9 @@ class TidalApi:
|
||||
{"countryCode": self.country_code},
|
||||
)
|
||||
|
||||
def getPlaylistItems(self, uuid: str, limit=50, offset=0) -> PlaylistItems:
|
||||
def getPlaylistItems(
|
||||
self, uuid: str, limit=PLAYLIST_LIMIT, offset=0
|
||||
) -> PlaylistItems:
|
||||
return self._request(
|
||||
f"playlists/{uuid}/items",
|
||||
{"countryCode": self.country_code, "limit": limit, "offset": offset},
|
||||
|
||||
Reference in New Issue
Block a user