Allow Access to ListItem Properties via JSON-RPC
#16
perhaps @Montellese can confirm whether or not "additionalProperties" would be the correct way to retrieve the value of custom ListItem properties.

after a bit of hacking around in the source-code, this seems to be working (but i have no idea whether it's even remotely valid to implement it like this):

diff:
diff --git a/xbmc/interfaces/json-rpc/FileItemHandler.cpp b/xbmc/interfaces/json-rpc/FileItemHandler.cpp
index badf8a97d0..f79c4a9e1f 100644
--- a/xbmc/interfaces/json-rpc/FileItemHandler.cpp
+++ b/xbmc/interfaces/json-rpc/FileItemHandler.cpp
@@ -233,6 +233,12 @@ void CFileItemHandler::HandleFileItemList(const char *ID, bool allowFile, const
       fields.insert(field->asString());
   }
 
+  if (parameterObject.isMember("additionalProperties") && parameterObject["additionalProperties"].isArray())
+  {
+    for (CVariant::const_iterator_array field = parameterObject["additionalProperties"].begin_array(); field != parameterObject["additionalProperties"].end_array(); field++)
+      fields.insert(field->asString());
+  }
+
   result[resultname].reserve(static_cast<size_t>(end - start));
   for (int i = start; i < end; i++)
   {
diff --git a/xbmc/interfaces/json-rpc/schema/methods.json b/xbmc/interfaces/json-rpc/schema/methods.json
index 856dda7490..8edb404551 100644
--- a/xbmc/interfaces/json-rpc/schema/methods.json
+++ b/xbmc/interfaces/json-rpc/schema/methods.json
@@ -640,6 +640,7 @@
       { "name": "directory", "type": "string", "required": true },
       { "name": "media", "$ref": "Files.Media", "default": "files" },
       { "name": "properties", "$ref": "List.Fields.Files" },
+      { "name": "additionalProperties", "type": "array", "items": { "type": "string" } },
       { "name": "sort", "$ref": "List.Sort" },
       { "name": "limits", "$ref": "List.Limits", "description": "Limits are applied after getting the directory content thus retrieval is not faster when they are applied." }
     ],


json example:
json:
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory": "plugin://plugin.test/", "media":"video", "properties":["genre", "director"], "additionalProperties":["foo", "bar"]}, "id": 1}')
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply


Messages In This Thread
RE: Allow Access to ListItem Properties via JSON-RPC - by ronie - 2020-06-24, 00:42
Logout Mark Read Team Forum Stats Members Help
Allow Access to ListItem Properties via JSON-RPC0