label_playlist #1

Merged
bspeice merged 2 commits from label_playlist into master 2021-09-10 22:17:09 -04:00
4 changed files with 36 additions and 6 deletions

View File

@ -6,11 +6,12 @@ from .album import SearchAlbum, SimplifiedAlbum
from .extra import ReleaseDatePrecision from .extra import ReleaseDatePrecision
from .paging import Paging from .paging import Paging
from .playlist import SimplifiedPlaylist from .playlist import SimplifiedPlaylist
from .track import SimplifiedTrack from .track import PlaylistTrack, SimplifiedTrack, Track
from .user import PrivateUser, PublicUser from .user import PrivateUser, PublicUser
__all__ = [ __all__ = [
"Paging", "Paging",
"PlaylistTrack",
"PrivateUser", "PrivateUser",
"PublicUser", "PublicUser",
"ReleaseDatePrecision", "ReleaseDatePrecision",
@ -18,4 +19,5 @@ __all__ = [
"SimplifiedAlbum", "SimplifiedAlbum",
"SimplifiedPlaylist", "SimplifiedPlaylist",
"SimplifiedTrack", "SimplifiedTrack",
"Track",
] ]

View File

@ -30,7 +30,7 @@ class SearchAlbum(BaseModel):
class SimplifiedAlbum(SearchAlbum): class SimplifiedAlbum(SearchAlbum):
""" """
Album as returned by the Album API Album as returned by non-album APIs
https://developer.spotify.com/documentation/web-api/reference/#object-simplifiedalbumobject https://developer.spotify.com/documentation/web-api/reference/#object-simplifiedalbumobject
""" """

View File

@ -1,14 +1,18 @@
""" """
Classes designed to manage track-like objects Classes designed to manage track-like objects
""" """
from datetime import datetime
from typing import Dict, List, Optional, Union from typing import Dict, List, Optional, Union
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
from .album import SearchAlbum
from .user import PublicUser
class SimplifiedTrack(BaseModel): class SimplifiedTrack(BaseModel):
""" """
Track as returned by the Tracks API Track as returned by non-track APIs
https://developer.spotify.com/documentation/web-api/reference/#object-simplifiedtrackobject https://developer.spotify.com/documentation/web-api/reference/#object-simplifiedtrackobject
""" """
@ -28,5 +32,29 @@ class SimplifiedTrack(BaseModel):
preview_url: Optional[str] preview_url: Optional[str]
restrictions: Optional[str] restrictions: Optional[str]
track_number: int track_number: int
type_: str = Field(alias="type") spotify_type: str = Field(alias="type")
uri: str uri: str
class Track(SimplifiedTrack):
"""
Track as returned by the Tracks APIs
https://developer.spotify.com/documentation/web-api/reference/#object-trackobject
"""
album: SearchAlbum
external_ids: Dict[str, str]
popularity: int
class PlaylistTrack(BaseModel):
"""
Track as returned from a playlist
"""
added_at: datetime
added_by: PublicUser
is_local: bool
primary_color: Optional[str]
track: Track

View File

@ -1,7 +1,7 @@
""" """
Classes for managing users Classes for managing users
""" """
from typing import Any, Dict, List from typing import Any, Dict, List, Optional
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
@ -13,7 +13,7 @@ class PublicUser(BaseModel):
https://developer.spotify.com/documentation/web-api/reference/#object-publicuserobject https://developer.spotify.com/documentation/web-api/reference/#object-publicuserobject
""" """
display_name: str display_name: Optional[str]
external_urls: Dict[str, str] external_urls: Dict[str, str]
href: str href: str
spotify_id: str = Field(alias="id") spotify_id: str = Field(alias="id")