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
|
- Fiasco - 2010-06-27 in no language! Some of us have to communicate with xbmc over a raw tcp port. I will post a working call later today. Would it be possible to have user specified formatting if the output? Say, if user created format file foo doesn't exist output in the default manner? For example, here is what my perl scrip returns for an artist request. STARTDATA###ENDRECORD CLEARARTISTS###ENDRECORD XBMCARTIST###1###(hed) Planet Earth###ENDRECORD XBMCARTIST###7###.38 Special###ENDRECORD XBMCARTIST###5###10,000 Maniacs###ENDRECORD XBMCARTIST###2###3 Doors Down###ENDRECORD XBMCARTIST###3###3-6 Mafia###ENDRECORD XBMCARTIST###9###311###ENDRECORD XBMCARTIST###6###38 Special###ENDRECORD ENDDATA###ENDRECORD topfs2 Wrote:Simple example in what language? its plain jsonrpc and any language has more or less a wrapper for it. - topfs2 - 2010-06-27 Fiasco Wrote:in no language! Read JSONRPC specifications, its nothing weird over a raw tcp port, its just a serialized json following jsonrpc 2.0 spec. The given script even prints the raw jsonrpc dump. I've written raw jsonrpc dumps in lots of posts in this very thread. Fiasco Wrote:Would it be possible to have user specified formatting if the output? Say, if user created format file foo doesn't exist output in the default manner? NO! The whole point of jsonrpc is to stop the user configuration formating nonsense. json is a simple, human readable, standardized serialization of objects. Any programing languages have parsers and generators readily available for you to use. If you need to have a special formating for a closed source product you must create a middleman, its impossible to have configuration to support all and every given products formating. - Fiasco - 2010-06-27 Here is a working call in CommandFusion POST /jsonrpc HTTP/1.1\x0D\x0AContent-Length: 64\x0D\x0AHOST: 192.168.2.202:80\x0D\x0A\x0D\x0A{"jsonrpc": "2.0", "method": "AudioLibrary.GetArtists", "id": 1}\x0D\x0A - Fiasco - 2010-06-27 topfs2 Wrote:NO! The whole point of jsonrpc is to stop the user configuration formating nonsense. json is a simple, human readable, standardized serialization of objects. Any programing languages have parsers and generators readily available for you to use. If you need to have a special formating for a closed source product you must create a middleman, its impossible to have configuration to support all and every given products formating. Can I open up a persistant tcp port connection to the xbmc json server or is it like HTTP with a disconnect after request/response? I'm trying to use the output of json for commandfusion. I am limited to splitting the output on a user selected end of message marker (im using }) and running a regex on each value group to get the info I need. Unfortunately no luxury of wrappers/parsers (beyond line by line regex) - Fiasco - 2010-06-28 Here is the list of commands linked in the first page. Under music library I see MusicLibrary.GetArtists MusicLibrary.GetSongs MusicLibrary.GetAlbums and MusicLibrary.GetSongInfo Would it be possible to add a GetArtistInfo and GetAlbumInfo to retrieve artist biographies and album discographies? - marksoccer - 2010-06-28 Great. Thanks for the example. Now I understand how I am supposed to interface with json rpc. I was able to write some php to get and set the volume. Thanks. - marksoccer - 2010-06-28 Fiasco Wrote:Here is the list of commands linked in the first page. Although I do see MusicLibrary commands in the list of commands on the first page, I do not see them in development.html. Does this mean that the commands are not implemented... or not tested? Is there a way to get the artist of a song from a playlist? - Fiasco - 2010-06-28 marksoccer Wrote:Although I do see MusicLibrary commands in the list of commands on the first page, I do not see them in development.html. Does this mean that the commands are not implemented... or not tested? The page i pulled those commands from must be out of date (it's linked in the first post of this thread) - topfs2 - 2010-06-28 marksoccer Wrote:Although I do see MusicLibrary commands in the list of commands on the first page, I do not see them in development.html. Does this mean that the commands are not implemented... or not tested? Yeah as Fiasco said, they are out of date. Always refer to the Introspect (this is what development.html shows). marksoccer Wrote:Is there a way to get the artist of a song from a playlist? Getting fields is exactly the same throughout the interface by design (no proper docs about that yet though, haven't had time writing it) { "jsonrpc": "2.0", "method": "AudioPlaylist.GetItems", "params": { "fields": ["album", "lyrics", "duration", "rating"], "end": 100 }, "id": 1 } Fiasco Wrote:Here is the list of commands linked in the first page. The GetSongInfo have been removed as its not needed. Similair to how SQL works you have the ability to choose whatever fields you need when calling the GetFoo methods. Again, what parameters they take is discussed quite much in this thread but the idea is that development.html (and introspect) should give you examples (not done for Audio Library though and some others). Example: { "jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": { "fields": ["album", "lyrics", "duration", "rating"], "end": 100 }, "id": 1 } Fiasco Wrote:Can I open up a persistant tcp port connection to the xbmc json server or is it like HTTP with a disconnect after request/response? Sure, the raw TCP port can be kept for as long as you wish, whenever you have sent a proper jsonrpc command xbmc will respond. You can do this for how long as you wish and then disconnect. Fiasco Wrote:I'm trying to use the output of json for commandfusion. I am limited to splitting the output on a user selected end of message marker (im using }) and running a regex on each value group to get the info I need. I have no clue what commandfusion is but if its proprietary you can always create a middleman script that translates to what commandfusion understand, this if far more flexible than transforming what jsonrpc server sends to fit the device (wouldn't be jsonrpc then even). Cheers, Tobias - Fiasco - 2010-06-28 Thanks for your responses I hope I'm not trying your patience. Is the port for raw TCP communication to the JSON server different than the http port specified in XBMC? - Tolriq - 2010-06-28 At this time it's the same since the data is served by the Web Server Most of the time testing and reading gives most answers - Fiasco - 2010-06-28 Tolriq Wrote:At this time it's the same since the data is served by the Web Server So can I write a raw json request to the same port or do I have to wrap it in a HTTP POST? I've read and reread this thread several times. And of course the joy of wireshark - Tolriq - 2010-06-28 Well it's as it's served by HTTP, yes you need to wrap it into HTTP The main difference beetween httpapi and json is that the dataposted and received is formated in a well known and popular format (JSON) that most language have implementations for. - topfs2 - 2010-06-28 Fiasco Wrote:Thanks for your responses I hope I'm not trying your patience. Nah, not trying my patience at all If its early I might have a bit grumpier responses but any unclear fact about jsonrpc is good if it comes out in the open since this will be the base of the documentation and FAQ raw TCP is on another port, 9090 IIRC (should be announced by zeroconf). - Fiasco - 2010-06-29 So you gave this example { "jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": { "fields": ["album", "lyrics", "duration", "rating"], "end": 100 }, "id": 1 } Is the "end" : 100 a limiter (first 100 records?) How would I go about doing this for just one album, something like? { "jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": { "albumid": albumid, "fields": ["album", "lyrics", "duration", "rating"]}, "id": 1 } or pull an artists biography and fanart, something like {"jsonrpc": "2.0", "method": "AudioLibrary.GetArtists", "params": { "artistid": 9, "fields": ["biography", "fanart"] }, "id": 1} http://192.168.2.5:81/jsonrpc http://192.168.2.5:81/jsonrpc |