arcade-mcp/toolkits/spotify/arcade_spotify/tools/models.py
Eric Gustin efee9589fa
More Spotify Tools (#140)
# PR Description
This PR adds three new spotify tools that are natural language friendly.

1. `search` - Search Spotify Catalog information
2. `play_artist_by_name` - Gets 5 songs by the specified artist and
plays them. Uses `search`, and `start_tracks_playback_by_id` under the
hood
3. `play_track_by_name` - Plays the specified song, optionally provide
the artist name who plays the song. Uses `search`, and
`start_tracks_playback_by_id` under the hood
2024-11-01 13:15:43 -07:00

56 lines
1.6 KiB
Python

from dataclasses import asdict, dataclass, field
from enum import Enum
from typing import Optional
@dataclass
class PlaybackState:
is_playing: Optional[bool] = None
progress_ms: Optional[int] = (
None # Progress into the currently playing track or episode in milliseconds
)
device_name: Optional[str] = None
device_id: Optional[str] = None
currently_playing_type: Optional[str] = None
album_id: Optional[str] = None
album_name: Optional[str] = None
album_artists: list[str] = field(default_factory=list)
album_spotify_url: Optional[str] = None
track_id: Optional[str] = None
track_name: Optional[str] = None
track_artists: list[str] = field(default_factory=list)
show_id: Optional[str] = None
show_spotify_url: Optional[str] = None
episode_name: Optional[str] = None
episode_spotify_url: Optional[str] = None
message: Optional[str] = None
def to_dict(self) -> dict:
"""Convert the PlaybackState instance to a dictionary, excluding None values."""
return {k: v for k, v in asdict(self).items() if v is not None and v != []}
@dataclass
class Device:
id: str
is_active: bool
is_private_session: bool
is_restricted: bool
name: str
type: str
volume_percent: int
supports_volume: bool
def to_dict(self) -> dict:
"""Convert the Device instance to a dictionary."""
return asdict(self)
class SearchType(str, Enum):
ALBUM = "album"
ARTIST = "artist"
PLAYLIST = "playlist"
TRACK = "track"
SHOW = "show"
EPISODE = "episode"
AUDIOBOOK = "audiobook"