Kodi Community Forum

Full Version: Working JSON RPC API Examples
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
I cannot get a file or a playlist (stream) to play using this code

Code:
http://192.168.1.222:88/jsonrpc?request={"jsonrpc":"2.0","id":"1","method":"Player.Open","params":{"item":{"file":"file:///C:/Kodi/file.mp3"}}}

I get a response say
Code:
{"id":"1","jsonrpc":"2.0","result":"OK"}

but the file does not actually play.

This code
Code:
http://192.168.1.222:88/jsonrpc?request={"jsonrpc": "2.0", "method": "Player.PlayPause", "params": { "playerid": 0 }, "id": 1}

Works correctly to pause or unpause something playing, so I think the error is in the finding of the correct file.

It seems like the same issue that Wollk may be getting.
Gentlemen, something very strange is happening with my kodi. I am using the command: {"jsonrpc":"2.0","method":"Input.ExecuteAction","params": {"action": "skipnext"},"id":1}, and instead of going through the chapters of movies and show it passes to the next item on my list of shows or movies. even the show or movie has chapters. someone could help me fix this, use the automation program and can not change the tracks on a DVD for example. if I use teclaod with the up key it goes normal chapter.
(2015-11-02, 04:42)atailo Wrote: [ -> ]Gentlemen, something very strange is happening with my kodi. I am using the command: {"jsonrpc":"2.0","method":"Input.ExecuteAction","params": {"action": "skipnext"},"id":1}, and instead of going through the chapters of movies and show it passes to the next item on my list of shows or movies. even the show or movie has chapters. someone could help me fix this, use the automation program and can not change the tracks on a DVD for example. if I use teclaod with the up key it goes normal chapter.

Em, that is exactly what it should do. I don't think it ever had the intention of going to the next chapter?
(2015-11-02, 04:42)atailo Wrote: [ -> ]Gentlemen, something very strange is happening with my kodi. I am using the command: {"jsonrpc":"2.0","method":"Input.ExecuteAction","params": {"action": "skipnext"},"id":1}, and instead of going through the chapters of movies and show it passes to the next item on my list of shows or movies. even the show or movie has chapters. someone could help me fix this, use the automation program and can not change the tracks on a DVD for example. if I use teclaod with the up key it goes normal chapter.

Have you tried:

ChapterOrBigStepForward Go to to next chapter in video. If no chapters, then step forward 10 minutes in video. (v13 Gotham addition)
ChapterOrBigStepBack Go to previous chapter in video, If no chapters, then step back 10 minutes in video. (v13 Gotham addition)


See:
http://kodi.wiki/view/Action_IDs
ok, He worked, friend, thank you. I used the command {"jsonrpc":"2.0","method":"Input.ExecuteAction","params": {"action": "chapterorbigstepforward"},"id":1}, and it worked
(2015-11-02, 18:55)atailo Wrote: [ -> ]ok, He worked, friend, thank you. I used the command {"jsonrpc":"2.0","method":"Input.ExecuteAction","params": {"action": "chapterorbigstepforward"},"id":1}, and it worked

Great to hear!
I am trying to create a keyboard for irule program json commands to the kodi, but nocmando send text when I send the first texte he does not allow write the second, for instance created text with the letter "a" and the letter "b "but if I hit any of the two he did not add another, only replacing the letter by the other. is there any way to solve?


{"jsonrpc":"2.0","method":"Input.SendText","params": {"text": "A", "done":false},"id":1}
{"jsonrpc":"2.0","method":"Input.SendText","params": {"text": "B", "done":false},"id":1}
(2015-11-03, 23:59)atailo Wrote: [ -> ]I am trying to create a keyboard for irule program json commands to the kodi, but nocmando send text when I send the first texte he does not allow write the second, for instance created text with the letter "a" and the letter "b "but if I hit any of the two he did not add another, only replacing the letter by the other. is there any way to solve?


{"jsonrpc":"2.0","method":"Input.SendText","params": {"text": "A", "done":false},"id":1}
{"jsonrpc":"2.0","method":"Input.SendText","params": {"text": "B", "done":false},"id":1}

I got this to work with irule email me at [email protected]
I'm trying to open a given PVR channel with json and use
Code:
{"jsonrpc": "2.0", "id":"1", "method": "Player.Open","params":{"item":{"channelid":%s}}}
where %s is the placeholder for the movie channel. But the player opens the radio channel with the given number instead. I'm shure there must be an additional parameter (as item is mixed) but I don't found anything...

Ups, found out that the channelid is not the same as the channelnumber used as a property in ListItem.ChannelNumberLabel. So how can I determine from ChannelName (which is unique) to the channelid with JSON RPC?
(2015-11-29, 20:55)_BJ1 Wrote: [ -> ]I'm trying to open a given PVR channel with json and use
Code:
{"jsonrpc": "2.0", "id":"1", "method": "Player.Open","params":{"item":{"channelid":%s}}}
where %s is the placeholder for the movie channel. But the player opens the radio channel with the given number instead. I'm shure there must be an additional parameter (as item is mixed) but I don't found anything...

Ups, found out that the channelid is not the same as the channelnumber used as a property in ListItem.ChannelNumberLabel. So how can I determine from ChannelName (which is unique) to the channelid with JSON RPC?

Use PVR.GetChannels and match "channel" against your channelname
The modeling of the json query is drivin' me nuts, need an example or a code snippet. I tried
Code:
res = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "PVR.GetChannels", "params": {"PVR.ChannelGroup.Id": "1", "properties": ["channel": "%s"]}, "id": "1"}' % channelname)
in various forms (changing channel to ChannelName etc.) but I get everytime
Code:
19:59:19 T:3148   ERROR: JSONRPC: Failed to parse '{"jsonrpc": "2.0", "method": "PVR.GetChannels", "params": {"PVR.ChannelGroup.Id": "1", "properties": ["channel": "VOX"]}, "id": "1"}'
19:59:19 T:3148  NOTICE: [service.kn.switchtimer] {"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}

Painful.
You are mixing too many things Smile And maybe Razze explanation was not very clear Wink

You need to query "PVR.GetChannels" to get the list of channels, find what is your channel in this list with the name then use than channelId in {"jsonrpc": "2.0", "id":"1", "method": "Player.Open","params":{"item":{"channelid":%s}}}

the channelIds are internal to Kodi and not the ids from the backend.

You can use filters to limit the returns of "PVR.GetChannels" there's example out there, but maybe it's out of the scope of your needs.
A good example that needs to be here from http://forum.kodi.tv/showthread.php?tid=251312
that shows the combining logic that filters on both AND and OR in GetAlbums

Code:
{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": { "filter": {"and": [{"or": [{"field": "genre", "operator": "contains", "value": "jazz"}, {"field": "genre", "operator": "contains", "value": "blues"}, {"field": "genre", "operator": "contains", "value": "swing"}]}, {"and":[{"field": "year", "operator": "greaterthan", "value": "1959"}, {"field": "year", "operator": "lessthan", "value": "1970"}]}]},  "properties": ["albumlabel", "artist", "title", "year", "thumbnail"], "sort": { "order": "ascending", "method": "artist", "ignorearticle": true }}, "id": "libAlbums"}

Worth adding that only smart playlist rule type filters (like above) can be combined in this way. The ID filters for artistid or genreid e.g.
Code:
"filter": {"artistid":563}
or
Code:
"filter": {"genreid":6}
can not be combined. Nor can ID filters and rule filters be combined. If you filter with an ID then only one can be applied and nothing else.

This is true in GetAlbums, GetArtists and GetSongs and restricts the JSON filtering permitted compared to the flexibility of the Kodi UI which can, for example, filter songs by both genreid and artistid.
(2016-01-27, 21:03)DaveBlake Wrote: [ -> ]A good example that needs to be here from http://forum.kodi.tv/showthread.php?tid=251312
that shows the combining logic that filters on both AND and OR in GetAlbums

Code:
{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": { "filter": {"and": [{"or": [{"field": "genre", "operator": "contains", "value": "jazz"}, {"field": "genre", "operator": "contains", "value": "blues"}, {"field": "genre", "operator": "contains", "value": "swing"}]}, {"and":[{"field": "year", "operator": "greaterthan", "value": "1959"}, {"field": "year", "operator": "lessthan", "value": "1970"}]}]},  "properties": ["albumlabel", "artist", "title", "year", "thumbnail"], "sort": { "order": "ascending", "method": "artist", "ignorearticle": true }}, "id": "libAlbums"}

Sorry but could not resist Smile

Great example of why genreid / genre is a problem Wink Filtering on scraped genre vs tag / song genre id and displayed genre in Kodi and that can't be combinedSmile (And why combining filters for roleid does not work Wink )
friend made the request via json for data series and part arts I got addresses of images, for example in a series I got the address below, but to put the address in the browser the image does not appear. I would like you guys to help me if you need any supplement.


image://http%3a%2f%2fthetvdb.com%2fbanners%2fposters%2f73762-9.jpg/
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15