arcade-mcp/toolkits/spotify/arcade_spotify/tools/models.py
Eric Gustin 6af49ef068
Common changes in all toolkits (#345)
Addresses general improvements to all toolkits including changing ruff
from python 3.9 to python 3.10 which is the reason for the removal of
Optional[] among others.

Also, turns out that our `make install` for toolkits wasn't correctly
checking for whether poetry was installed (&> /dev/null syntax isn't
supported by our check-toolkits GitHub action, so we were installing
poetry twice. I replaced with the more portable >/dev/null 2>&1)

Question: Should we also change ruff to py310 for the `arcade/` package
in a later PR?

-------------------

CU-86b4gzyp6
2025-04-04 09:32:37 -07:00

59 lines
1.7 KiB
Python

from dataclasses import asdict, dataclass, field
from enum import Enum
@dataclass
class PlaybackState:
is_playing: bool | None = None
progress_ms: int | None = (
None # Progress into the currently playing track or episode in milliseconds
)
device_name: str | None = None
device_id: str | None = None
currently_playing_type: str | None = None
album_id: str | None = None
album_name: str | None = None
album_artists: list[str] = field(default_factory=list)
album_spotify_url: str | None = None
track_id: str | None = None
track_name: str | None = None
track_spotify_url: str | None = None
track_artists: list[str] = field(default_factory=list)
track_artists_ids: list[str] = field(default_factory=list)
show_name: str | None = None
show_id: str | None = None
show_spotify_url: str | None = None
episode_name: str | None = None
episode_id: str | None = None
episode_spotify_url: str | None = None
message: str | None = 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"