mirror of
https://github.com/oskvr37/tiddl.git
synced 2026-06-13 12:15:13 +03:00
🏷️ move search to api, artist to resource
This commit is contained in:
+7
-2
@@ -11,11 +11,11 @@ from tiddl.models.api import (
|
||||
Favorites,
|
||||
PlaylistItems,
|
||||
SessionResponse,
|
||||
Search,
|
||||
TrackStream,
|
||||
)
|
||||
from tiddl.models.constants import TrackQuality
|
||||
from tiddl.models.resource import Track, Album, Playlist
|
||||
from tiddl.models.search import Search
|
||||
from tiddl.models.resource import Track, Album, Playlist, Artist
|
||||
|
||||
DEBUG = False
|
||||
API_URL = "https://api.tidal.com/v1"
|
||||
@@ -85,6 +85,11 @@ class TidalApi:
|
||||
**self._request(f"tracks/{id}", {"countryCode": self.country_code})
|
||||
)
|
||||
|
||||
def getArtist(self, id: str | int):
|
||||
return Artist(
|
||||
**self._request(f"artists/{id}", {"countryCode": self.country_code})
|
||||
)
|
||||
|
||||
def getArtistAlbums(
|
||||
self, id: str | int, limit=ARTIST_ALBUMS_LIMIT, offset=0, onlyNonAlbum=False
|
||||
):
|
||||
|
||||
+35
-1
@@ -1,7 +1,7 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional, List, Literal, Union
|
||||
|
||||
from .resource import Video, Album, Track, TrackQuality
|
||||
from .resource import Album, Artist, Playlist, Track, TrackQuality, Video
|
||||
|
||||
__all__ = [
|
||||
"Client",
|
||||
@@ -11,6 +11,7 @@ __all__ = [
|
||||
"PlaylistItems",
|
||||
"Favorites",
|
||||
"TrackStream",
|
||||
"Search"
|
||||
]
|
||||
|
||||
|
||||
@@ -105,3 +106,36 @@ class TrackStream(BaseModel):
|
||||
trackPeakAmplitude: float
|
||||
bitDepth: Optional[int] = None
|
||||
sampleRate: Optional[int] = None
|
||||
|
||||
|
||||
class Search(BaseModel):
|
||||
|
||||
class Artists(Items):
|
||||
items: List[Artist]
|
||||
|
||||
class Albums(Items):
|
||||
class SearchAlbum(Album):
|
||||
# TODO: remove the artist field instead of making it None
|
||||
artist: None = None
|
||||
|
||||
items: List[SearchAlbum]
|
||||
|
||||
class Playlists(Items):
|
||||
items: List[Playlist]
|
||||
|
||||
class Tracks(Items):
|
||||
items: List[Track]
|
||||
|
||||
class Videos(Items):
|
||||
items: List[Video]
|
||||
|
||||
class TopHit(BaseModel):
|
||||
value: Union[Artist, Track, Playlist, Album]
|
||||
type: Literal["ARTISTS", "TRACKS", "PLAYLISTS", "ALBUMS"]
|
||||
|
||||
artists: Artists
|
||||
albums: Albums
|
||||
playlists: Playlists
|
||||
tracks: Tracks
|
||||
videos: Videos
|
||||
topHit: TopHit
|
||||
|
||||
@@ -4,7 +4,7 @@ from typing import Optional, List, Literal, Dict
|
||||
from .constants import TrackQuality
|
||||
|
||||
|
||||
__all__ = ["Track", "Video", "Album", "Playlist"]
|
||||
__all__ = ["Track", "Video", "Album", "Playlist", "Artist"]
|
||||
|
||||
|
||||
class Track(BaseModel):
|
||||
@@ -159,3 +159,33 @@ class Playlist(BaseModel):
|
||||
squareImage: str
|
||||
promotedArtists: List[Album.Artist]
|
||||
lastItemAddedAt: Optional[str] = None
|
||||
|
||||
|
||||
class Artist(BaseModel):
|
||||
|
||||
class Role(BaseModel):
|
||||
categoryId: int
|
||||
category: Literal[
|
||||
"Artist",
|
||||
"Songwriter",
|
||||
"Performer",
|
||||
"Producer",
|
||||
"Engineer",
|
||||
"Production team",
|
||||
"Misc",
|
||||
]
|
||||
|
||||
class Mix(BaseModel):
|
||||
ARTIST_MIX: str
|
||||
MASTER_ARTIST_MIX: Optional[str] = None
|
||||
|
||||
id: int
|
||||
name: str
|
||||
artistTypes: Optional[List[Literal["ARTIST", "CONTRIBUTOR"]]] = None
|
||||
url: Optional[str] = None
|
||||
picture: Optional[str] = None
|
||||
# only in search i guess
|
||||
selectedAlbumCoverFallback: Optional[str] = None
|
||||
popularity: Optional[int] = None
|
||||
artistRoles: Optional[List[Role]] = None
|
||||
mixes: Optional[Mix | Dict] = None
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional, List, Literal, Dict, Union
|
||||
|
||||
from .resource import Track, Playlist, Album, Video
|
||||
from .api import Items
|
||||
|
||||
|
||||
class Artist(BaseModel):
|
||||
|
||||
class Role(BaseModel):
|
||||
categoryId: int
|
||||
category: Literal[
|
||||
"Artist",
|
||||
"Songwriter",
|
||||
"Performer",
|
||||
"Producer",
|
||||
"Engineer",
|
||||
"Production team",
|
||||
"Misc",
|
||||
]
|
||||
|
||||
class Mix(BaseModel):
|
||||
ARTIST_MIX: str
|
||||
|
||||
id: int
|
||||
name: str
|
||||
artistTypes: Optional[List[Literal["ARTIST", "CONTRIBUTOR"]]] = None
|
||||
url: Optional[str] = None
|
||||
picture: Optional[str] = None
|
||||
selectedAlbumCoverFallback: Optional[str] = None
|
||||
popularity: Optional[int] = None
|
||||
artistRoles: Optional[List[Role]] = None
|
||||
mixes: Optional[Mix | Dict] = None
|
||||
|
||||
|
||||
class Search(BaseModel):
|
||||
|
||||
class Artists(Items):
|
||||
items: List[Artist]
|
||||
|
||||
class Albums(Items):
|
||||
class SearchAlbum(Album):
|
||||
# TODO: remove the artist field instead of making it None
|
||||
artist: None = None
|
||||
|
||||
items: List[SearchAlbum]
|
||||
|
||||
class Playlists(Items):
|
||||
items: List[Playlist]
|
||||
|
||||
class Tracks(Items):
|
||||
items: List[Track]
|
||||
|
||||
class Videos(Items):
|
||||
items: List[Video]
|
||||
|
||||
class TopHit(BaseModel):
|
||||
value: Union[Artist, Track, Playlist, Album]
|
||||
type: Literal["ARTISTS", "TRACKS", "PLAYLISTS", "ALBUMS"]
|
||||
|
||||
artists: Artists
|
||||
albums: Albums
|
||||
playlists: Playlists
|
||||
tracks: Tracks
|
||||
videos: Videos
|
||||
topHit: TopHit
|
||||
Reference in New Issue
Block a user