• 1
  • 2
  • 3
  • 4(current)
  • 5
  • 6
  • 226
JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC
#46
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}}'
postdata '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"type": "files", "directory": "c:\\"}, "id": "1"}' 

these also give parse errors. do yo9u have an example of Files.GetDirectory, looking thru the source i came up with the above.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#47
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.
Reply
#48
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.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#49
Sorry for the \\ you use phpcode tag i misunderstand Smile

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 Smile

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 Smile

Just use C:/ and it will works Smile
Reply
#50
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 Smile 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 Smile ).

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 Smile. 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
If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

Image

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
Reply
#51
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.
Reply
#52
Tolriq Wrote: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.

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 Smile
If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

Image

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
Reply
#53
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.
Reply
#54
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?
If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

Image

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
Reply
#55
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.
Reply
#56
Tolriq Wrote: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).

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.
If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

Image

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
Reply
#57
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!
Reply
#58
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.
Reply
#59
http api has always been able to do that.
Reply
#60
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.
Reply
  • 1
  • 2
  • 3
  • 4(current)
  • 5
  • 6
  • 226

Logout Mark Read Team Forum Stats Members Help
JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC8