JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - 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: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC (/showthread.php?tid=68263) Pages:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - A guy - 2012-06-02 Hello. I'm sorry for being total idiot in this. I tried to do the HTTP posting thing, but it just isn't working out. I can understand the JSON syntax more or less, but I fail to pass the command to XBMC. Maybe some of you guys could show me how it's done in html or something for complete new to this thing. I'd really appreciate it. Thank you for your time. Edit: I tested around with REST client on chrome at the data I send works, does what it needs to do. However I just can't get it working with html, then again i don't know if I'm doing things correctly. Currently I'm just trying to post {"jsonrpc": "2.0", "method": "Input.Select", "id": 1} throught html. I'm very bad at improvising RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-06-03 (2012-06-01, 23:32)Archigos Wrote: Once I get back home and start toying with this again, I imagine your example (along with Montellese's comment) something like these would work for the Volume? (I don't want to give exact percentages).Yes that should work. (2012-06-01, 23:32)Archigos Wrote: So, "id": "1" should be at the end of each command... I'm guessing it wouldn't hurt to just leave it there even when I'm done since the script outputs everything to a div which I'm hiding in the released version. Also, I think it was in the post, pages back, but I thought the id specified type, like "id": "1" was for video or is this just another area I misunderstood? (The posts were about adding images not in the library into a slideshow or something like that).The "id" we are talking about here comes from the JSON-RPC 2.0 specification and has nothing to do with XBMC itself. Generally JSON-RPC can't assure that when you send request A and then B that you will first receive the response for request A and then the response for request B. It could be the other way around. So by specifying a "unique" "id" value for every request you can use the "id" value returned in the response to match a request with a response. What most people do is just use an integer value and increment it with every request they make. the "playerid" in XBMC's Player methods are something totaly different and are very XBMC-specific. (2012-06-01, 23:32)Archigos Wrote: I'll remove all the permissions and set the id's. So, something like the following should work for Mute then?Yes that should work. (2012-06-02, 23:36)A guy Wrote: Hello. I'm sorry for being total idiot in this. I tried to do the HTTP posting thing, but it just isn't working out. I can understand the JSON syntax more or less, but I fail to pass the command to XBMC. Maybe some of you guys could show me how it's done in html or something for complete new to this thing. I'd really appreciate it. Thank you for your time.What do you mean by "through html"? If you want to write a webinterface for XBMC (or something similar web-based) you either need to use JavaScript (and send POST requests or use WebSockets (which are not available in Eden)) or you need another programming/scripting language like PHP or Python. RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Archigos - 2012-06-03 (2012-06-02, 23:36)A guy Wrote: Hello. I'm sorry for being total idiot in this. I tried to do the HTTP posting thing, but it just isn't working out. I can understand the JSON syntax more or less, but I fail to pass the command to XBMC. Maybe some of you guys could show me how it's done in html or something for complete new to this thing. I'd really appreciate it. Thank you for your time.I know the feeling, I was in the same boat very recently. It took days but I was able to get it working through a JavaScript I wrote that uses the new Websocket in the Pre-Frodo nightly builds. If you're using a recent version I'm more than willing to share the code... (it sends via PHP, but 'may' be able to be modified easy for straight HTML, however Montellese's comment hints that straight HTML may not work anyway). I'm just curious, are you just doing this for personal internal use or for a project that will be released to the community? The reason I'm asking is if you want to help contribute to the community, maybe we can collaborate a little on the project I'm working on. PM me if you're interested in helping or just need the *.js and *.php file to get it working. (2012-06-03, 11:15)Montellese Wrote:Thanks for the added info... I noticed the commands I had in that post worked after I got home to test, just forgot to post a thank you at that point. Now that I've managed to semi-wrap my head around getting the commands to work the way I want, now I just need to learn how to either handle or format the returned info into something useful for the end users.(2012-06-01, 23:32)Archigos Wrote: Once I get back home and start toying with this again, I imagine your example (along with Montellese's comment) something like these would work for the Volume? (I don't want to give exact percentages).Yes that should work. RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - alicharles - 2012-06-03 Dear Community I have had a pretty good read of these posts and the changes. I am a novice but I spent a bit of time writing a simple text based remote control to run on my Linux desktop, mainly so I didn't have to keep picking my phone up to skip tracks and so I could play internet radio steams et.. These are the commands I used per Eden, which worked well for my basic needs. The http stuff obviously still works but needs to be rewritten when that channel is fully removed, but I am having issues updating my commands for the JSON-RPC API v4 curl -i -X POST -d '{"jsonrpc": "2.0", "method": "AudioLibrary.ScanForContent", "id": "1"}' http://192.168.0.50:8080/jsonrpc ;; curl 'http://192.168.0.50:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn¶meter=XBMC.updatelibrary(video)' ; sleep 5 ;; curl "http://192.168.0.50:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn¶meter=%20PlayerControl%28Partymode%29" ;; curl -i -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlayer.PlayPause", "id": "1"}' http://192.168.0.50:8080/jsonrpc ;; curl -i -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlayer.Stop", "id": "1"}' http://192.168.0.50:8080/jsonrpc ;; curl -i -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlayer.State", "id": 1}' http://192.168.0.50:8080/jsonrpc ; sleep 4;; curl -i -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlayer.SkipNext", "id": 1}' http://192.168.0.50:8080/jsonrpc;; curl "http://192.168.0.50:8080/xbmcCmds/xbmcHttp?command=getcurrentlyplaying" ; sleep 5;; curl "http://192.168.0.50:8080/xbmcCmds/xbmcHttp?command=PlayFile%28smb://192.168.0.50/music/-0AdminTools/Future.m3u%29" ; sleep 4;; I hoped it would be a simple change to the following curl -i -X POST -d '{"jsonrpc":"2.0","method":"Player.PlayPause","params":{"playerid":1}}' http://192.168.0.50:8080/jsonrpc HTTP/1.1 200 OK Content-Length: 0 Content-Type: application/json Date: Sun, 03 Jun 2012 15:13:04 GMT OR curl -i -X POST -d '{"jsonrpc": "2.0", "method": "Player.PlayPause", "params": { "playerid": 1 }, "id": 1}' http://192.168.0.50:8080/jsonrpc HTTP/1.1 200 OK Content-Length: 86 Content-Type: application/json Date: Sun, 03 Jun 2012 15:39:08 GMT {"error":{"code":-32100,"message":"Failed to execute method."},"id":1,"jsonrpc":"2.0"} but neither of these appear to work, yet it also doesn't return any errors and I was really hoping for a pointer in the right direction. XBMC Eden is running in standalone on Ubuntu 10.04 base Many Thanks. RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-06-03 (2012-06-03, 17:46)alicharles Wrote: Dear Community Does your question only concern the Player.PlayPause request or all of the above? If you want to control the audio player you need to pass "playerid" with a value of 0 and not 1. 1 is currently assigned to the video player. If you pass a "playerid" value of a player that is currently not active you will get a "Failed to execute method" error message. (2012-06-03, 17:46)alicharles Wrote: curl -i -X POST -d '{"jsonrpc": "2.0", "method": "AudioLibrary.ScanForContent", "id": "1"}' http://192.168.0.50:8080/jsonrpc ;;AudioLibrary.Scan (2012-06-03, 17:46)alicharles Wrote: curl 'http://192.168.0.50:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn¶meter=XBMC.updatelibrary(video)' ; sleep 5 ;;VideoLibrary.Scan (2012-06-03, 17:46)alicharles Wrote: curl "http://192.168.0.50:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn¶meter=%20PlayerControl%28Partymode%29" ;;There's currently no alternative for this in JSON-RPC (2012-06-03, 17:46)alicharles Wrote: curl -i -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlayer.PlayPause", "id": "1"}' http://192.168.0.50:8080/jsonrpc ;;Player.PlayPause with "playerid" as 0 (2012-06-03, 17:46)alicharles Wrote: curl -i -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlayer.Stop", "id": "1"}' http://192.168.0.50:8080/jsonrpc ;;Player.Stop with "playerid" as 0 (2012-06-03, 17:46)alicharles Wrote: curl -i -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlayer.State", "id": 1}' http://192.168.0.50:8080/jsonrpc ; sleep 4;;Player.GetProperties with "playerid" as 0 and an array of "properties" you are interested in (2012-06-03, 17:46)alicharles Wrote: curl -i -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlayer.SkipNext", "id": 1}' http://192.168.0.50:8080/jsonrpc;;Player.GoNext with "playerid" as 0 (2012-06-03, 17:46)alicharles Wrote: curl "http://192.168.0.50:8080/xbmcCmds/xbmcHttp?command=getcurrentlyplaying" ; sleep 5;;Player.GetItem with "playerid" as 0 and an array of "properties" you are interested in (2012-06-03, 17:46)alicharles Wrote: curl "http://192.168.0.50:8080/xbmcCmds/xbmcHttp?command=PlayFile%28smb://192.168.0.50/music/-0AdminTools/Future.m3u%29" ; sleep 4;;Player.Open with the "item" parameter containing the "file" property set to the file you would like to start playing. RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - _Andy_ - 2012-06-04 Hello In Eden i query the database with a command like: @"{\"jsonrpc\": \"2.0\", \"method\": \"VideoLibrary.GetMovies\", \"params\": {\"properties\": [\"file\",\"year\",\"genre\",\"runtime\",\"fanart\",\"thumbnail\",\"plot\"],\"sort\":{\"method\":\"label\",\"order\":\"ascending\"}},\"id\": 1}"; As fanart and thumbnail i got a link to the special folder in xbmc. So i could download the pictures from my HTPC. For testing purpose i updated to Frodo. No i get a link to imgobject.com. Is this a change? How can i retrieve the old style? RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-06-04 Yes after Eden jmarshall has changed the way XBMC caches images. They are now referenced with an URI of the following schema: Code: image://<url encoded uri from where the image originally came> RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - alicharles - 2012-06-04 Excellent. Thanks Montellese, I was only looking for the help on the mistakes but you have answered them all. Much appreciated. RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - alicharles - 2012-06-04 I have a further query here with the information. When passing the getcurrentlyplaying using http request. I get all the information returned. However when using the Player.GetItem I only every return the song title? Do I have a syntax issue? Even when I request only Artist or Album I still return the title. Examples. Thanks $ curl "http://192.168.0.50:8080/xbmcCmds/xbmcHttp?command=getcurrentlyplaying" <html> <li>Filename:/var/lib/mythtv/music/Masters of Persian Music/Without You/Masters of Persian Music_Without You_09_Zarbi Bayat-e Kord and Tasnif (Del-e Divaneh (Baba Taher)).mp3 <li>PlayStatuslaying <li>SongNo:0 <li>Type:Audio <li>Title:Zarbi Bayat-e Kord and Tasnif (Del-e Divaneh (Baba Taher)) <li>Track:9 <li>Artist:Masters of Persian Music <li>Album:Without You <li>Genre:Reggae <li>Year:2002 <li>URL:/var/lib/mythtv/music/Masters of Persian Music/Without You/Masters of Persian Music_Without You_09_Zarbi Bayat-e Kord and Tasnif (Del-e Divaneh (Baba Taher)).mp3 <li>Lyrics: <li>Bitrate:197 <li>Samplerate:44 <li>ThumbefaultAlbumCover.png <li>Time:01:05 <li>Duration:08:47 <li>Percentage:12 <li>File size:12979705 <li>Changed:True </html> ------- $ curl -i -X POST -d '{"jsonrpc":"2.0","method":"Player.GetItem","params":{"playerid":0},"id": "0"} "properties":["Title", "Artist", "Album"]}' http://192.168.0.50:8080/jsonrpc HTTP/1.1 200 OK Content-Length: 100 Content-Type: application/json Date: Mon, 04 Jun 2012 19:54:21 GMT {"id":"0","jsonrpc":"2.0","result":{"item":{"id":35680,"label":"Positivity (Remix)","type":"song"}}} ------- $ curl -i -X POST -d '{"jsonrpc":"2.0","method":"Player.GetItem","params":{"playerid":0},"id": "0"} "properties":["Artist"]}' http://192.168.0.50:8080/jsonrpc HTTP/1.1 200 OK Content-Length: 100 Content-Type: application/json Date: Mon, 04 Jun 2012 19:55:14 GMT {"id":"0","jsonrpc":"2.0","result":{"item":{"id":35680,"label":"Positivity (Remix)","type":"song"}}}ali@ali-laptop:~$ RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - alicharles - 2012-06-04 Issue solved with a slight change curl -i -X POST -d '{ "jsonrpc": "2.0", "method": "Player.GetItem", "params": { "playerid": 0, "properties": ["title","artist"] }, "id": 0 }' http://192.168.0.50:8080/jsonrpc RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-06-07 (2012-05-22, 10:27)Millencolin007 Wrote: With this change I loose my current way to distinguish if playback was stopped automatically or through user interaction. Any chance this info can be added back to the notification using an additional parameter or by sending a different notification if playback was stopped automatically or through user interaction? I have just committed a change that adds an "end" parameter to the Player.OnStop notification. If it's value is true the player has reached the end of the playable item(s). If it's false the player was (manually) stopped before having finished playback. Hope that's good enough for your purposes. RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-06-07 (2012-05-27, 16:15)Mizaki Wrote: There seems to be a problem with adding directories that are not in the library: Sorry for not answering earlier but there was also a bug report on trac about this a few days ago and I fixed it. Can you check if it works again for you in latest master? Thanks. RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Millencolin007 - 2012-06-07 (2012-06-07, 13:42)Montellese Wrote:(2012-05-22, 10:27)Millencolin007 Wrote: With this change I loose my current way to distinguish if playback was stopped automatically or through user interaction. Any chance this info can be added back to the notification using an additional parameter or by sending a different notification if playback was stopped automatically or through user interaction? Thanks, exactly what I needed. RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Mizaki - 2012-06-07 (2012-06-07, 13:44)Montellese Wrote:(2012-05-27, 16:15)Mizaki Wrote: There seems to be a problem with adding directories that are not in the library: No problem. I saw it and tried it yesterday. Seems to have fixed it. Thanks. RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - rickles - 2012-06-08 Hi, I have spent way too much time trying to figure this out so I hope someone can help me. I am using curl to remotely export my video library from the terminal: Code: curl --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.Export", "id": "mybash"}' -H 'content-type: application/json;' http://htpc:8080/jsonrpc I want to include the "images": "true" option so that my fanart and thumbnails are exported too. Can someone show me how to add it to the above command? Thanks very much. |