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
|
- bradvido88 - 2011-11-30 Hey, I found some odd behavior in the Files.GetDirectory() call changes between Dharma and Eden. I posted the details here: http://forum.xbmc.org/showthread.php?tid=114921 but now realize this thread might have been a better place to ask - jimk72 - 2011-12-01 Montellese Wrote:It's not really a bug because that's how XBMC works. If it has to create a playlist from multiple files it (by default) creates a video playlist unless there is some specific meta data that can be retrieved that specifies it as a music playlist (which is possible with smart playlists). This logic/implementation is far from perfect and I don't really know why it is done this way but that's how it is. That will work. Thanks!! - el_Paraguayo - 2011-12-01 Montellesse, I'm writing a python script that's trying to catch the "OnStop" notification (by listening on port 9090). While I can search the data for "OnStop", a neater way would be to detect the end of the notification and then parse the full JSON response. However, I'm having difficulty in making the script determine the end of the notification as there doesn't seem to be any break character (maybe this is intentional - i.e. as required by the specification). Do you have any tips for catching the end of the notification? Thanks, el_P - Montellese - 2011-12-01 el_Paraguayo Wrote:Montellesse, You have to count the { and } that you receive from the socket on port 9090. Whenever the number of } matches the number of { you have a whole JSON-RPC notification/response. But ideally you would use some kind of stream-parser because { and } could also appear within strings but this is not the case with any JSON-data generated by XBMC. This problem has been discussed before and other people have requested to add something like a line break (\n) to the end of every notification/response but that's no good solution at all because it makes scripts depend on something that is not part of the specification. The JSON-RPC specification doesn't state anything apart from saying that all data between notifications/responses must be ignored. - othrayte - 2011-12-01 el_Paraguayo Wrote:Montellesse,This has actually come up several times before, the recommended method is to "count the brackets" or in the case of json count the brackets and the quote marks. To simplify there should be an equal number of opening and closing brackets that aren't surrounded with quote marks (e.g. inside a string). In TU we do this by keeping a count, increasing the count on an opening bracket, decreasing it on a closing one and doing nothing in between quotes. One special case to remember to account for is when you start partway through a notification you need to check if your count has become negative, reset the count and assume you are at the start of the next message. The only other case that can cause problems is starting inside a string, and if anyone has any ideas how to detect this it would be most helpful; in general this is unlikely to happen. - el_Paraguayo - 2011-12-01 Thanks both for your quick replies - I'll take a look at TU to get some tips. Sorry for having missed the earlier discussions. - el_Paraguayo - 2011-12-01 Othrayte, Your code works beautifully, I'll adapt slightly for my (less impressive) needs, giving full credit to TU. Thanks so much for pointing me to the code. el_P - topfs2 - 2011-12-01 For streaming parsing check YAJL (or YAJL-py for the python version). it does add some complexity with parsing but such will always be the case with streaming data as the raw TCP is. So with YAJL-Py you would count the object start/ends and when you reach 0 on end you know you have one package. You could do the actual parsing in the SAX handlers or simply store the string you input and do the parsing when you have deduced when the package is finished (the former is the better). For those understanding C++ you can look at our streaming parsers in XBMC, (https://github.com/xbmc/xbmc/blob/master/xbmc/utils/JSONVariantParser.cpp) The fact is that \n checking which some others relied on previously was equally error prone as its as valid to have \n within a json object as } is in strings - el_Paraguayo - 2011-12-02 Is it possible to use Playlist.Add to add more than one item ("file") in a single request? If not, is this because submitting single requests should ensure the correct ordering? - Montellese - 2011-12-02 el_Paraguayo Wrote:Is it possible to use Playlist.Add to add more than one item ("file") in a single request? You can't pass multiple "file" property parameters in one request but you can send multiple requests in one HTTP request. This is called batch requesting and you just put multiple json-rpc request into a json array Code: [ - el_Paraguayo - 2011-12-02 Great. I learn something new every day. Sorry if these are really basic questions for you! Notifications for slideshows - dwagner - 2011-12-04 Is there any notification for when a slideshow or pictures are shown? Having this would be useful as I was prefer not to continually poll the server for when a slideshow or picture are played. Currently I use the Player.OnPlay and Player.OnStop notification to update data on what is currently playing. - Montellese - 2011-12-04 dwagner Wrote:Is there any notification for when a slideshow or pictures are shown? Currently not. The whole slideshow stuff is very badly integrated into XBMC and requires a lot of extra work for it to be available in JSON-RPC at all. - dwagner - 2011-12-04 Montellese Wrote:Currently not. The whole slideshow stuff is very badly integrated into XBMC and requires a lot of extra work for it to be available in JSON-RPC at all. That's quite sad, because I do see that Player.GetActivePlayers correctly retrieves the picture player. I was using the notification system to just get info when it changed, but without getting the picture information the notification system goes out the door for me and I instead have to continually poll to see if pictures are being shown as opposed to videos and music. - dwagner - 2011-12-04 Hi Montellese, One other thing I've noted as I am trying to do my work arounds for pictures. The JSON result for Player.GetItem comes back with correct picture information for file, label and type but it gives me a path to a fanart image that supposedly sits in the Video/Fanart directory. The file does not exist there. Another issue seems to be that if you view a single image, the return has the correct thumbnail, but if you view images in a slideshow the return has no thumbnail set. |