Skip to content

Commit

Permalink
tweak config entries
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Feb 4, 2025
1 parent 693dbb5 commit 95dc0b8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
29 changes: 18 additions & 11 deletions music_assistant/providers/filesystem_local/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
import shortuuid
import xmltodict
from aiofiles.os import wrap
from music_assistant_models.config_entries import ConfigEntry, ConfigValueType
from music_assistant_models.enums import (
ConfigEntryType,
ContentType,
ExternalID,
ImageType,
Expand Down Expand Up @@ -69,7 +67,9 @@
from .constants import (
AUDIOBOOK_EXTENSIONS,
CONF_ENTRY_CONTENT_TYPE,
CONF_ENTRY_CONTENT_TYPE_READ_ONLY,
CONF_ENTRY_MISSING_ALBUM_ARTIST,
CONF_ENTRY_PATH,
CONF_MISSING_ALBUM_ARTIST_ACTION,
IMAGE_EXTENSIONS,
PLAYLIST_EXTENSIONS,
Expand All @@ -89,7 +89,7 @@
)

if TYPE_CHECKING:
from music_assistant_models.config_entries import ProviderConfig
from music_assistant_models.config_entries import ConfigEntry, ConfigValueType, ProviderConfig
from music_assistant_models.provider import ProviderManifest

from music_assistant.mass import MusicAssistant
Expand Down Expand Up @@ -132,15 +132,22 @@ async def get_config_entries(
values: the (intermediate) raw values for config entries sent with the action.
"""
# ruff: noqa: ARG001
if instance_id is None or values is None:
return (
CONF_ENTRY_CONTENT_TYPE,
CONF_ENTRY_PATH,
CONF_ENTRY_MISSING_ALBUM_ARTIST,
)
media_type = values.get(CONF_ENTRY_CONTENT_TYPE.key)
if media_type == "music":
return (
CONF_ENTRY_PATH,
CONF_ENTRY_CONTENT_TYPE_READ_ONLY,
CONF_ENTRY_MISSING_ALBUM_ARTIST,
)
return (
ConfigEntry(
key="path",
type=ConfigEntryType.STRING,
label="Path",
default_value="/media",
),
CONF_ENTRY_CONTENT_TYPE,
CONF_ENTRY_MISSING_ALBUM_ARTIST,
CONF_ENTRY_PATH,
CONF_ENTRY_CONTENT_TYPE_READ_ONLY,
)


Expand Down
18 changes: 18 additions & 0 deletions music_assistant/providers/filesystem_local/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
depends_on_value="music",
)


CONF_ENTRY_PATH = ConfigEntry(
key="path",
type=ConfigEntryType.STRING,
label="Path",
default_value="/media",
)

CONF_ENTRY_CONTENT_TYPE = ConfigEntry(
key=CONF_CONTENT_TYPE,
type=ConfigEntryType.STRING,
Expand All @@ -37,6 +45,16 @@
ConfigValueOption("Podcasts", "podcasts"),
),
)
CONF_ENTRY_CONTENT_TYPE_READ_ONLY = ConfigEntry(
key=CONF_CONTENT_TYPE,
type=ConfigEntryType.STRING,
label=CONF_ENTRY_CONTENT_TYPE.label,
default_value="blah",
required=False,
depends_on=CONF_ENTRY_PATH.key,
depends_on_value="thisdoesnotexist",
)


TRACK_EXTENSIONS = {
"aac",
Expand Down

0 comments on commit 95dc0b8

Please sign in to comment.