Add more models to get some of the playlists I wanted to create going

This commit is contained in:
Bradlee Speice 2021-09-08 21:26:55 -04:00
parent ea03da8575
commit 1dd79fa4f8
5 changed files with 69 additions and 2 deletions

View File

@ -155,7 +155,8 @@ disable=print-statement,
comprehension-escape,
# Manually added
import-error,
too-few-public-methods
too-few-public-methods,
duplicate-code
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option

View File

@ -5,12 +5,17 @@ Client-agnostic model for marshalling Spotify data types.
from .album import SearchAlbum, SimplifiedAlbum
from .extra import ReleaseDatePrecision
from .paging import Paging
from .playlist import SimplifiedPlaylist
from .track import SimplifiedTrack
from .user import PrivateUser, PublicUser
__all__ = [
"Paging",
"PrivateUser",
"PublicUser",
"ReleaseDatePrecision",
"SearchAlbum",
"SimplifiedAlbum",
"SimplifiedPlaylist",
"SimplifiedTrack",
]

View File

@ -24,7 +24,7 @@ class SearchAlbum(BaseModel):
release_date: str
release_date_precision: ReleaseDatePrecision
total_tracks: int
type_: str = Field(alias="type")
spotify_type: str = Field(alias="type")
uri: str

29
spotify_model/playlist.py Normal file
View File

@ -0,0 +1,29 @@
"""
Classes designed to manage playlist
"""
from typing import Any, Dict, List
from pydantic import BaseModel, Field
from .user import PublicUser
class SimplifiedPlaylist(BaseModel):
"""
Playlist as returned by the Playlist API
https://developer.spotify.com/documentation/web-api/reference/#object-simplifiedplaylistobject
"""
collaborative: bool
description: str
external_urls: Dict[str, str]
href: str
spotify_id: str = Field(alias="id")
images: List[Dict[str, Any]]
name: str
owner: PublicUser
snapshot_id: str
tracks: Dict[str, Any]
spotify_type: str = Field(alias="type")
uri: str

32
spotify_model/user.py Normal file
View File

@ -0,0 +1,32 @@
"""
Classes for managing users
"""
from typing import Any, Dict, List
from pydantic import BaseModel, Field
class PublicUser(BaseModel):
"""
Public information associated with a user
https://developer.spotify.com/documentation/web-api/reference/#object-publicuserobject
"""
display_name: str
external_urls: Dict[str, str]
href: str
spotify_id: str = Field(alias="id")
spotify_type: str = Field(alias="type")
uri: str
class PrivateUser(PublicUser):
"""
Private information associated with a user
https://developer.spotify.com/documentation/web-api/reference/#object-privateuserobject
"""
followers: Dict[str, Any]
images: List[Dict[str, str]]