I was playing around with the json api today and run into a couple of issues I wanted to share:
Files.PrepareDownload is not working as I expected on the windows platform. (tested with eden rc2/beta3)
When retrieving a list of audio files using (AudioLibrary.GetSongs) the file paths are returned with backslashes in the path, which produces an error message when used as argument in the Files.PrepareDownload call.
Request:
{"jsonrpc": "2.0", "method": "Files.PrepareDownload", "params": { "path":"D:\MP3\123.mp3" }, "id": 1}
Response:
{"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}
Replacing the backslashes with forward slashes the call works.
Request:
{"jsonrpc": "2.0", "method": "Files.PrepareDownload", "params": { "path":"D:/MP3/123.mp3" }, "id": 1}
Response:
{"id":1,"jsonrpc":"2.0","result":{"details":{"path":"vfs/D%3a%2fMP3%2f123%2emp3"},"mode":"redirect","protocol":"http"}}
The returned path (
http://xbmc_ip: port/vfs/D%3a%2fMP3%2f123%2emp3 ) cannot be played by xbmc when it is added to a playlist using a json call like the following:
{"jsonrpc": "2.0", "method": "Playlist.Add", "params" : { "playlistid" : 0 , "item" : { "file" : "%s" } }, "id" : 1 }
If %2e is replaced with a . so that the file ends in .mp3 playback works.