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
|
- Nuka1195 - 2010-03-21 debug log http://pastebin.com/T7RPQZZX first call success: PHP Code: postdata = '{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "id": "1"}' second call error: PHP Code: postdata = '{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieInfo", "movieid": 11}' you're right json.dumps() is not necessary, i must have formatted the string incorrectly. i haven't played with the File.Download, so it may do it. but i use httpapi's File.Copy. it's very useful for copying to smb:// shares. edit: PHP Code: postdata = '{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieInfo", "params": {"movieid": 11}}' these also give parse errors. do yo9u have an example of Files.GetDirectory, looking thru the source i came up with the above. - Tolriq - 2010-03-21 Request must always have : "jsonrpc": "2.0" "method": "VideoLibrary.GetMovies" "id": 1 (or other number ) Then for params you add the params PHP Code: postdata = '{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieInfo", "params": {"movieid": 11}}' should be PHP Code: postdata = '{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieInfo", "params": {"movieid": 11} , "id" : 1}' But : PHP Code: postdata = '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"type": "files", "directory": "c:\\"}, "id": "1"}' Should work. Since type default to files try without it. And since you use ' for escapsluating postdata you should not double the \ for the directory. - Nuka1195 - 2010-03-21 thanks, but your should be example, i get params error with the "id": 1 the example lists it as "id": "1", which also gives params error the double \\ is a python thing. it's escaping the \ not the ", so it is correct. the log shows it correctly. - Tolriq - 2010-03-21 Sorry for the \\ you use phpcode tag i misunderstand For the id in my .net implementation i use int i works well , and it's int also in the webinterface and the jsonrpc standard too it refer to the query id. Quote:http_request.send("{\"jsonrpc\": \"2.0\", \"method\": \"Files.GetShares\", \"params\": { \"type\": \"music\" }, \"id\": 1}"); Looking at the jsonrpc code : Quote:postdata = '{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieInfo", "params": {"movieid": 11} , "id" : 1}' Can only send back a OK, so the problem seems not be tied to the method but to the way the server receive the full request. Since no param check in the code the simple method : Quote:postdata = '{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieInfo", "id" : 1}'Should work but it don"t In the log i got the request and no error but the return is an error -32602 strange... For the directory it seems that it must be urlencoded from the jsonrpc source. Just try : Quote:const string postData = "{\"jsonrpc\": \"2.0\", \"method\": \"Files.GetDirectory\", \"params\" : { \"type\" : \"files\", \"directory\" : \".\" }, \"id\": 1}";I just test this quickly it works well. For C:\ it should work also with : C%3A\ but it seems not Just use C:/ and it will works - topfs2 - 2010-03-21 The directory shouldn't be urlencoded, atleast not afaik. But yeah the params needs to be inside params. Thats jsonrpc spec, here is documentation regarding it I'll need to fire up windows and try but afaik C:\ should work, sounds weird if it doesn't Does C:\ as a source work? btw, File.Download will not download the file per say, it will just tell you how you should download it depending on your transport, for http it will tell you a useable url with tcp it may open up a new port (like ftp, but its not doing that now but will at some point ). Also for explanation sake, id may be anything so you can use it for your own benefits. EDIT: Although it looks like thats outside json-rpc specification, maybee I should change it . Anyways it cannot be omitted. i.e. this is an ok call Code: { "jsonrpc": "2.0", "method": "foo", "id": { "somekey": [1, 2, 3, 4] } } Cheers Tobias - Tolriq - 2010-03-21 Well C:\ works as a source but not with Files.GetDirectory. (But C:/ works) That makes me try something : http://192.168.10.1:8080/vfs/c:\Windows\win.ini And it works, this really seems not secured at all to allow full drive access from a by default unsecured web access. - topfs2 - 2010-03-22 Tolriq Wrote:Well C:\ works as a source but not with Files.GetDirectory. (But C:/ works) Yeah its not very safe at all, I think I need to limit down this abit. not sure how, perhaps only allow copy from something that is a source, this should make it possible to get from werever but still in a maintained way. Or different permissions, i.e. one client is allowed to read from special:// but not from anything else. its abit can of worms on it, I'm all ears for ideas though - Tolriq - 2010-03-22 Well i must admit that i don't really see the point of allowing outside XBMC data access from the Web Interface. Typical usage can be : Replication of cache Streaming of Music / Video Streaming of trailer (got to check what jsonrpc send back for local trailers) Uploading of files to source Uploading of files to cache for external tools. So yes if you can upload, 3 perms seems enough, default only cache data, source access and full access to upload. - topfs2 - 2010-03-22 Indeed, I think as you say its mostly for downloading music / video. So I guess we could limit it to only download / stream stuff thats in our sources. It could be done via stating you want to access movie A but I wonder if it isn't better if the client states what it want since it may want the rar archive, or the files within the rar. So I think its better to say it can only access whats in the medias sources? Also could have as you say another permission for temporary access, so it can upload / download whatever is in special://temp/ I think we need to allow all clients to read to this since client a may use it to share stuff to client b, could perhaps flag that though. Not sure what you mean with replication of cache? - Tolriq - 2010-03-22 For Cache i'm talking about thumbs / fanart for all remote software. But typically there's the problem of multi profiles (that why i need the getsysinfo to find the logged user). Only access to /temp will perhaps limit functionnality (for access to thumbnails, but also to upload movies or files to target source, my htpc only have a small SSD and i can't upload a 20Go 1080p movie to it so that it after copy it to the good place.) Edit : For uploading thumbs to cache, i think the best way would be to have a dedicated function, passing the file / database id and the file, so xbmc handle hash calc and correct organisation. - topfs2 - 2010-03-22 Tolriq Wrote:For Cache i'm talking about thumbs / fanart for all remote software. Ah, yeah those will ofcourse be accesible, probably not even a special permission, I mean if you can access the library you might aswell be able to access the thumbs. Tolriq Wrote:Only access to /temp will perhaps limit functionnality (for access to thumbnails, but also to upload movies or files to target source, my htpc only have a small SSD and i can't upload a 20Go 1080p movie to it so that it after copy it to the good place.) Hmm, thats true, in that case though It would make sense for you to have access to the full vfs. Perhaps both are needed here really, temp access which we can more or less give all clients and full access which should be considered "unsafe" ? Tolriq Wrote:Edit : For uploading thumbs to cache, i think the best way would be to have a dedicated function, passing the file / database id and the file, so xbmc handle hash calc and correct organisation. Indeed, I think a call were you state update thumb to this URL, so it could be a remote file or a file in the temp after you've uploaded. probably the most futureproof way since then you don't force the client to even upload the file. - grapefrukt - 2010-03-24 I toyed around with the latest nightlies some yesterday and I really like where this is going, it's already way more understandable than the old interface. great work! - Taleteller - 2010-03-24 Hi, I got one feature in mind I always missed in the old http-server. While surfing you often get URIs of audio and video streams. Not talking about YouTube sites, but direct links to webradios, livestreams etc. XBMC is able to play them fine, but you have to create a ".strm" file containing the URI stored somewhere XBMC can find. It would be way easier to have an JSON command causing the given address to be played instantly. We might access it by plain web input fields, or even browser plugins submitting locations on context clicks. - spiff - 2010-03-24 http api has always been able to do that. - Taleteller - 2010-03-24 spiff Wrote:http api has always been able to do that.Interesting, never seen it implemented, and another reason for having it for JSON as well. |