Kodi Community Forum
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)



RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - dwagner - 2012-08-12

(2012-08-10, 09:20)Montellese Wrote:
(2012-08-10, 00:56)dwagner Wrote: The problem is with the OSX build. I tried the latest OSX and Windows builds. The OSX build crashed on JSONRPC.Introspect and the Windows build did not. There are other JSON commands that crash for me on OSX. I read an earlier post where you mentioned you are going to try and test on OSX, so I guess it will be sorted once you get a chance to do that.

Do these crashes happen over HTTP or over TCP or over both? Would be important to know whether the crashes are transport-dependent or transport-agnostic (you can also try websockets if you want). If the crashes happen on all transports it's a problem with JSON-RPC or the JSON reader/writer. Otherwise it's a problem with the transport itself.

Originally I tested over HTTP using Simple Rest Client in Chrome. I did a quick test now over TCP and the crash is still 100% repeatable with JSONRPC.Introspect.
I'll file a trac report tomorrow, I can't recall all the methods that failed. I'll have to update the trac report as I discover them. If I can get XBMC code to compile on my Mac I would be glad to assist you.



RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - dwagner - 2012-08-12

(2012-08-09, 23:39)Montellese Wrote:
(2012-08-09, 22:54)Millencolin007 Wrote: I understand that you want to remove the VFS handlers since it is a security risk and allows you to download almost any file from xbmc.

Currently the only way to retrieve audio playlists from xbmc is using the url special://musicplaylists. Is this also part of the vfs handlers and will there be an alternative after removing the handlers?

Will it still be possible to download/stream a file from xbmc using the url returned by Files.PrepareDownload, since today this function returns a vfs url and I am using those urls in my app to stream music files to android devices? Will there be an alternative url?

Files.PrepareDownload will fail on anything except cached images. The problem with access to media files is that it is very difficult to draw a line of what should be accessible and what not. Every user would probably provide you with a different answer so for now only providing access to the cached images is the safest solution. Hopefully there will be ways to access media files managed by XBMC in the future but we haven't thoroughly discussed this yet.

Please don't kill the ability to download files. I also download info on music playlists and I download file info on add-ons to display to users. Ultimately I think a permissions system which you mentioned in another post is the best solution. As is you have added JSON methods that allow deleting items from the Database which is more dangerous then allowing download of a file.



RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - jmarshall - 2012-08-12

Why is removing an item from a database more dangerous than allowing access to download a file? The file itself is not deleted.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-08-12

(2012-08-11, 19:47)Tolriq Wrote: I finally got the database and it seems that's it the data in database that is not good and I suppose the json part suppose the data is correct UTF and does not do another utf encode Sad

How is non valid UTF be stored in database ? If this can happens shouldn't the Json part ensure that it sends correct data ?

A screen shot of the database content : http://yatse.leetzone.org/Images/utf.png
In general XBMC should store everything as UTF8. If it doesn't the problem is somewhere else in XBMC and could also cause problems in the GUI when displaying the text.
Another possibility is if a user manually changed stuff in the database (e.g. fixed a movie plot or something like that). Then it's no longer garantueed that the text is correctly encoded in UTF8 but that's the problem of the user manually editing the database or using a third party tool that writes directly to the XBMC database and messes up the encoding.

(2012-08-11, 20:44)Tolriq Wrote: And another question that have nothing to do with that Smile

What is the recommended way to get pictures thumbs for Frodo ?
It seems there's no way for Eden other than getting the real image via preparedownload and vfs.

But for Frodo if VFS is removed ?

Should I make a FR so that the thumbnail properties is filled in GetDirectory for media = pictures ?
I haven't considered pictures yet tbh. Will have to think on it and discuss with jmarshall.

(2012-08-12, 01:25)Tolriq Wrote: And to finish for today, another very small bug that might worth being corrected for Frodo.

When doing a Files.GetDirectory with media set to movie on a directory with movies scanned to Xbmc databases with an organization of 1 movie by folder, the response list the directories as recognized movies with a correct type of movie and set the filename directly to the movie but leaves the FileType attribute to directory instead of file.

For example :

Code:
{"id":1,"jsonrpc":"2.0","method":"Files.GetDirectory","params":{"media":"video","directory":"Z:\\Films\\","properties":["title","thumbnail","fanart","rating","genre","artist","track","season","episode","year","duration","album","showtitle","playcount"]}}

Gives the result :

Code:
{"id":1,"jsonrpc":"2.0","result":{"files":[{"album":"","artist":"","episode":-1,"fanart":"image://Z%3a%5cFilms%5c13%20fant%c3%b4mes%20(Thir13en%20Ghosts)%20%5b720p%5d%20%5b2002%5d%5cfanart.jpg","file":"Z:\\Films\\13 fantômes (Thir13en Ghosts) [720p] [2002]\\13 fantômes.bluray.720p.2002.mkv","filetype":"directory","genre":"","id":7,"label":"13 fantômes","playcount":1,"rating":5.0999999046325684,"season":-1,"showtitle":"","thumbnail":"image://Z%3a%5cFilms%5c13%20fant%c3%b4mes%20(Thir13en%20Ghosts)%20%5b720p%5d%20%5b2002%5d%5cmovie.tbn","title":"13 fantômes","track":-1,"type":"movie","year":2002},{"album":"","artist":"","episode":-1,"fanart":"image://Z%3a%5cFilms%5c13%20jeux%20de%20mort%20(13%20game%20Sayawng)%20%5b720p%5d%20%5b2006%5d%5cfanart.jpg","file":"Z:\\Films\\13 jeux de mort (13 game Sayawng) [720p] [2006]\\13 jeux de mort.720p.2006.mkv","filetype":"directory","genre":"Thriller","id":8,"label":"13 jeux de mort","playcount":0,"rating":5,"season":-1,"showtitle":"","thumbnail":"image://Z%3a%5cFilms%5c13%20jeux%20de%20mort%20(13%20game%20Sayawng)%20%5b720p%5d%20%5b2006%5d%5cmovie.tbn","title":"13 jeux de mort","track":-1,"type":"movie","year":2006},{"album":"","artist":"","episode":-1,"fanart":"image://Z%3a%5cFilms%5c2%20Fast%202%20Furious%20(2%20Fast%202%20Furious)%20%5b720p%5d%20%5b2003%5d%5cfanart.jpg","file":"Z:\\Films\\2 Fast 2 Furious (2 Fast 2 Furious) [720p] [2003]\\2 Fast 2 Furious.hddvd.720p.2003.mkv","filetype":"directory","genre":"Action / Crime / Thriller","id":4,"label":"2 Fast 2 Furious","playcount":1,"rating":5.0999999046325684,"season":-1,"showtitle":"","thumbnail":"image://Z%3a%5cFilms%5c2%20Fast%202%20Furious%20(2%20Fast%202%20Furious)%20%5b720p%5d%20%5b2003%5d%5cmovie.tbn","title":"2 Fast 2 Furious","track":-1,"type":"movie","year":2003},{"album":"","artist":"","episode":-1,"fanart":"image://Z%3a%5cFilms%5c2012%20(2012)%20%5b720p%5d%20%5b2009%5d%5cfanart.jpg","file":"Z:\\Films\\2012 (2012) [720p] [2009]\\2012.720p.2009.mkv","filetype":"directory","genre":"","id":20,"label":"2012","playcount":0,"rating":6,"season":-1,"showtitle":"","thumbnail":"image://Z%3a%5cFilms%5c2012%20(2012)%20%5b720p%5d%20%5b2009%5d%5cmovie.tbn","title":"2012","track":-1,"type":"movie","year":2009}

As you see file attributes are set to a file in subdirs since movie is in database so referring to a direct file but the result also contain : "filetype":"directory" witch should mean that you can go down a level in the returned file attribute witch is obviously not possible.

The correct behavior should to have the filetype set to file. (Or to send back only the directory so we could go in but I don't think this would make sense for full real browsing we should use the media:files ).
Hm good question whether it should show "directory" and the path to the directory or "file" and the path to the file. The former would be normal behaviour in video files view while the latter would be the behaviour with "Stacking" enabled in video files view.

(2012-08-12, 04:06)jmarshall Wrote: Why is removing an item from a database more dangerous than allowing access to download a file? The file itself is not deleted.

Access to any file on your computer is faaaaar more dangerous than deleting something in the database. With the VFS handler you can access any file on your computer so also the password files on linux etc. IMO it's more important to fix such a security issue even if it means restricting access to other "valid" files for now until a better solution has been found (which is not so easy).


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Tolriq - 2012-08-12

(2012-08-12, 09:19)Montellese Wrote:
(2012-08-11, 19:47)Tolriq Wrote: I finally got the database and it seems that's it the data in database that is not good and I suppose the json part suppose the data is correct UTF and does not do another utf encode Sad

How is non valid UTF be stored in database ? If this can happens shouldn't the Json part ensure that it sends correct data ?

A screen shot of the database content : http://yatse.leetzone.org/Images/utf.png
In general XBMC should store everything as UTF8. If it doesn't the problem is somewhere else in XBMC and could also cause problems in the GUI when displaying the text.
Another possibility is if a user manually changed stuff in the database (e.g. fixed a movie plot or something like that). Then it's no longer garantueed that the text is correctly encoded in UTF8 but that's the problem of the user manually editing the database or using a third party tool that writes directly to the XBMC database and messes up the encoding.

I just got feedback from this user and he did not tamper the database, he just use NFO files then Xbmc scan.
The Nfo files are effectively badly encoded but Xbmc should sanitize those and not insert in database incorrect data.

http://yatse.leetzone.org/Castle.S03E01.nfo / http://yatse.leetzone.org/Castle.S03E02.nfo


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-08-12

(2012-08-12, 14:20)Tolriq Wrote: I just got feedback from this user and he did not tamper the database, he just use NFO files then Xbmc scan.
The Nfo files are effectively badly encoded but Xbmc should sanitize those and not insert in database incorrect data.

http://yatse.leetzone.org/Castle.S03E01.nfo / http://yatse.leetzone.org/Castle.S03E02.nfo

In that case it's a problem with XBMC's NFO scanner and not JSON-RPC. Create a bug ticket on trac about it and attach the NFOs and if possible the database.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - dwagner - 2012-08-14

(2012-08-12, 04:06)jmarshall Wrote: Why is removing an item from a database more dangerous than allowing access to download a file? The file itself is not deleted.

You are right. Dangerous is the wrong word, bored hackers could be more pests with the delete command. I am all for securing user content, but its not great to shut the door on programs that use the download feature legitimately. Montellese's idea of using a permission system is the right way to go, so its my hope that the XBMC Team waits to implement this before just closing the door on programs that have been using the download feature for some time. Even as a first step instead of having a complicated permission system just use a Device.PairChallenge via JSON like Boxee does in their API.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Tolriq - 2012-08-14

A new little question Smile

Is there a way to get the current user sorttokens ? Or a way during queries to get the title with sorttokens applied ?

I got lot's of request for supporting this and I'd like to be able to reproduce what they configure in Xbmc. (And I can't use a sort in the Json query since I do sync to local database and can later sort by year + title /sortitle or such)

And as a bonus question but related, is there / will be a way to get the current language Xbmc is configured to ?


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - N3MIS15 - 2012-08-16

I started looking at the new movie tags feature and was wondering if there are plans to add VideoLibrary.GetMovieTags method?


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - N3MIS15 - 2012-08-16

Is there any way to parse thumbnail images that are taken from video files?
example: image://video@smb%3a%2f%2funraid%2fRIPS%2fGame_Of_Thrones_Season_1_Disc_2_t00.mkv


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Mizaki - 2012-08-16

Am I right in saying there is no way to retrieve the resume point of a file? I use GetFooDetails for movies and TV but am I missing a way to do it when the file is played and not in the library?

Had a quick play with the filter PR. Awesome sauce on an awesome burger between an awesome bun Smile Is the addon PR still going in this month btw?


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Martijn - 2012-08-16

(2012-08-16, 23:45)Mizaki Wrote: Had a quick play with the filter PR. Awesome sauce on an awesome burger between an awesome bun Smile Is the addon PR still going in this month btw?

@Montellese
Gonna need some help with that filter addition. Will ping you at IRC

@Mizaki
Not this month because merge window is closed. Next one is at the start of September


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Mizaki - 2012-08-19

Sorry if I've missed something but can I not do a smart playlist type filter with a single item? For example:
Code:
{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "filter": { "field": "title", "operator": "startswith", "value": "A" } }, "id": 1}
I've tried a few variations and can't get it to work which I think is "right" as there is no "and"/"or". I've found a workaround of:
Code:
{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "filter": { "and": [ { "field": "year", "operator": "endswith", "value": "" }, { "field": "title", "operator": "startswith", "value": "a" } ]  }  }, "id": 1}
With the above is there a way to ignore the article that I've missed again?

Also:
Code:
{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "filter": { "year": "2000" } }, "id": 1}

doesn't appear to work. "Invalid params" but I believe it should?

Would you like me to continue testing or do you know about these? Smile


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-08-19

(2012-08-14, 03:00)dwagner Wrote: You are right. Dangerous is the wrong word, bored hackers could be more pests with the delete command. I am all for securing user content, but its not great to shut the door on programs that use the download feature legitimately. Montellese's idea of using a permission system is the right way to go, so its my hope that the XBMC Team waits to implement this before just closing the door on programs that have been using the download feature for some time. Even as a first step instead of having a complicated permission system just use a Device.PairChallenge via JSON like Boxee does in their API.
The problem is that the permission system would not really solve the problem of the current VFS handler. You can use VFS urls without previously using Files.PrepareDownload because you just need to URL encode the path you want to access and then append that path to the VFS url so a permission system on JSON-RPC level won't do any good. That's why we'll have to make major changes to it anyway and starting with removing any access to files directly is the first step. Then we can start considering which files we want to expose to clients and how.

(2012-08-14, 12:13)Tolriq Wrote: Is there a way to get the current user sorttokens ? Or a way during queries to get the title with sorttokens applied ?
No there isn't because these are window/view dependent.

(2012-08-14, 12:13)Tolriq Wrote: And as a bonus question but related, is there / will be a way to get the current language Xbmc is configured to ?
Yes when it will be possible to access (and modify) GUI settings through JSON-RPC.

(2012-08-16, 02:26)N3MIS15 Wrote: I started looking at the new movie tags feature and was wondering if there are plans to add VideoLibrary.GetMovieTags method?
Most likely there will be a VideoLibrary.GetTags method (similar to GetGenres) because I plan to extend tags to tvshows, episodes and musicvideos.

(2012-08-16, 10:03)N3MIS15 Wrote: Is there any way to parse thumbnail images that are taken from video files?
example: image://video@smb%3a%2f%2funraid%2fRIPS%2fGame_Of_Thrones_Season_1_Disc_2_t00.mkv
Not sure I understand the question. Is this a image:// URL you get from XBMC through JSON-RPC? or what are you trying to achieve?

(2012-08-16, 23:45)Mizaki Wrote: Am I right in saying there is no way to retrieve the resume point of a file? I use GetFooDetails for movies and TV but am I missing a way to do it when the file is played and not in the library?
Yup that's probably not possible. I'll have a look if I can add an extra call to retrieve that information if requested by the client.

(2012-08-16, 23:45)Mizaki Wrote: Had a quick play with the filter PR. Awesome sauce on an awesome burger between an awesome bun Smile
Glad to hear that you like it.

(2012-08-16, 23:45)Mizaki Wrote: Is the addon PR still going in this month btw?
Totally forgot about it because I had a lot of stuff to do.

(2012-08-16, 23:58)Martijn Wrote: @Montellese
Gonna need some help with that filter addition. Will ping you at IRC
I was away the whole week but I'll be in IRC again starting tomorrow.

(2012-08-19, 01:21)Mizaki Wrote: Sorry if I've missed something but can I not do a smart playlist type filter with a single item? For example:
Code:
{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "filter": { "field": "title", "operator": "startswith", "value": "A" } }, "id": 1}
Seems like I forgot about the case of a single filter where it is a bit of a pain to just define an "and" or an "or" property containing the actual rule. Will see that I can get it in. Thanks for the hint.

(2012-08-19, 01:21)Mizaki Wrote: I've tried a few variations and can't get it to work which I think is "right" as there is no "and"/"or". I've found a workaround of:
Code:
{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "filter": { "and": [ { "field": "year", "operator": "endswith", "value": "" }, { "field": "title", "operator": "startswith", "value": "a" } ]  }  }, "id": 1}
With the above is there a way to ignore the article that I've missed again?
I don't follow. What are you trying to do?

(2012-08-19, 01:21)Mizaki Wrote: Also:
Code:
{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "filter": { "year": "2000" } }, "id": 1}

doesn't appear to work. "Invalid params" but I believe it should?
Nope year must be an integer value and not a string. So get rid of the double-quotes around 2000 and you should be good.

(2012-08-19, 01:21)Mizaki Wrote: Would you like me to continue testing or do you know about these? Smile
Sure, any testing is good. I can only test so many cases and miss 99.9%. Let me know if you run into any more problems or have any ideas/suggestions. The implementation or rather the way you have to define the filter properties is a bit limited by the way smartplaylists work but I think it's ok.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Tolriq - 2012-08-20

(2012-08-19, 23:51)Montellese Wrote:
(2012-08-14, 12:13)Tolriq Wrote: Is there a way to get the current user sorttokens ? Or a way during queries to get the title with sorttokens applied ?
No there isn't because these are window/view dependent.

Not sure understand, those are configured in advanced settings and does not change.
I suppose you mean they can be activated or not in the views but the list containing (The, A , An, ...) should not change. And getting this list from remotes will allow remotes to reproduce Xbmc sorting if the user want it.