feat(kodi_rpc): implement Settings.GetSettingValue, Settings.SetSettingValue, and library stubs
This commit is contained in:
+38
-1
@@ -189,7 +189,7 @@ class KodiRpcServer:
|
||||
method = req.get("method", "")
|
||||
params = req.get("params", {})
|
||||
|
||||
logger.debug("Kodi JSON-RPC method called: %s (id=%s)", method, req_id)
|
||||
logger.info("Kodi JSON-RPC method called: %s (params=%s, id=%s)", method, params, req_id)
|
||||
|
||||
try:
|
||||
handler = self._methods.get(method)
|
||||
@@ -432,6 +432,37 @@ class KodiRpcServer:
|
||||
await self.player.stop()
|
||||
return "OK"
|
||||
|
||||
async def _rpc_settings_get_setting_value(self, params: Dict[str, Any]) -> Dict[str, Any]:
|
||||
setting = params.get("setting", "").lower()
|
||||
if "port" in setting:
|
||||
val = 9777 if "es" in setting else 8080
|
||||
elif any(k in setting for k in ("enabled", "eventserver", "webserver", "interface", "upnp", "zeroconf")):
|
||||
val = True
|
||||
else:
|
||||
val = True
|
||||
return {"value": val}
|
||||
|
||||
async def _rpc_settings_set_setting_value(self, params: Dict[str, Any]) -> bool:
|
||||
return True
|
||||
|
||||
async def _rpc_settings_get_settings(self, params: Dict[str, Any]) -> Dict[str, Any]:
|
||||
return {
|
||||
"settings": [
|
||||
{"id": "services.eventserver", "value": True},
|
||||
{"id": "services.esenabled", "value": True},
|
||||
{"id": "services.esport", "value": 9777},
|
||||
{"id": "services.esallinterfaces", "value": True},
|
||||
{"id": "services.webserver", "value": True},
|
||||
{"id": "services.webserverport", "value": 8080},
|
||||
]
|
||||
}
|
||||
|
||||
async def _rpc_playlist_get_playlists(self, params: Any) -> List[Dict[str, Any]]:
|
||||
return [{"playlistid": 0, "type": "audio"}, {"playlistid": 1, "type": "video"}]
|
||||
|
||||
async def _rpc_files_get_sources(self, params: Any) -> Dict[str, Any]:
|
||||
return {"sources": [], "limits": {"start": 0, "total": 0, "end": 0}}
|
||||
|
||||
_methods = {
|
||||
"JSONRPC.Ping": _rpc_ping,
|
||||
"JSONRPC.Version": _rpc_version,
|
||||
@@ -442,6 +473,9 @@ class KodiRpcServer:
|
||||
"Application.SetMute": _rpc_app_set_mute,
|
||||
"GUI.GetProperties": _rpc_gui_get_properties,
|
||||
"System.GetProperties": _rpc_system_get_properties,
|
||||
"Settings.GetSettingValue": _rpc_settings_get_setting_value,
|
||||
"Settings.SetSettingValue": _rpc_settings_set_setting_value,
|
||||
"Settings.GetSettings": _rpc_settings_get_settings,
|
||||
"XBMC.GetInfoBooleans": _rpc_xbmc_get_info_booleans,
|
||||
"XBMC.GetInfoLabels": _rpc_xbmc_get_info_labels,
|
||||
"Player.GetActivePlayers": _rpc_player_get_active_players,
|
||||
@@ -453,6 +487,8 @@ class KodiRpcServer:
|
||||
"Player.Open": _rpc_player_open,
|
||||
"Playlist.Add": _rpc_playlist_add,
|
||||
"Playlist.GetItems": _rpc_playlist_get_items,
|
||||
"Playlist.GetPlaylists": _rpc_playlist_get_playlists,
|
||||
"Files.GetSources": _rpc_files_get_sources,
|
||||
"GUI.ShowNotification": _rpc_gui_show_notification,
|
||||
"Input.Back": _rpc_input_back,
|
||||
"Input.Home": _rpc_input_ok,
|
||||
@@ -466,6 +502,7 @@ class KodiRpcServer:
|
||||
"Input.ShowOSD": _rpc_input_ok,
|
||||
}
|
||||
|
||||
|
||||
async def start(self) -> None:
|
||||
if not self.config.enabled:
|
||||
logger.info("Kodi RPC emulation server is disabled in config")
|
||||
|
||||
Reference in New Issue
Block a user