Merge pull request 'label_playlist' (#1) from label_playlist into master

This commit is contained in:
bspeice 2021-09-11 02:17:07 +00:00
commit 49ae593c45
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 .paging import Paging
from .playlist import SimplifiedPlaylist
from .track import SimplifiedTrack
from .track import PlaylistTrack, SimplifiedTrack, Track
from .user import PrivateUser, PublicUser
__all__ = [
"Paging",
"PlaylistTrack",
"PrivateUser",
"PublicUser",
"ReleaseDatePrecision",
@ -18,4 +19,5 @@ __all__ = [
"SimplifiedAlbum",
"SimplifiedPlaylist",
"SimplifiedTrack",
"Track",
]

View File

@ -30,7 +30,7 @@ class SearchAlbum(BaseModel):
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
"""

View File

@ -1,14 +1,18 @@
"""
Classes designed to manage track-like objects
"""
from datetime import datetime
from typing import Dict, List, Optional, Union
from pydantic import BaseModel, Field
from .album import SearchAlbum
from .user import PublicUser
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
"""
@ -28,5 +32,29 @@ class SimplifiedTrack(BaseModel):
preview_url: Optional[str]
restrictions: Optional[str]
track_number: int
type_: str = Field(alias="type")
spotify_type: str = Field(alias="type")
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
"""
from typing import Any, Dict, List
from typing import Any, Dict, List, Optional
from pydantic import BaseModel, Field
@ -13,7 +13,7 @@ class PublicUser(BaseModel):
https://developer.spotify.com/documentation/web-api/reference/#object-publicuserobject
"""
display_name: str
display_name: Optional[str]
external_urls: Dict[str, str]
href: str
spotify_id: str = Field(alias="id")