fix(kodi_rpc): fix Application.SetMute error handling and correct platform booleans and system labels

This commit is contained in:
bart
2026-11-02 22:04:07 +01:00
parent ba5feaf3b2
commit 5de0425b57
3 changed files with 24 additions and 8 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ services:
- "8097:8097" # Web Remote & REST API
environment:
- DISPLAY=${DISPLAY:-:0}
- MPV_VO=${MPV_VO:-gpu} # Change to 'null' for headless test without window
- MPV_VO=${MPV_VO:-null} # 'null' ensures stable background test; set to 'gpu' with xhost for video window
- MPV_HWDEC=${MPV_HWDEC:-auto} # 'auto', 'vaapi', 'nvdec', or 'no'
- MPV_FULLSCREEN=${MPV_FULLSCREEN:-false} # Windowed by default for desktop testing
volumes:
+9 -5
View File
@@ -213,8 +213,8 @@ class MpvController:
async def command(self, *args: Any) -> Any:
"""Send a command to MPV and wait for response."""
if not self._writer:
logger.warning("Cannot send command, MPV writer is disconnected")
if not self._writer or (self.process and self.process.returncode is not None):
logger.debug("Cannot send command, MPV is disconnected: %s", args)
return None
self._request_id += 1
@@ -224,15 +224,19 @@ class MpvController:
msg = {"command": list(args), "request_id": req_id}
payload = (json.dumps(msg) + "\n").encode("utf-8")
self._writer.write(payload)
await self._writer.drain()
try:
self._writer.write(payload)
await self._writer.drain()
return await asyncio.wait_for(fut, timeout=5.0)
except asyncio.TimeoutError:
self._pending_requests.pop(req_id, None)
logger.warning("MPV command timed out: %s", args)
return None
except Exception as e:
self._pending_requests.pop(req_id, None)
logger.warning("MPV command error (%s): %s", args, e)
return None
async def play_url(
self,
+14 -2
View File
@@ -266,8 +266,10 @@ class KodiRpcServer:
booleans = params.get("booleans", [])
result = {}
for b in booleans:
if b in ("Services.EventServer", "Services.Webserver"):
if b in ("System.Platform.Linux", "Services.EventServer", "Services.Webserver"):
result[b] = True
elif b.startswith("System.Platform."):
result[b] = False
elif b == "System.HasModalDialog":
result[b] = False
else:
@@ -276,7 +278,17 @@ class KodiRpcServer:
async def _rpc_xbmc_get_info_labels(self, params: Dict[str, Any]) -> Dict[str, str]:
labels = params.get("labels", [])
return {l: "" for l in labels}
result = {}
for l in labels:
if l == "System.BuildVersion":
result[l] = "19.4 (19.4.0) Git:20220302-e26f2334f3 Media Center Kodi"
elif l == "System.KernelVersion":
result[l] = "Linux 6.8.0"
elif l == "System.FriendlyName":
result[l] = "HTPC"
else:
result[l] = ""
return result
async def _rpc_app_set_volume(self, params: Dict[str, Any]) -> int:
vol = params.get("volume", 100)