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)



- Montellese - 2011-03-01

I have already reproduced the described problem and I have also identified the source of it but unfortunately it is by no means an easy fix.


- gertjanzwartjes - 2011-03-01

Ok, good to know that you are on top of it. Hope a solution can be found, although I'm not an official XBMC developer, if you'd need help let me know.


- vasikgreif - 2011-03-03

Is there something like VideoLibrary.GetGenres and VideoLibrary.GetActors implemented? Thanks


- Montellese - 2011-03-03

vasikgreif Wrote:Is there something like VideoLibrary.GetGenres and VideoLibrary.GetActors implemented? Thanks

No it isn't but feature requests (in our Trac) are always welcome (please submit a seperate request for every idea). IIRC correctly I once looked into adding VideoLibrary.GetGenres() and it wasn't as simple as I thought it would be and had more important stuff to do.


- dann0 - 2011-03-04

I think there is something fishy with the 'total' field returned from AudioLibrary.GetAlbums()

When i use AudioLibrary.GetArtists({'start': 0, 'end': 5}) the 'total' returned is the total number of artists in the library, same goes for songs, if i use AudioLibrary.GetSongs({'start': 0, 'end': 5, 'artistid': 2}) the 'total' is the total tracks i have for the artist with id 2. This is all good and expected behaviour.

However if i use AudioLibrary.GetAlbums({'start': 0, 'end': 5}) the 'total' is always the same as 'end'. This is not so juicy and makes it hard to page through results as the client can't know when there are more pages available.

The workaround for me was to first query the server with AudioLibrary.GetAlbums('start': 0, 'end': 0) as this returns the true number of albums in the library but in doing that i discovered that when you send {'start': 0, 'end': 0, 'artistid': 2} you still get the total number of albums in the library, not the number of albums for artist with id 2.

stumped.


- dann0 - 2011-03-04

more strange behavior from AudioLibrary.GetAlbums().

When i send 'start' and 'end' params to this method it looks to me like it doubles the start value when returning results, even though the result has the correct values for 'start' and 'end' the albums array is not the correct items.

The real problems start when i specify a start value of more than half the total albums in my library, this breaks the response sending back 'start '= 7 'end' = 7 and 'total' = 7 (apparently nothing to do with the number of albums in the library) but no items.

It seems strange to me that no one else has noticed this behavior... can someone confirm this?


- topfs2 - 2011-03-04

total should reflect the actual number of returned items and if it does not then its wrong / bug.

e.g. If you query start=0, end=0 you should get total=0. If you query start=0 and end=10 but there are only 5 movies it should return total=5.

I do find it weird that it does not work in albums though since it uses the EXACT same code as everywhere else, I have not debugged or verified your problem though.


- Montellese - 2011-03-04

topfs2 Wrote:total should reflect the actual number of returned items and if it does not then its wrong / bug.

The way it currently is (and the way I think it is good) is that "total" shows the total number of items which could be retrieved when not limitting the number of items. If we don't return the total amount of available items a client never knows how many items actually exist (if the client prefers to use pagination). This is especially useful for remote control devices like the android remote where you don't want to retrieve all 2000 albums in one request but still need to know how many items are available.

topfs2 Wrote:e.g. If you query start=0, end=0 you should get total=0.
I disagree. Total should still show the number of theoretically available items.

If you want to know the amount of returned items you can always calculate it from the values returned for "start" and "end".


- Montellese - 2011-03-04

I just remembered that there is already a bug report for this with a discussion: #10146


- topfs2 - 2011-03-04

Montellese Wrote:The way it currently is (and the way I think it is good) is that "total" shows the total number of items which could be retrieved when not limitting the number of items. If we don't return the total amount of available items a client never knows how many items actually exist (if the client prefers to use pagination). This is especially useful for remote control devices like the android remote where you don't want to retrieve all 2000 albums in one request but still need to know how many items are available.


I disagree. Total should still show the number of theoretically available items.

If you want to know the amount of returned items you can always calculate it from the values returned for "start" and "end".

doh, yeah thats true Smile I just looked at the code and it does indeed return total as possible total which I agree is more useful than what I spoke of. Then you can query the possible numbers via start=0, end=0 which might be a useful indicator (which is why it was designed like that). My memory gets fuzzy it seems Smile

So to formalize, given 10 items:
start=0, end=0 -> start=0, end=0, total=10. Returning 0 items
start=0, end=5 -> start=0, end=5, total=10. Returning 5 items
start=5, end=15 -> start=5, end=10, total 10. Returning 5 items
start=15, end=20 -> start=10, end=10, total 10. Returning 0 items

This is the behavior we want? When I rethink on it I agree this is the proper API. i.e. input start and end are indicators what you want returned start and end shows what you got while total shows what is available in total.


- dann0 - 2011-03-05

Re: AudioLibrary.GetItems()

My apologies for not checking to see if the 'total' bug had already been reported. :o

dann0 Wrote:... When i send 'start' and 'end' params to this method it looks to me like it doubles the start value when returning results, even though the result has the correct values for 'start' and 'end' the albums array is not the correct items.

The real problems start when i specify a start value of more than half the total albums in my library, this breaks the response sending back 'start '= 7 'end' = 7 and 'total' = 7 (apparently nothing to do with the number of albums in the library) but no items....

This doesn't get a mention in the Trac discussion, should it be ignored as the AudioLibrary.GetAlbums() method is being looked at already?


- Manromen - 2011-03-10

Hi,

is there a way to get some more media info from a movie (VideoLibrary.GetMovies)?

I want to get the videowidth, video codec, imdb or tmdb id and so on ...

All i have yet is a list with the movies:
Code:
rpccmd = json.dumps({'jsonrpc': '2.0', 'method': 'VideoLibrary.GetMovies','params':{'fields': ['year','title','playcount','genre','duration','originaltitle']}, 'id': 1})

result = xbmc.executeJSONRPC(rpccmd)
result = json.loads(result)

I don't know how to get some more infos about the movies :-)


- Montellese - 2011-03-10

Manromen Wrote:is there a way to get some more media info from a movie (VideoLibrary.GetMovies)?
The next version will offer a VideoLibrary.GetMovieDetails() method to retrieve information for a single movie by ID.

Manromen Wrote:I want to get the videowidth, video codec, imdb or tmdb id and so on ...
Try the following additional fields:
- "imdbid": returns the ID used for scraping a site as a string
- "streamDetails": returns an object containing a "video", "audio" and "subtitle" object. From the "streamDetails.video" object you should be able to retrieve the codec and other useful data about the available video streams in a movie.

PS: I might have to check whether these field names are correct I can't look them up right now so this is just what I have in mind right now.


- Manromen - 2011-03-10

Thanks very much :-)

[edit]

the field names seem to be wrong

[edit2]

i looked them up right now, the correct field names are:
"imdbnumber" and "streamDetails"


- Fiasco - 2011-03-14

CommandFusion is adding support for javascript/JSON. Smile