From 53e99d25f5bc09d8a597cb78036efccf5d1c7245 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Fri, 10 Jan 2025 21:05:26 +0100 Subject: [PATCH] refactor PluginSource into its own media item --- music_assistant_models/enums.py | 1 - music_assistant_models/media_items/__init__.py | 15 +++++++++++++-- music_assistant_models/media_items/media_item.py | 12 ++++++++++++ music_assistant_models/player.py | 2 -- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/music_assistant_models/enums.py b/music_assistant_models/enums.py index 36adcc3..70d30b2 100644 --- a/music_assistant_models/enums.py +++ b/music_assistant_models/enums.py @@ -38,7 +38,6 @@ class MediaType(StrEnum, metaclass=MediaTypeMeta): ANNOUNCEMENT = "announcement" FLOW_STREAM = "flow_stream" PLUGIN_SOURCE = "plugin_source" - OTHER = "other" UNKNOWN = "unknown" @classmethod diff --git a/music_assistant_models/media_items/__init__.py b/music_assistant_models/media_items/__init__.py index 7e145a5..f197bea 100644 --- a/music_assistant_models/media_items/__init__.py +++ b/music_assistant_models/media_items/__init__.py @@ -21,6 +21,7 @@ ItemMapping, MediaItem, Playlist, + PluginSource, Podcast, PodcastEpisode, Radio, @@ -47,6 +48,7 @@ "MetadataProviderType", "Playlist", "PlaylistTrack", + "PluginSource", "Podcast", "PodcastEpisode", "ProviderMapping", @@ -56,11 +58,20 @@ ] MediaItemType = ( - Artist | Album | Track | Radio | Playlist | Audiobook | Podcast | PodcastEpisode | BrowseFolder + Artist + | Album + | Track + | Radio + | Playlist + | Audiobook + | Podcast + | PodcastEpisode + | PluginSource + | BrowseFolder ) # directly playable media items -PlayableMediaItemType = Track | Radio | Audiobook | PodcastEpisode +PlayableMediaItemType = Track | Radio | Audiobook | PluginSource | PodcastEpisode @dataclass(kw_only=True) diff --git a/music_assistant_models/media_items/media_item.py b/music_assistant_models/media_items/media_item.py index 310de4b..eaddb5d 100644 --- a/music_assistant_models/media_items/media_item.py +++ b/music_assistant_models/media_items/media_item.py @@ -299,6 +299,18 @@ class PodcastEpisode(MediaItem): media_type: MediaType = MediaType.PODCAST_EPISODE +@dataclass(kw_only=True) +class PluginSource(MediaItem): + """Model for a (generic) playable media source provided by a Plugin.""" + + __hash__ = _MediaItemBase.__hash__ + __eq__ = _MediaItemBase.__eq__ + + duration: int | None = None + + media_type: MediaType = MediaType.PLUGIN_SOURCE + + @dataclass(kw_only=True) class BrowseFolder(MediaItem): """Representation of a Folder used in Browse (which contains media items).""" diff --git a/music_assistant_models/player.py b/music_assistant_models/player.py index 420a740..bc8590c 100644 --- a/music_assistant_models/player.py +++ b/music_assistant_models/player.py @@ -56,8 +56,6 @@ class PlayerSource(DataClassDictMixin): name: str # passive: this source can not be selected/activated by MA/the user passive: bool = False - # metadata is optional and can be used to store additional source data - metadata: PlayerMedia | None = None @dataclass