Skip to content

Commit

Permalink
refactor PluginSource into its own media item
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Jan 10, 2025
1 parent d713b29 commit 53e99d2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
1 change: 0 additions & 1 deletion music_assistant_models/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class MediaType(StrEnum, metaclass=MediaTypeMeta):
ANNOUNCEMENT = "announcement"
FLOW_STREAM = "flow_stream"
PLUGIN_SOURCE = "plugin_source"
OTHER = "other"
UNKNOWN = "unknown"

@classmethod
Expand Down
15 changes: 13 additions & 2 deletions music_assistant_models/media_items/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
ItemMapping,
MediaItem,
Playlist,
PluginSource,
Podcast,
PodcastEpisode,
Radio,
Expand All @@ -47,6 +48,7 @@
"MetadataProviderType",
"Playlist",
"PlaylistTrack",
"PluginSource",
"Podcast",
"PodcastEpisode",
"ProviderMapping",
Expand All @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions music_assistant_models/media_items/media_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)."""
Expand Down
2 changes: 0 additions & 2 deletions music_assistant_models/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 53e99d2

Please sign in to comment.