Compare commits

..

No commits in common. "master" and "label_playlist" have entirely different histories.

7 changed files with 18 additions and 118 deletions

View File

@ -2,12 +2,11 @@
Client-agnostic model for marshalling Spotify data types. Client-agnostic model for marshalling Spotify data types.
""" """
from .album import SavedAlbum, SearchAlbum, SimplifiedAlbum from .album import SearchAlbum, SimplifiedAlbum
from .artist import Artist, SimplifiedArtist
from .extra import ReleaseDatePrecision from .extra import ReleaseDatePrecision
from .paging import Cursor, CursorPaging, Paging from .paging import Paging
from .playlist import PlaylistTrack, SimplifiedPlaylist from .playlist import SimplifiedPlaylist
from .track import SavedTrack, SimplifiedTrack, Track from .track import PlaylistTrack, SimplifiedTrack, Track
from .user import PrivateUser, PublicUser from .user import PrivateUser, PublicUser
__all__ = [ __all__ = [
@ -17,8 +16,6 @@ __all__ = [
"PublicUser", "PublicUser",
"ReleaseDatePrecision", "ReleaseDatePrecision",
"SearchAlbum", "SearchAlbum",
"SavedAlbum",
"SavedTrack",
"SimplifiedAlbum", "SimplifiedAlbum",
"SimplifiedPlaylist", "SimplifiedPlaylist",
"SimplifiedTrack", "SimplifiedTrack",

View File

@ -41,14 +41,3 @@ class SimplifiedAlbum(SearchAlbum):
label: str label: str
popularity: int popularity: int
tracks: Paging tracks: Paging
class SavedAlbum(BaseModel):
"""
Album as returned by the Library API
https://developer.spotify.com/documentation/web-api/reference/#object-savedalbumobject
"""
added_at: str
album: SimplifiedAlbum

View File

@ -1,42 +0,0 @@
"""
Objects used for retrieving artist information from Spotify
"""
from typing import Dict, List, Optional
from pydantic import BaseModel, Field
from .extra import Image
class SimplifiedArtist(BaseModel):
"""
https://developer.spotify.com/documentation/web-api/reference/#object-simplifiedartistobject
"""
external_urls: Dict[str, str]
href: str
spotify_id: str = Field(alias="id")
name: str
spotify_type: str = Field(alias="type")
uri: str
class Followers(BaseModel):
"""
https://developer.spotify.com/documentation/web-api/reference/#object-followersobject
"""
href: Optional[str]
total: int
class Artist(SimplifiedArtist):
"""
https://developer.spotify.com/documentation/web-api/reference/#object-artistobject
"""
followers: Followers
genres: List[str]
images: List[Image]
popularity: int

View File

@ -4,8 +4,6 @@ Extra type definitions that don't necessarily belong in other categories.
from enum import Enum from enum import Enum
from pydantic import BaseModel
class ReleaseDatePrecision(Enum): class ReleaseDatePrecision(Enum):
"Release date precision" "Release date precision"
@ -13,13 +11,3 @@ class ReleaseDatePrecision(Enum):
YEAR = "year" YEAR = "year"
MONTH = "month" MONTH = "month"
DAY = "day" DAY = "day"
class Image(BaseModel):
"""
https://developer.spotify.com/documentation/web-api/reference/#object-imageobject
"""
height: int
url: str
width: int

View File

@ -7,27 +7,6 @@ from typing import Any, Dict, List, Optional
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
class Cursor(BaseModel):
"""
https://developer.spotify.com/documentation/web-api/reference/#object-cursorobject
"""
after: Optional[str]
class CursorPaging(BaseModel):
"""
https://developer.spotify.com/documentation/web-api/reference/#object-cursorpagingobject
"""
cursors: Cursor
href: str
items: List[Dict[str, Any]]
limit: int
next_href: Optional[str] = Field(alias="next")
total: int
class Paging(BaseModel): class Paging(BaseModel):
"https://developer.spotify.com/documentation/web-api/reference/#object-pagingobject" "https://developer.spotify.com/documentation/web-api/reference/#object-pagingobject"

View File

@ -1,27 +1,13 @@
""" """
Classes designed to manage playlist Classes designed to manage playlist
""" """
from typing import Any, Dict, List, Optional from typing import Any, Dict, List
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
from .track import SimplifiedTrack
from .user import PublicUser from .user import PublicUser
class PlaylistTrack(BaseModel):
"""
Track entry as returned by the Playlist API
https://developer.spotify.com/documentation/web-api/reference/#object-playlisttrackobject
"""
added_at: str
added_by: PublicUser
is_local: bool
track: Optional[SimplifiedTrack]
class SimplifiedPlaylist(BaseModel): class SimplifiedPlaylist(BaseModel):
""" """
Playlist as returned by the Playlist API Playlist as returned by the Playlist API
@ -30,11 +16,11 @@ class SimplifiedPlaylist(BaseModel):
""" """
collaborative: bool collaborative: bool
description: Optional[str] description: 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")
images: Optional[List[Dict[str, Any]]] images: List[Dict[str, Any]]
name: str name: str
owner: PublicUser owner: PublicUser
snapshot_id: str snapshot_id: str

View File

@ -1,11 +1,13 @@
""" """
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 .album import SearchAlbum
from .user import PublicUser
class SimplifiedTrack(BaseModel): class SimplifiedTrack(BaseModel):
@ -16,7 +18,7 @@ class SimplifiedTrack(BaseModel):
""" """
artists: List[Dict[str, Union[Dict[str, str], str]]] artists: List[Dict[str, Union[Dict[str, str], str]]]
available_markets: Optional[List[str]] available_markets: List[str]
disc_number: int disc_number: int
duration_ms: int duration_ms: int
explicit: bool explicit: bool
@ -25,10 +27,10 @@ class SimplifiedTrack(BaseModel):
spotify_id: str = Field(alias="id") spotify_id: str = Field(alias="id")
is_local: bool is_local: bool
is_playable: Optional[bool] is_playable: Optional[bool]
linked_from: Optional[Union[str, Dict[str, Union[str, Dict[str, str]]]]] linked_from: Optional[str]
name: str name: str
preview_url: Optional[str] preview_url: Optional[str]
restrictions: Optional[Union[str, Dict[str, str]]] restrictions: Optional[str]
track_number: int track_number: int
spotify_type: str = Field(alias="type") spotify_type: str = Field(alias="type")
uri: str uri: str
@ -46,12 +48,13 @@ class Track(SimplifiedTrack):
popularity: int popularity: int
class SavedTrack(BaseModel): class PlaylistTrack(BaseModel):
""" """
Track as returned by the Library API Track as returned from a playlist
https://developer.spotify.com/documentation/web-api/reference/#object-savedtrackobject
""" """
added_at: str added_at: datetime
added_by: PublicUser
is_local: bool
primary_color: Optional[str]
track: Track track: Track