From 5de0425b5731982c73ef6942da04c81a71e36529 Mon Sep 17 00:00:00 2001 From: bart Date: Mon, 2 Nov 2026 22:04:07 +0100 Subject: [PATCH] fix(kodi_rpc): fix Application.SetMute error handling and correct platform booleans and system labels --- docker-compose.yml | 2 +- src/player/mpv_controller.py | 14 +++++++++----- src/remotes/kodi_rpc.py | 16 ++++++++++++++-- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 36f86e3..e405323 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: diff --git a/src/player/mpv_controller.py b/src/player/mpv_controller.py index 3f9d9af..282d25e 100644 --- a/src/player/mpv_controller.py +++ b/src/player/mpv_controller.py @@ -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, diff --git a/src/remotes/kodi_rpc.py b/src/remotes/kodi_rpc.py index 58510aa..b81ddfd 100644 --- a/src/remotes/kodi_rpc.py +++ b/src/remotes/kodi_rpc.py @@ -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)