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)



- grywnn - 2011-11-10

Sure.
I'm doing a big all-rounder:
Code:
{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": {"properties": ["playcount", "year", "rating", "genre", "trailer", "tagline", "plot", "fanart", "thumbnail", "set", "setid"], "sort": { "method": "sorttitle", "order": "ascending", "ignorearticle": true } }, "id": 1}
From what you say, i'd guess either playcount or set+setid are the evil ones...


- Montellese - 2011-11-10

grywnn Wrote:Sure.
I'm doing a big all-rounder:
Code:
{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": {"properties": ["playcount", "year", "rating", "genre", "trailer", "tagline", "plot", "fanart", "thumbnail", "set", "setid"], "sort": { "method": "sorttitle", "order": "ascending", "ignorearticle": true } }, "id": 1}
From what you say, i'd guess either playcount or set+setid are the evil ones...

Yeah "set" and "setid" are the evil properties as stated in the description of "Video.Fields.Movie":
Quote:Requesting the cast, set, showling and/or resume field will result in increased response times



- grywnn - 2011-11-10

hmm would dropping the set field in favor of setid help (i'd guess so: Setid is probably a crossindex available in the movies table, right?)

Or, the other way round:
How about adding an optional setid: parameter to getMovies?

Cause right now, if i want to get the movies from a specific set, i have to run the above query and filter by setid afterwards (imagine the client as "dumb", not remembering earlier result sets of the same query)


- Montellese - 2011-11-10

Why don't you use VideoLibrary.GetMovieSets and VideoLibrary.GetMovieSetDetails? The latter returns the list of movies in the set with the given setid.


- grywnn - 2011-11-10

Damn i never bothered looking into getMovieSetDetails, because i thought i'd only get metadata about the set itself, not the items within.
Quick question then:
How would i get all movies that are in no st at all?
getMovieSetDetails with setid=0 ?


- Montellese - 2011-11-10

That's currently not possible. "setid" = 0 might be a valid set in an XBMC installation.

I specifically made GetMovieSetDetails so that it returns all movies in a given set. You can even specify the properties you want for the returned movies in the "properties" protperty of the "movies" parameter.


- grywnn - 2011-11-10

Code:
{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieSetDetails", "params": {"setid": 0,"properties": ["thumbnail"]}, "id": "1"}
{
    "error": {
        "code": -32602,
        "data": {
            "method": "VideoLibrary.GetMovieSetDetails",
            "stack": {
                "message": "Value between 1 (inclusive) and 2147483647 (inclusive) expected but 0 received",
                "name": "setid",
                "type": "integer"
            }
        },
        "message": "Invalid params."
    },
    "id": "1",
    "jsonrpc": "2.0"
}
Big Grin
(PVR build git20111102)

Indeed, calling getMovieSetDetails is super fast.

So, to get a structure like i have in confluences movie view, where sets and non set movies are mixed at the bottom level, and you can dive into each set to view the set items, i'd have to:
Call getMovieSets to get a set list,
Call getMovies to get all movies those in sets and those without alike,
Iterate through all sets calling getMovieSetDetails for each set,
remove all matching movies from the "all movies" list,
join the resulting movie and set lists.

A little inconvenient IMHO. Or did i miss something again?


- Montellese - 2011-11-10

grywnn Wrote:A little inconvenient IMHO. Or did i miss something again?
No you didn't miss anything but there's no better way to do it. JSON-RPC is not GUI-oriented but API-oriented so it wouldn't make any sense to return a mixture of movies and sets in either GetMovies or GetMovieSets. If you want to implement special features in your client you'll have to do some work as well Wink

Furthermore "sets" are not fully integrated into XBMC either so at first I was even against adding GetMovieSets and GetMovieSetDetails.


- grywnn - 2011-11-11

My problem wasn't mixing the movies and the sets, i'm completely fine with that.
It's that i either have to go for the slow getMovies query with setid as parameter, or loop through all sets to filter out the set items.
So thats either one extremely slow query or (number of sets)+2 fast queries only to get all non set movies.

Anyway, i just had a look through the XBMC source, and obviously the problem lies deep down in video/VideoDatabase.cpp
To put it short:
VideoDatabase::GetDetailsForMovie (called in VideoDatabase::GetMovieInfo) offers no control over the details you're interested in apart from a needsCast bool that triggers cast, setinfo and tvshowlink all at once.
So if i'm just interested in movie sets for every movie, all the cast info is generated alongside, which is horribly expensive.
Adding another parameter to VideoDatabase::GetDetailsForMovie would probably have tons of implications, so it's nothing thats easily fixed.

One more thing though:
Code:
"Video.Details.MovieSet": {
    "extends": "Video.Details.Media",
    "properties": {
      "setid": { "$ref": "Library.Id", "required": true }
    }
  },
Library.Id has a minimum value of 1, while as you pointed out before there could well be sets with setid=0.


- Montellese - 2011-11-11

grywnn Wrote:Anyway, i just had a look through the XBMC source, and obviously the problem lies deep down in video/VideoDatabase.cpp
To put it short:
VideoDatabase::GetDetailsForMovie (called in VideoDatabase::GetMovieInfo) offers no control over the details you're interested in apart from a needsCast bool that triggers cast, setinfo and tvshowlink all at once.
So if i'm just interested in movie sets for every movie, all the cast info is generated alongside, which is horribly expensive.
Adding another parameter to VideoDatabase::GetDetailsForMovie would probably have tons of implications, so it's nothing thats easily fixed.
Which is why I never really touched that method. Wink

grywnn Wrote:One more thing though:
Code:
"Video.Details.MovieSet": {
    "extends": "Video.Details.Media",
    "properties": {
      "setid": { "$ref": "Library.Id", "required": true }
    }
  },
Library.Id has a minimum value of 1, while as you pointed out before there could well be sets with setid=0.

I'll have to double-check but I might have been mistaken concerning setid = 0.

Concerning the order of GetRecentlyAddedMovies I'll have to double-check as well.


- Montellese - 2011-11-11

OK I checked the code.

The lowest possible ID of a database item is 1 so Library.Id works the way it should.

Code:
{ "jsonrpc": "2.0", "method": "VideoLibrary.GetRecentlyAddedMovies", "params": { "limits": { "end": 1 } }, "id": 1 }
works perfectly fine for me. It returns the last added movie i.e. the movie with the highest "movieid". The SQL query runs "ORDER BY movieid DESC" so that should really be fine.


- dwagner - 2011-11-12

Montellese Wrote:works perfectly fine for me.

You are of course correct, and having compared my code to yours I now bow my head in shame for the glaring copy paste mistake. I was actually incorrectly calling GetMovies which explains why I got the first movie. Sadly I never picked up on it at the time while it was staring me in the face in the simple rest client.

Apologies for wasting your time.


- yallah - 2011-11-12

Hi,

Is it possible control dreambox plugin (tuxbox) with JSON


- jimk72 - 2011-11-12

Im starting to work on the playlist part of my program and noticed the result does not give you a limits like most other results. Is this a bug or is it supposed to be like this. Just trying to figure out how many playlists there are. Or do I have to call a diff method that will tell me how many playlists there are.

Thanks in advanced!

After messing with this I realized that it always returns only those three playlist ids. I am trying to access the playlists created by the user and the name of said playlist.

After researching I found the playlist only access the current players que. I see no JSON in the rpc that will access these. am I right to gather these are not accessable?


- othrayte - 2011-11-12

I have been using the JSONRPC.NotifyAll method recently, and it has been working fine but I've just tried to use it to pass data and the only thing that it is passing is a string representation of the basic types; ie a string is passed as a string, a number is passed as a string but more complex types like dictionaries, list and tuples are passed as empty strings. In the .json file it specifies that 'data' can be of type 'any'. Should I be able to pass the more complex types and why are the numbers converted to strings?

The example I'm trying is:
Code:
{"params": {"message": "TraktUtilities.View", "data": {"window": "watchlistMovies"}, "sender": "TraktUtilities"}, "jsonrpc": "2.0", "method": "JSONRPC.NotifyAll", "id": 1}