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
|
- hans234567 - 2012-03-04 Ok, thanks for your fast reply. Sorry for posting this question again, I will search better next time. - samdret - 2012-03-04 Hello again Disclaimer: I'm using MySQL. (Ninja edit: and XBMC Eden b2) I'm wondering if there's a way to get the current database revision (I think that's what you call it) number from XBMC via JSON RPC? My system would like a way to backup said database. Also, I would love the ability to add sources via JSON RPC to the MySQL database. Or at the very least, directly into the XBMC databases. Previously I just edited sources.xml, but since going over to MySQL, this is no longer possible. Any word on a screenshot feature for JSON RPC? Would it also be a possibility to get a function which returns the appropriate ID (to use with Play) when given a filename? Mark movies/episodes as "Watched" via JSON RPC? - Montellese - 2012-03-04 samdret Wrote:I'm wondering if there's a way to get the current database revision (I think that's what you call it) number from XBMC via JSON RPC? My system would like a way to backup said database.I don't think that this will ever make it into JSON-RPC because it offers zero benefit to a normal client which wants to access the libraries and control playback etc. Furthermore if you want to perform a backup you'll have to access the MySQL database manually anyway so why don't you do that in the first place and use some SQL queries to get the name of your database? samdret Wrote:Also, I would love the ability to add sources via JSON RPC to the MySQL database. Or at the very least, directly into the XBMC databases. Previously I just edited sources.xml, but since going over to MySQL, this is no longer possible.Sources are not stored in the database independant of whether you use MySQL or SQLite, they are still stored in a sources.xml. In the future there will eventually be the functionality to add/edit/remove sources but it's not one of the urgent features. Please create a feature request ticket for it. samdret Wrote:Any word on a screenshot feature for JSON RPC?Not yet. Please create a feature request ticket. samdret Wrote:Would it also be a possibility to get a function which returns the appropriate ID (to use with Play) when given a filename?Why don't you just pass the filename in the "file" property of the "item" parameter of Player.Open or Playlist.Add? Saves you a call to an extra function. samdret Wrote:Mark movies/episodes as "Watched" via JSON RPC?This will be possible with my FooLibrary.SetBarDetails() methods which should be available in the next release. You'll be able to set the "playcount" property to whatever you want. - samdret - 2012-03-04 Montellese Wrote:I don't think that this will ever make it into JSON-RPC because it offers zero benefit to a normal client which wants to access the libraries and control playback etc. Furthermore if you want to perform a backup you'll have to access the MySQL database manually anyway so why don't you do that in the first place and use some SQL queries to get the name of your database? Thanks, I guess that'll have to do Edit: Found that I can just check %AppData%/Roaming/XBMC/userdata/Database/ and see which files are there. I.e. MyVideos18.db and MyVideos58.db which is the same name as the databases XBMC created. Montellese Wrote:Sources are not stored in the database independant of whether you use MySQL or SQLite, they are still stored in a sources.xml. In the future there will eventually be the functionality to add/edit/remove sources but it's not one of the urgent features. I can't believe I missed that. Must've been a brain freeze. Montellese Wrote:Not yet. Please create a feature request ticket. On it! Montellese Wrote:Why don't you just pass the filename in the "file" property of the "item" parameter of Player.Open or Playlist.Add? Saves you a call to an extra function. I believe I've tried this, but when it's done this way, Player.GetItem does not return all the meta data that XBMC has, only marginal information. I'll give this another go and report back. Montellese Wrote:This will be possible with my FooLibrary.SetBarDetails() methods which should be available in the next release. You'll be able to set the "playcount" property to whatever you want. Awesome. By next release, you mean RC3/Final or Eden+1? - Montellese - 2012-03-04 samdret Wrote:I believe I've tried this, but when it's done this way, Player.GetItem does not return all the meta data that XBMC has, only marginal information. I'll give this another go and report back.When you go through JSON-RPC with a file that is in XBMC's databases you should always get all the information available. If the file is not in the database you will only get a limited set of information. There will be some improvement for this in the future but not for Eden. samdret Wrote:Awesome. By next release, you mean RC3/Final or Eden+1?Beta's and RC's are not real releases. With "next release" I refer to Eden+1 i.e. Frodo. - Millencolin007 - 2012-03-04 Hi, I just run into another problem with Files.PrepareDownload I am trying to download the file from the following location on the disk of my xbmc. The filename contains + characters in the filename /media/media/Music/Full Albums/Electro/Bob Sinclar feat. Sean Paul - Disco Crash - 2012/02 - Bob Sinclar feat. Sophie Ellis-Bextor & Gilbere Forte - F++k With You.mp3 As usual requesting the download url Code: curl -d "{\"jsonrpc\": \"2.0\", \"method\": \"Files.PrepareDownload\", \"params\" : { \"path\" : \"/media/media/Music/Full Albums/Electro/Bob Sinclar feat. Sean Paul - Disco Crash - 2012/02 - Bob Sinclar feat. Sophie Ellis-Bextor & Gilbere Forte - F++k With You.mp3\" }, \"id\" : 1 }" http://192.168.1.40:6666/jsonrpc returns the json string with the download path Code: {"id":1,"jsonrpc":"2.0","result":{"details":{"path":"vfs/%2fmedia%2fmedia%2fMusic%2fFull%20Albums%2fElectro%2fBob%20Sinclar%20feat%2e%20Sean%20Paul%20%2d%20Disco%20Crash%20%2d%202012%2f02%20%2d%20Bob%20Sinclar%20feat%2e%20Sophie%20Ellis%2dBextor%20%26%20Gilbere%20Forte%20%2d%20F%2b%2bk%20With%20You%2emp3"},"mode":"redirect","protocol":"http"}} Trying to download the file gives me a file not found exception Code: curl http://192.168.1.40:6666/vfs/%2fmedia%2fmedia%2fMusic%2fFull%20Albums%2fElectro%2fBob%20Sinclar%20feat%2e%20Sean%20Paul%20%2d%20Disco%20Crash%20%2d%202012%2f02%20%2d%20Bob%20Sinclar%20feat%2e%20Sophie%20Ellis%2dBextor%20%26%20Gilbere%20Forte%20%2d%20F%2b%2bk%20With%20You%2emp3 From the xbmc logs I can see that xbmc tried to open the file without a + sign in it. Code: ERROR: WebServer: Failed to open /media/media/Music/Full Albums/Electro/Bob Sinclar feat. Sean Paul - Disco Crash - 2012/02 - Bob Sinclar feat. Sophie Ellis-Bextor & Gilbere Forte - F k With You.mp3 Am I doing something wrong or is this a bug in xbmc? - Montellese - 2012-03-04 The problems is the two "+" you have in your path. XBMC thinks that "+" needs to be replaced with a whitespace when decoding the URL. I'll have to read up in the RFC on URI/URLs on how this is supposed to work. But it looks like XBMC correctly URL encodes the "+" to "%2b" but on decoding it it first decodes "%2b" to "+" and then to a whitespace. - Millencolin007 - 2012-03-04 Montellese Wrote:The problems is the two "+" you have in your path. XBMC thinks that "+" needs to be replaced with a whitespace when decoding the URL. I'll have to read up in the RFC on URI/URLs on how this is supposed to work. But it looks like XBMC correctly URL encodes the "+" to "%2b" but on decoding it it first decodes "%2b" to "+" and then to a whitespace. Yes, that is probably what is happening. I was able to download the file by encoding the %2b a second time to %252b so that the + sign stays after decoding The working download url looks like this Code: http://192.168.1.40:6666/vfs/%2fmedia%2fmedia%2fMusic%2fFull%20Albums%2fElectro%2fBob%20Sinclar%20feat%2e%20Sean%20Paul%20%2d%20Disco%20Crash%20%2d%202012%2f02%20%2d%20Bob%20Sinclar%20feat%2e%20Sophie%20Ellis%2dBextor%20%26%20Gilbere%20Forte%20%2d%20F%252b%252bk%20With%20You%2emp3 - Montellese - 2012-03-04 I have located the problem. It seems that the library we use for our webserver already decodes incoming URLs and then we (i.e. XBMC) decode it again so first the %2b is decoded to + by libmicrohttpd and then to a whitespace by XBMC. I'll see if I can get a fix for that into Eden. - Millencolin007 - 2012-03-04 Montellese Wrote:I have located the problem. It seems that the library we use for our webserver already decodes incoming URLs and then we (i.e. XBMC) decode it again so first the %2b is decoded to + by libmicrohttpd and then to a whitespace by XBMC. I'll see if I can get a fix for that into Eden. Great! Thanks for your help - Montellese - 2012-03-04 Millencolin007 Wrote:Great! Thanks for your help Fixed in https://github.com/xbmc/xbmc/commit/d5b351937a92d1dbc8976145f7a1078c54a087ad and thanks for reporting this. - Millencolin007 - 2012-03-05 Sorry I'ts me once again ;-) I am looking for a way to retrieve music playlists. Since there seems no way to do this through the api I was trying to get the playlists using Files.GetDirectory from special://musicplaylists like below and the parsing the files myself. Unfortunately the returned filetype is always "directory" Request Code: curl -d "{\"jsonrpc\": \"2.0\", \"method\": \"Files.GetDirectory\", \"params\" : { \"directory\" : \"special://musicplaylists\" }, \"id\" : 1 }" http://192.168.1.40:6666/jsonrpc | python -mjson.tool Response Code: { - Montellese - 2012-03-05 Yeah that's intended and correct because to XBMC a smartplaylist is a directory/node containing items (e.g. movies, episodes, albums, songs, ...). So you pass one of those paths to an XSP to Files.GetDirectory and specify the matching "media" parameter ("music" in the above example) and you will get a list of all items contained in that playlist. You can even retrieve all the properties you'd get from AudioLibrary.GetFoo if you specify them in the "properties" parameter. - Millencolin007 - 2012-03-05 Montellese Wrote:Yeah that's intended and correct because to XBMC a smartplaylist is a directory/node containing items (e.g. movies, episodes, albums, songs, ...). So you pass one of those paths to an XSP to Files.GetDirectory and specify the matching "media" parameter ("music" in the above example) and you will get a list of all items contained in that playlist. You can even retrieve all the properties you'd get from AudioLibrary.GetFoo if you specify them in the "properties" parameter. Nice! Thanks a lot. - jimk72 - 2012-03-05 I have noticed when testing xbmc side by side with my program that the thumb for currently playing songs isn't always sent. It's always the same songs. Does xbmc research the net if a thumb is not in the database? It will show the album cover in xbmc but when using json to get the data it returns blank. This is a small percentage of my songs. There are a few others that show the generic music icon in xbmc and nothing is sent as expected. Just figured if xbmc is displaying a image for a song that it would send it. |