Add new items into JSON result
#1
Hello,

I wanted to add support for 3-rd party plugin from my own plugin.
I would like not to edit the plugin I want to add support too.

That plugin is asking this JSON query:

{'jsonrpc': '2.0', 'method': 'Player.GetItem', 'params': {'playerid': 1}, 'id': 1}

The result I get is:

{"id":1,"jsonrpc":"2.0","result":{"item":{"label":"You`re Myself, I`m Yourself","type":"episode"}}}

The file that is played is not in database but it invoke from mine plugin.
I would like to add item 'id' to the 'item' dictionary so the 3-rd party plugin can read it from there.
Is it possible to write that information there ?

I already tried ListItem and set property of 'id' there but that dont work
Reply
#2
if i understand you correctly, you want to add a new key to a dict?
Code:
response = {"id":1,"jsonrpc":"2.0","result":{"item":{"label":"You`re Myself, I`m Yourself","type":"episode"}}}
response['result']['item']['id'] = 123
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
#3
More like, I want to add item (old one) in middle so when :

{'jsonrpc': '2.0', 'method': 'Player.GetItem', 'params': {'playerid': 1}, 'id': 1}

run, It will have produce:

{"id":1,"jsonrpc":"2.0","result":{"item":{"label":"You`re Myself, I`m Yourself","type":"episode"}}}

But I want to have this:

{"id":1,"jsonrpc":"2.0","result":{"item":{"label":"You`re Myself, I`m Yourself","type":"episode", "id": "added_in_middle"}}}


But I cannot edit code of 3rd party plugin, so I cannot:
response['result']['item']['id'] = 123

I understand that jsonrpc query ask kodi about things from it library ? but I dont use one, but wanted to "add" those properties before read.
Reply
#4
I'm obviously missing something here. If you can get the JSON response, why can't you edit the response in your code?
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#5
i'm not sure what you mean with "id"?
you said the item is not in the database, so it doesn't have a library id.

if you're looking to get the path of the playing item, try:
{'jsonrpc': '2.0', 'method': 'Player.GetItem', 'params': {'playerid': 1, 'properties': ['file']}, 'id': 1}

Player.GetItem docs:
http://kodi.wiki/view/JSON-RPC_API/v6#Player.GetItem

properties you can retrieve:
http://kodi.wiki/view/JSON-RPC_API/v6#List.Fields.All
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
#6
(2016-01-19, 12:45)el_Paraguayo Wrote: I'm obviously missing something here. If you can get the JSON response, why can't you edit the response in your code?
Its like this: mine plugin read files and metadata from mysql that is not linked with kodi,
the other NOT MINE PLUGIN work this way:
send rpc:
{'jsonrpc': '2.0', 'method': 'Player.GetItem', 'params': {'playerid': 1}, 'id': 1}
Then get 'id' from the result, do something with it (inside that plugin)
I want to add support for that PLUGIN inside mine plugin and I dont want to patch the NOT MINE PLUGIN.. I want to inject that "ID" parameter to Kodi before RPC ask for it.

(2016-01-19, 19:22)ronie Wrote: i'm not sure what you mean with "id"?
you said the item is not in the database, so it doesn't have a library id.

if you're looking to get the path of the playing item, try:
{'jsonrpc': '2.0', 'method': 'Player.GetItem', 'params': {'playerid': 1, 'properties': ['file']}, 'id': 1}

Player.GetItem docs:
http://kodi.wiki/view/JSON-RPC_API/v6#Player.GetItem

properties you can retrieve:
http://kodi.wiki/view/JSON-RPC_API/v6#List.Fields.All


I want to INJECT that 'id' to Kodi before RPC ask for it.
I was thinking that:
{'jsonrpc': '2.0', 'method': 'Player.GetItem', 'params': {'playerid': 1}, 'id': 1}
Just read ListItem of current played item, but that didnt work.
By debuging Kodi with Advance Setting I see that the jsonrpc execute sql query on Kodi side, and I want to Inject more info in that query result.
Reply
#7
Ok - Is it the case that your plugin will play some media and you want the other plugin to be able to retrieve the relevant information about the now playing item?

Like Ronie, I don't follow what the "ID" value you're looking to pass is. If your item is not in the Kodi library database then any ID is likely to be meaningless. The ID in that request is just to identify requests and has no bearing on the data received (other than the response will include the same ID).

Can you explain more about what your ID represents and how you want to use it?
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#8
ID is probably library mysql ID of episode inside it - which I dont need.
But being able to spoof that ID, the script will move ahead insted of throwing that there is no ID = No Library File
being able to Spoof this 'ID' i can also spoof next querys which ask about other infos with that ID.
Reply

Logout Mark Read Team Forum Stats Members Help
Add new items into JSON result0