Add radio now-playing metadata polling and readonly props

This commit is contained in:
Jage9
2026-02-25 00:52:28 -05:00
parent 1745915ec3
commit 9eaa330c3e
10 changed files with 220 additions and 3 deletions

View File

@@ -29,6 +29,8 @@ DEFAULT_PARAMS: dict = {
"mediaChannel": "stereo",
"mediaEffect": "off",
"mediaEffectValue": 50,
"stationName": "",
"nowPlaying": "",
"facing": 0,
"emitRange": 10,
}
@@ -39,6 +41,8 @@ PARAM_KEYS: tuple[str, ...] = (
"mediaChannel",
"mediaEffect",
"mediaEffectValue",
"stationName",
"nowPlaying",
"facing",
"emitRange",
)
@@ -61,7 +65,10 @@ PROPERTY_METADATA: dict[str, dict[str, object]] = {
"valueType": "number",
"tooltip": "Amount for the selected effect.",
"range": {"min": 0, "max": 100, "step": 0.1},
"visibleWhen": {"mediaEffect": "!off"},
},
"stationName": {"valueType": "text", "tooltip": "Detected station name from stream metadata."},
"nowPlaying": {"valueType": "text", "tooltip": "Detected current track/title from stream metadata."},
"facing": {
"valueType": "number",
"tooltip": "Facing direction in degrees used for directional emit.",

View File

@@ -59,6 +59,9 @@ def validate_update(item: WorldItem, next_params: dict) -> dict:
if not (0 <= effect_value <= 100):
raise ValueError("mediaEffectValue must be between 0 and 100.")
next_params["mediaEffectValue"] = round(effect_value, 1)
# Read-only metadata fields are server-managed and cannot be client-edited.
next_params["stationName"] = str(item.params.get("stationName", "")).strip()[:160]
next_params["nowPlaying"] = str(item.params.get("nowPlaying", "")).strip()[:200]
try:
facing = float(next_params.get("facing", item.params.get("facing", 0)))