arcade-mcp/toolkits/spotify/arcade_spotify/tools/models.py
Eric Gustin ab889f9f1d
Lint all toolkits (#183)
# PR Description
* Adds/updates the following files to all toolkits:
    - `.pre-commit-config.yaml`
    - `.ruff.toml`
    - `LICENSE`
    - `Makefile`
    - `pyproject.toml`
* Lint all toolkits such that they pass `make check` and `make test` (a
total doozy). This includes adding some unit tests and evals.
* Github workflow for testing toolkits before merge into main (courtesy
of @sdreyer)
* Added a QOL improvement for tool developers for when they need to get
the context's auth token.
* Minor updates to `arcade new` template.
2024-12-20 09:49:45 -08:00

60 lines
1.8 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_spotify_url: Optional[str] = None
track_artists: list[str] = field(default_factory=list)
track_artists_ids: list[str] = field(default_factory=list)
show_name: Optional[str] = None
show_id: Optional[str] = None
show_spotify_url: Optional[str] = None
episode_name: Optional[str] = None
episode_id: 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"