Kodi Community Forum

Full Version: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have a problem with XBMC.Play. WHen i use it to play a movie from my library, it plays correctly but then VideoPlaylist.GetItems retuns an empty items list after that.
To resume if i play a movie from XBMC i get a correct "items" in VideoPlaylist.GetItems, but if i do it through XBMC.PLay, i get an empty "items" in VideoPlaylist.GetItems
Another remark. When requesting a field (for example "cast" in getMovies) and the field is null, could we get a result without "cast" instead of "cast = <null>"? it would be a lot easier to work with.

Thanks
carmenm Wrote:Hi,

I have a problem with XBMC.Play. WHen i use it to play a movie from my library, it plays correctly but then VideoPlaylist.GetItems retuns an empty items list after that.
To resume if i play a movie from XBMC i get a correct "items" in VideoPlaylist.GetItems, but if i do it through XBMC.PLay, i get an empty "items" in VideoPlaylist.GetItems
I'll have to try that when I get time but I recommend to use VideoPlaylist.Add/Insert and VideoPlaylist.Play instead of XBMC.Play. I know it's faster to only call XBMC.Play but XBMC.Play does not know what kind of media file you are trying to play whereas VideoPlaylist.Add at least knows that it's a video file so this is the better approach.

carmenm Wrote:Another remark. When requesting a field (for example "cast" in getMovies) and the field is null, could we get a result without "cast" instead of "cast = <null>"? it would be a lot easier to work with.

It hasn't been decided (nor discussed) yet whether we should return null for any requested field, that is not set or if we should not return it at all. This is the same problem as with the requested "thumbnail" field which is not returned. We'll have to decide on one of the two approaches and then stick with it. IMO it doesn't matter whether you have to check IF a certain property is present or if you can be sure that it is present but need to check whether it is null or not.
But if i use VideoPlaylist.Add/Insert, it means that i first have to clean the playlist if i want to emulate XBMC.play? so what about a VideoPlaylist.set that would clean then add. just a wish ... Tongue

Yeah i get that you have to make a choice and that it is not made. If i had to choose(simple opinion) i would have to choose not existing. I dont like to rely on a string that can change syntax and everything.
Moreover in the code testing the existence of an object doesnt rely on a variable that i would have to set somewhere. In this case it would be a string "<null>" that i would use to compare with.
Once again just my humble opinion

EDIT: on another subject, is there a way to get an actor thumbnail image?

THanks
carmenm Wrote:Yeah i get that you have to make a choice and that it is not made. If i had to choose(simple opinion) i would have to choose not existing. I dont like to rely on a string that can change syntax and everything.
Moreover in the code testing the existence of an object doesnt rely on a variable that i would have to set somewhere. In this case it would be a string "<null>" that i would use to compare with.
Are you not using a JSON library that provides you with parsing and convenience methods like isNull etc? If not I would highly recommend to look for one (hopefully one exists for whatever programming language you use) as it can make your life so much easier.

carmenm Wrote:EDIT: on another subject, is there a way to get an actor thumbnail image?

No, but I planned to add it to the "cast" list for movies but probably forgot about it. Please check if there already is a feature request for this on trac and if not create one so I don't forget again Wink
Another update to JSON-RPC: I committed a fix for the long- and well-known problem when using the "file" parameter of AudioPlaylist/VideoPlaylist.Add/Insert which did not provide any metadata neither in the GUI nor through AudioPlaylist/VideoPlaylist.GetItems. You should now get full metadata information + I added a "directory" parameter which let's you provide the path to a directory to add all audio/video items (e.g. all songs from an album or all episodes from a certain tv show season) from that directory with a single call.

As a benefit Files.GetDirectory got an update as well and should now be able to return all kinds of meta data for the returned files as well (including the "id" and "type" if it is a file known to XBMC) BUT only when you define the type of media you are looking for using the "media" parameter.

I hope you enjoy this and that it will make your lifes easier.
Montellese Wrote:Are you not using a JSON library that provides you with parsing and convenience methods like isNull etc? If not I would highly recommend to look for one (hopefully one exists for whatever programming language you use) as it can make your life so much easier.
Yes i am using a json library, but apparently not such a good one Tongue
But you are right i will add a <null> check in the deserializer. One question though. If you stay with the null, shouldnt it be "cast = null" and not "cast = <null>"? looking at the json sytnax i dont see the "<>"

Quote:No, but I planned to add it to the "cast" list for movies but probably forgot about it. Please check if there already is a feature request for this on trac and if not create one so I don't forget again Wink
Ok will add the ticket.

Thanks a lot
carmenm Wrote:Yes i am using a json library, but apparently not such a good one Tongue
But you are right i will add a <null> check in the deserializer. One question though. If you stay with the null, shouldnt it be "cast = null" and not "cast = <null>"? looking at the json sytnax i dont see the "<>"

In my raw TCP and HTTP output I can only see "null" without any "<>".
Montellese Wrote:In my raw TCP and HTTP output I can only see "null" without any "<>".
sorry then, there must really be something wrong with my lib then Confused (objective c lib)
Montellese Wrote:Another update to JSON-RPC: I committed a fix for the long- and well-known problem when using the "file" parameter of AudioPlaylist/VideoPlaylist.Add/Insert which did not provide any metadata neither in the GUI nor through AudioPlaylist/VideoPlaylist.GetItems. You should now get full metadata information + I added a "directory" parameter which let's you provide the path to a directory to add all audio/video items (e.g. all songs from an album or all episodes from a certain tv show season) from that directory with a single call.

As a benefit Files.GetDirectory got an update as well and should now be able to return all kinds of meta data for the returned files as well (including the "id" and "type" if it is a file known to XBMC) BUT only when you define the type of media you are looking for using the "media" parameter.

I hope you enjoy this and that it will make your lifes easier.

Cool stuff! Thanks a lot.
Montellese Wrote:Another update to JSON-RPC: I committed a fix for the long- and well-known problem when using the "file" parameter of AudioPlaylist/VideoPlaylist.Add/Insert which did not provide any metadata neither in the GUI nor through AudioPlaylist/VideoPlaylist.GetItems. You should now get full metadata information

Hi, I have tested that now, and it seems to work only for items found in the Library. However, imho the main purpose of the Files namespace is to play back items that are not contained in the Library. Any chance this could be also fixed for the the other files?


And another thing I noticed is that the VideoLibrary.GetItems fields parameter lacks the "duration" enum. This would be handy to show a progressbar for the currently played video.
mzanetti Wrote:Hi, I have tested that now, and it seems to work only for items found in the Library. However, imho the main purpose of the Files namespace is to play back items that are not contained in the Library. Any chance this could be also fixed for the the other files?

Well the methods VideoPlaylist/AudioPlaylist.GetItems/Add/Insert are not in the Files namespace Wink I'm not sure if it makes sense to try to get metadata information for files not in the library. IMO if you want metadata you should have your files in the library because that's what the library is for.

mzanetti Wrote:And another thing I noticed is that the VideoLibrary.GetItems fields parameter lacks the "duration" enum. This would be handy to show a progressbar for the currently played video.

There is no "duration" enum for videos because it is called "runtime". It's "duration" for audio files and "runtime" for video files Wink
Montellese Wrote:Well the methods VideoPlaylist/AudioPlaylist.GetItems/Add/Insert are not in the Files namespace Wink I'm not sure if it makes sense to try to get metadata information for files not in the library. IMO if you want metadata you should have your files in the library because that's what the library is for.

Well, the VideoPlaylist/AudioPlaylist.GetItems do not return any metadata if the files in there are added by browsing the Files namespace and the added file is not contained in the Library... Thats probably the more precise wording. Still, I think you get what I mean.

In my opinion such files should at least have the same "label" as the one displayed in xbmc directly. Also, there should be no dfference in the GetItems result wether the files are beeing added directly on xbmc or via JSon.

You can see the difference ealsy doing this:
- Browse the "Files" directly on the xbmc and start playback of a file not contained in the library (e.g. Some homebrew video file that does not fall into the Movie/TVShow/MusicVideo categories).
- Do a Audio/VideoPlaylist.GetItems with all fields. You will get the filename (without the path) in the "label" field.
- Now do Audio/VideoPlaylist.Clear and add the same file(s) again using the Audio/VideoLibrary.Add call using the filename.
- Do the same GetItems call again. The "label" field will be empty.

Now you can see, that for the exact same display/behavior of xbmc on your TV/Computer, the JSONRPC API returns different results.

Montellese Wrote:There is no "duration" enum for videos because it is called "runtime". It's "duration" for audio files and "runtime" for video files Wink
Oh, missed that one... Thanks for the hint.
mzanetti Wrote:In my opinion such files should at least have the same "label" as the one displayed in xbmc directly. Also, there should be no dfference in the GetItems result wether the files are beeing added directly on xbmc or via JSon.

You can see the difference ealsy doing this:
- Browse the "Files" directly on the xbmc and start playback of a file not contained in the library (e.g. Some homebrew video file that does not fall into the Movie/TVShow/MusicVideo categories).
- Do a Audio/VideoPlaylist.GetItems with all fields. You will get the filename (without the path) in the "label" field.
- Now do Audio/VideoPlaylist.Clear and add the same file(s) again using the Audio/VideoLibrary.Add call using the filename.
- Do the same GetItems call again. The "label" field will be empty.

Now you can see, that for the exact same display/behavior of xbmc on your TV/Computer, the JSONRPC API returns different results.

Ah you were talking about the "label". I thought you were talking about general metadata. As all my video and audio files are in XBMC's library I never encountered that problem but I fixed it with a commit just now. The label will show the filename but there is no additional metadata available.
Montellese Wrote:Ah you were talking about the "label". I thought you were talking about general metadata. As all my video and audio files are in XBMC's library I never encountered that problem but I fixed it with a commit just now. The label will show the filename but there is no additional metadata available.

Yay Smile But it's not only the label. E.g. xbmc creates screenshots of videos without metadata. When adding them to the playlist on xbmc directly, the "thumbnail" field contains a URI to that screenshot. When adding them using JSONRPC the "thumbnail" field is empty. I'm not sure about other fields as I don't have testet all of them. But "label" and "thumbnail" immediately popped up here on the first try.