![]() |
Working JSON RPC API Examples - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93) +---- Forum: JSON-RPC (https://forum.kodi.tv/forumdisplay.php?fid=174) +---- Thread: Working JSON RPC API Examples (/showthread.php?tid=157996) |
RE: Working JSON RPC API Examples - SDG72 - 2016-09-19 Seem to be stuck and could use some help, I have managed to get many of the JSON example commands from JSON-RPC_API (wiki) and JSON-RPC_API/Examples (wiki) working but have noted that for a more complete user navigation some commands seem to be missing or not documented. I have been able to get the attached list of commands verified working, but number entry 0-9 for example does not seem to be documented anywhere. My goal here is to have a complete set of one way IP navigation commands for a Kodi installation, so I don't have to use a IR remote to control Kodi. And from the attached info you will see that I have many but some key features are still missing. Number entry, TV Guide, TV Channels, and a Fast Forward and Rewind toggle 2x, 4x, 8x, etc. like a RC6 IR remote does would be REALLY nice since it just makes it easier to navigate than individual discrete requests. Sorry for the length of the post. Quote:Transport Commands: RE: Working JSON RPC API Examples - black_eagle - 2016-09-19 Get the available PVR channel groups PHP Code: result=$( curl -s --data-binary '{"jsonrpc": "2.0", "method": "PVR.GetChannelGroups", "params": {"channeltype" : "tv"}, "id": 1 }' -H 'content-type: application/json;' http://$xbmcAddress:$xbmcPort/jsonrpc) Use jq to get the channel group ID for 'All channels'. Note, you can change this for whatever channels tags you have set up. PHP Code: groupid=$(echo $result | jq '.result.channelgroups[] | select(.label=="All channels") | .channelgroupid') Get channel names and numbers for all channels in the group. PHP Code: result=$( curl -s --data-binary '{"jsonrpc": "2.0", "method": "PVR.GetChannels", "params": {"channelgroupid" : '$groupid',"properties":["channel"]}, "id": 1 }' -H 'content-type: application/json;' http://$xbmcAddress:$xbmcPort/jsonrpc) Start channel '$startchan' playing PHP Code: result=$( curl -s --data-binary '{"jsonrpc": "2.0", "method": "Player.Open","params":{"item":{"channelid": '"$startchan"'}}, "id": 1}' -H 'content-type: application/json;' http://$xbmcAddress:$xbmcPort/jsonrpc) RE: Working JSON RPC API Examples - SDG72 - 2016-09-25 (2016-09-19, 20:10)black_eagle Wrote: Get the available PVR channel groups Thanks Black Eagle I'm new to Linux and Kodi and I am having trouble getting these to work! Here is how I have tested the commands I posted above. One was I used Chrome using the "Simple REST Client" option, and was able to get the strings I posted to show a result in a working Kodi machine that was set static and to port 8080. "I sent these in the form in which you see them posted" and got a result. I have also used a program like Putty, called "Hercules" to send just the IP strings portion of the commands I'm testing to a Kodi test machine on a static IP and to port 9090 which from what I have read is an open TCP socket, and this has been one of the easiest options, I can open a TCP socket of an IP on a port of my choosing and hold it open while I send IP test strings without the http://IPaddress/port/ in front. Example: PHP Code: /jsonrpc?request={"jsonrpc":"2.0","method":"AudioLibrary.GetAlbums","params":{"properties":["playcount","artist","genre"],"limits":{"end":10,"start":0},"sort":{"order":"ascending","method":"album","ignorearticle":true}},"id":"libAlbums"} -- get Albums So with that said I tried to test the portions that I'm seeing as the TCP command only, so no "http://ipaddress/port" Example, I cut and pasted this: PHP Code: result=$( curl -s --data-binary '{"jsonrpc": "2.0", "method": "PVR.GetChannels", "params": {"channelgroupid" : '$groupid',"properties":["channel"]}, "id": 1 }' -H 'content-type: application/json;' As stated I'm new to Linux and Kodi and hope you can help walk me through these. I tend to poke and prod until I get things to work if you follow me! Thanks! RE: Working JSON RPC API Examples - alireza44907 - 2016-11-16 Dear All I want to play a folder that is in USB connected to XBMS. I tried all the commands that are posted but none of them work. Can anyone tell me how It can be done? Thanks RE: Working JSON RPC API Examples - alireza44907 - 2016-11-20 Found it: http://192.168.1.7:8080/jsonrpc?request={"jsonrpc":"2.0","id":"1","method":"Player.Open","params":{"item":{"directory":"media/<NAME OF FLASH>/<NAME OF FOLDER>"}}} It must be paid attention that Uppercase and lowercase letters are important RE: Working JSON RPC API Examples - VeggieVampire - 2016-11-26 Found a great way to see what's playing on your device. Code: curl -s --user foo:bar --header 'Content-Type: application/json' --data-binary '{ "jsonrpc": "2.0", "method": "Player.GetItem","params": {"properties": [ "file"],"playerid":1},"id": "VideoGetItem"}' 'http://127.0.0.1:8080/jsonrpc'| python -m json.tool output: Code: { RE: Working JSON RPC API Examples - User 359464 - 2016-12-27 Trying to get the Player.open to play a video by label or title using the example from the first page: Code: //Play a single video from file I have tried the following and neither work: Code: http://192.168.15.117/jsonrpc?request={"jsonrpc":"2.0","id":"1","method":"Player.Open","params":{"item":{"label":"Big Buck Bunny"}}} Code: http://192.168.15.117/jsonrpc?request={"jsonrpc":"2.0","id":"1","method":"Player.Open","params":{"item"{"title":"Big Buck Bunny"}}} If I check the now playing (if the file is playing) with: Code: http://192.168.15.117/{"jsonrpc": "2.0", "method": "Player.GetItem", "params": { "properties": ["title", "album", "artist", "season", "episode", "duration", "showtitle", "tvshowid", "thumbnail", "file", "fanart", "streamdetails"], "playerid": 1 }, "id": "VideoGetItem"} I see the title and label of file":"Media/Big_Buck_Bunny_1080p.mov is "Big Buck Bunny". Is there any way to get Player.Open to work with label or title?[/code] RE: Working JSON RPC API Examples - Happyoldguy - 2017-01-01 Life02 I have the same issue, i want to play based on title or label. I get the error not a valid param. But according to the wiki you should be able to play based on an item in the db as you listed. Is this a bug or am I missing something too? RE: Working JSON RPC API Examples - jonib - 2017-01-02 (2017-01-01, 22:56)Happyoldguy Wrote: I have the same issue, i want to play based on title or label. I get the error not a valid param. But according to the wiki you should be able to play based on an item in the db as you listed. Is this a bug or am I missing something too?As far as I know and the JSON-RPC Wiki you need to provide a path or a video id (movieid or episodeid) to play a video. A title or a label is not a unique identifier so there could be 10 videos with the same name. To be able to use the title do a search to get the id, then use that in the open method. jonib RE: Working JSON RPC API Examples - Happyoldguy - 2017-01-02 (2017-01-02, 01:14)jonib Wrote:(2017-01-01, 22:56)Happyoldguy Wrote: I have the same issue, i want to play based on title or label. I get the error not a valid param. But according to the wiki you should be able to play based on an item in the db as you listed. Is this a bug or am I missing something too?As far as I know and the JSON-RPC Wiki you need to provide a path or a video id (movieid or episodeid) to play a video. A title or a label is not a unique identifier so there could be 10 videos with the same name. Thanks Jonib I do see that in the JSON-RPC Wiki. what about tagging? I'm working on IFTTT with Google assistant and would like to say "Ok Google" I want to watch <movie name>. I'm working on a python script to handle the GET from IFTTT and process the the suggestion you had. Thanks for the input. RE: Working JSON RPC API Examples - jonib - 2017-01-02 (2017-01-02, 04:04)Happyoldguy Wrote: what about tagging?Not sure what you are asking, but VideoLibrary.GetMovies can be used to find a movie based on name and tags (and other meta data) jonib RE: Working JSON RPC API Examples - User 359464 - 2017-01-02 (2017-01-02, 04:04)Happyoldguy Wrote:(2017-01-02, 01:14)jonib Wrote:(2017-01-01, 22:56)Happyoldguy Wrote: I have the same issue, i want to play based on title or label. I get the error not a valid param. But according to the wiki you should be able to play based on an item in the db as you listed. Is this a bug or am I missing something too?As far as I know and the JSON-RPC Wiki you need to provide a path or a video id (movieid or episodeid) to play a video. A title or a label is not a unique identifier so there could be 10 videos with the same name. Happyoldguy, yeah that's exactly what I was trying to do without making an intermediary script for mapping name to id. jonib, Thanks, I'll look into VideoLibrary.GetMovies. RE: Working JSON RPC API Examples - Happyoldguy - 2017-01-03 (2017-01-02, 07:12)life02 Wrote:(2017-01-02, 04:04)Happyoldguy Wrote:(2017-01-02, 01:14)jonib Wrote: As far as I know and the JSON-RPC Wiki you need to provide a path or a video id (movieid or episodeid) to play a video. A title or a label is not a unique identifier so there could be 10 videos with the same name. Ok so last night I dabbled with VideoLibrary.GetMovies and this seems to work to get me the file of the movie by title. Now I need to see how to make this work. If you come up with something please let me know. If I get the solution Ill let you know here. Code: http://192.168.15.117/jsonrpc?request={"jsonrpc": "2.0", "params": {"sort": {"order": "ascending", "method": "title"}, "filter": {"operator": "is", "field": "title", "value": "<movie title here>"}, "properties": ["title", "art", "file"]}, "method": "VideoLibrary.GetMovies", "id": "libMovies"} RE: Working JSON RPC API Examples - Happyoldguy - 2017-01-10 Ok guys, im working with a friend and we now can tell kodi to watch a movie and it will list movies with same title, so men and black men and black 2 men in black 3 and let you select by the id of the movie. It is very alpha and hopefully will release the code and a set up soon. RE: Working JSON RPC API Examples - Happyoldguy - 2017-01-17 Hey guys sorry been under the weather, i will get a git updated soon with instructions. |