fix(kodi_rpc): fix Application.SetMute error handling and correct platform booleans and system labels
This commit is contained in:
+1
-1
@@ -12,7 +12,7 @@ services:
|
|||||||
- "8097:8097" # Web Remote & REST API
|
- "8097:8097" # Web Remote & REST API
|
||||||
environment:
|
environment:
|
||||||
- DISPLAY=${DISPLAY:-:0}
|
- 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_HWDEC=${MPV_HWDEC:-auto} # 'auto', 'vaapi', 'nvdec', or 'no'
|
||||||
- MPV_FULLSCREEN=${MPV_FULLSCREEN:-false} # Windowed by default for desktop testing
|
- MPV_FULLSCREEN=${MPV_FULLSCREEN:-false} # Windowed by default for desktop testing
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
@@ -213,8 +213,8 @@ class MpvController:
|
|||||||
|
|
||||||
async def command(self, *args: Any) -> Any:
|
async def command(self, *args: Any) -> Any:
|
||||||
"""Send a command to MPV and wait for response."""
|
"""Send a command to MPV and wait for response."""
|
||||||
if not self._writer:
|
if not self._writer or (self.process and self.process.returncode is not None):
|
||||||
logger.warning("Cannot send command, MPV writer is disconnected")
|
logger.debug("Cannot send command, MPV is disconnected: %s", args)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
self._request_id += 1
|
self._request_id += 1
|
||||||
@@ -224,15 +224,19 @@ class MpvController:
|
|||||||
|
|
||||||
msg = {"command": list(args), "request_id": req_id}
|
msg = {"command": list(args), "request_id": req_id}
|
||||||
payload = (json.dumps(msg) + "\n").encode("utf-8")
|
payload = (json.dumps(msg) + "\n").encode("utf-8")
|
||||||
self._writer.write(payload)
|
|
||||||
await self._writer.drain()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
self._writer.write(payload)
|
||||||
|
await self._writer.drain()
|
||||||
return await asyncio.wait_for(fut, timeout=5.0)
|
return await asyncio.wait_for(fut, timeout=5.0)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
self._pending_requests.pop(req_id, None)
|
self._pending_requests.pop(req_id, None)
|
||||||
logger.warning("MPV command timed out: %s", args)
|
logger.warning("MPV command timed out: %s", args)
|
||||||
return None
|
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(
|
async def play_url(
|
||||||
self,
|
self,
|
||||||
|
|||||||
+14
-2
@@ -266,8 +266,10 @@ class KodiRpcServer:
|
|||||||
booleans = params.get("booleans", [])
|
booleans = params.get("booleans", [])
|
||||||
result = {}
|
result = {}
|
||||||
for b in booleans:
|
for b in booleans:
|
||||||
if b in ("Services.EventServer", "Services.Webserver"):
|
if b in ("System.Platform.Linux", "Services.EventServer", "Services.Webserver"):
|
||||||
result[b] = True
|
result[b] = True
|
||||||
|
elif b.startswith("System.Platform."):
|
||||||
|
result[b] = False
|
||||||
elif b == "System.HasModalDialog":
|
elif b == "System.HasModalDialog":
|
||||||
result[b] = False
|
result[b] = False
|
||||||
else:
|
else:
|
||||||
@@ -276,7 +278,17 @@ class KodiRpcServer:
|
|||||||
|
|
||||||
async def _rpc_xbmc_get_info_labels(self, params: Dict[str, Any]) -> Dict[str, str]:
|
async def _rpc_xbmc_get_info_labels(self, params: Dict[str, Any]) -> Dict[str, str]:
|
||||||
labels = params.get("labels", [])
|
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:
|
async def _rpc_app_set_volume(self, params: Dict[str, Any]) -> int:
|
||||||
vol = params.get("volume", 100)
|
vol = params.get("volume", 100)
|
||||||
|
|||||||
Reference in New Issue
Block a user