{"library":"music-assistant-models","title":"Music Assistant Models","description":"The `music-assistant-models` library provides the core Pydantic V2 data models used across the Music Assistant ecosystem. It defines structured representations for media items (tracks, artists, albums), player states, queues, and other common entities. As of version 1.1.115, it requires Python 3.11+ and Pydantic V2. Releases typically follow the main Music Assistant project's development, with frequent updates to align with new features and data structures.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install music-assistant-models"],"cli":null},"imports":["from music_assistant_models.metadata import Track","from music_assistant_models.metadata import Artist","from music_assistant_models.player import PlayerState","from music_assistant_models.enums import EventType"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from music_assistant_models.metadata import Track, Artist, Album\nfrom music_assistant_models.enums import MediaType\nfrom music_assistant_models.player import PlayerState, RepeatMode\n\n# Example: Create a simple Artist object\nartist = Artist(\n    item_id=\"artist_123\",\n    provider=\"spotify\",\n    name=\"The Example Band\",\n    media_type=MediaType.ARTIST\n)\n\n# Example: Create an Album object\nalbum = Album(\n    item_id=\"album_456\",\n    provider=\"spotify\",\n    name=\"Greatest Hits\",\n    artists=[artist],\n    year=2023,\n    media_type=MediaType.ALBUM\n)\n\n# Example: Create a Track object\ntrack = Track(\n    item_id=\"track_789\",\n    provider=\"spotify\",\n    name=\"Sample Song\",\n    version=\"Original Mix\",\n    duration=240, # seconds\n    artists=[artist],\n    album=album,\n    media_type=MediaType.TRACK\n)\n\nprint(f\"Created Track: {track.name} by {', '.join(a.name for a in track.artists)}\")\nprint(f\"Track duration: {track.duration} seconds from album '{track.album.name}'\")\n\n# Accessing model attributes\nprint(f\"Track media type: {track.media_type.value}\")\n\n# Using other enums\nprint(f\"Current PlayerState options: {list(PlayerState)}\")\nprint(f\"Desired RepeatMode: {RepeatMode.ALL}\")\n\n# To serialize a model to JSON (Pydantic V2 style)\nimport json\nprint(\"\\nSerialized Track (JSON):\")\nprint(json.dumps(track.model_dump(), indent=2))\n","lang":"python","description":"This quickstart demonstrates how to import and instantiate core media item models like `Artist`, `Album`, and `Track`, as well as interacting with common enums. It highlights the use of Pydantic V2 methods for serialization.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}