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)



- Tolriq - 2012-02-09

With basic i mean a little more than arrows Smile

Like context menu, go to home / video or such screens / info .... the actions that are mappable in keymaps.


Player.Repeat - doozer - 2012-02-10

Any chance Eden can be updated to send an unsolicited message when the user changes the "Repeat" setting (off/one/all) ?

Noticed in Eden Beta 3, changing this setting doesn't result in a Player.Repeat update being broadcast.

Thanks,
Matt.


Genre issue - doozer - 2012-02-10

Hi All,

Hoping an expert can weigh in here and tell me if i'm doing something wrong..

I am listing all Genres:
Code:
{"jsonrpc": "2.0", "method": "AudioLibrary.GetGenres", "params": {"properties": ["title"], "limits": { "start" : 0, "end" : 20 }, "sort": { "method" : "label", "order" : "ascending" }}, "id": "AudioLibrary.GetGenres"}

Which results in:
Code:
{"id":"AudioLibrary.GetGenres","jsonrpc":"2.0","result":{"genres":[{"genreid":6,"label":"Alternative","title":"Alternative"},{"genreid":2,"label":"Hip-Hop","title":"Hip-Hop"},{"genreid":5,"label":"Punk","title":"Punk"},{"genreid":4,"label":"Rock","title":"Rock"},{"genreid":3,"label":"Unknown","title":"Unknown"}],"limits":{"end":5,"start":0,"total":5}}}

Note that the "Alternative" genre has an ID of 6.
I then request all Albums that fit this genre:
Code:
{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": {"genreid": 6,"properties": ["artist","artistid","albumlabel","year","thumbnail","genre"], "limits": { "start" : 0, "end" : 20 }, "sort": { "method" : "label", "order" : "ascending" }}, "id": "AudioLibrary.GetAlbumsByGenre"}

And get:
Code:
{"id":"AudioLibrary.GetAlbumsByGenre","jsonrpc":"2.0","result":{"albums":[{"albumid":9,"albumlabel":"WEA","artist":"Green Day","artistid":7,"genre":"Punk","label":"Dookie","thumbnail":"special://masterprofile/Thumbnails/Music/d/daca1175.tbn","year":1994},{"albumid":12,"albumlabel":"Reprise","artist":"Green Day","artistid":7,"genre":"Alternative","label":"Warning","thumbnail":"special://masterprofile/Thumbnails/Music/2/29036724.tbn","year":2000}],"limits":{"end":2,"start":0,"total":2}}}

Notice how I get one album of genre "Punk" and one of "Alternative". Why?


- Montellese - 2012-02-10

doozer Wrote:Any chance Eden can be updated to send an unsolicited message when the user changes the "Repeat" setting (off/one/all) ?

Noticed in Eden Beta 3, changing this setting doesn't result in a Player.Repeat update being broadcast.
Same goes for shuffle and other settings. But I'm not gonna add any new stuff to the JSON-RPC API for Eden at this point in the release cycle. Please create a feature request ticket for it on trac so I won't forget once Eden is out.

doozer Wrote:Hi All,

Hoping an expert can weigh in here and tell me if i'm doing something wrong..

I am listing all Genres:
Code:
{"jsonrpc": "2.0", "method": "AudioLibrary.GetGenres", "params": {"properties": ["title"], "limits": { "start" : 0, "end" : 20 }, "sort": { "method" : "label", "order" : "ascending" }}, "id": "AudioLibrary.GetGenres"}

Which results in:
Code:
{"id":"AudioLibrary.GetGenres","jsonrpc":"2.0","result":{"genres":[{"genreid":6,"label":"Alternative","title":"Alternative"},{"genreid":2,"label":"Hip-Hop","title":"Hip-Hop"},{"genreid":5,"label":"Punk","title":"Punk"},{"genreid":4,"label":"Rock","title":"Rock"},{"genreid":3,"label":"Unknown","title":"Unknown"}],"limits":{"end":5,"start":0,"total":5}}}

Note that the "Alternative" genre has an ID of 6.
I then request all Albums that fit this genre:
Code:
{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": {"genreid": 6,"properties": ["artist","artistid","albumlabel","year","thumbnail","genre"], "limits": { "start" : 0, "end" : 20 }, "sort": { "method" : "label", "order" : "ascending" }}, "id": "AudioLibrary.GetAlbumsByGenre"}

And get:
Code:
{"id":"AudioLibrary.GetAlbumsByGenre","jsonrpc":"2.0","result":{"albums":[{"albumid":9,"albumlabel":"WEA","artist":"Green Day","artistid":7,"genre":"Punk","label":"Dookie","thumbnail":"special://masterprofile/Thumbnails/Music/d/daca1175.tbn","year":1994},{"albumid":12,"albumlabel":"Reprise","artist":"Green Day","artistid":7,"genre":"Alternative","label":"Warning","thumbnail":"special://masterprofile/Thumbnails/Music/2/29036724.tbn","year":2000}],"limits":{"end":2,"start":0,"total":2}}}

Notice how I get one album of genre "Punk" and one of "Alternative". Why?

I was confused at first as well but in general XBMC always operates on songs when using the audiolibrary so what it does when you retrieve all albums of a certain genre is it actually returns all albums which contain at least one song with that genre. So in you're case there should be at least one song in Green Day's Dookie album which has "Alternative" as a genre.


- doozer - 2012-02-11

Montellese Wrote:Same goes for shuffle and other settings. But I'm not gonna add any new stuff to the JSON-RPC API for Eden at this point in the release cycle. Please create a feature request ticket for it on trac so I won't forget once Eden is out.

I was confused at first as well but in general XBMC always operates on songs when using the audiolibrary so what it does when you retrieve all albums of a certain genre is it actually returns all albums which contain at least one song with that genre. So in you're case there should be at least one song in Green Day's Dookie album which has "Alternative" as a genre.

Will do.

Ah, I see, it's on a per song basis, not a per album. Makes sense. Thanks.


- mikebzh44 - 2012-02-11

I'm using Files.GetDirectory for getting movies of a playlist :
Code:
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory": "special://profile/playlists/video/cartoons.xsp", "media": "video", "properties": ["originaltitle"], "sort": { "order": "descending", "method": "date" }}, "id": 1}')
I'm using sort to get last added movies but it doesn't seem to work because movies are returned in alphabetical order :
Code:
{u'jsonrpc': u'2.0',
u'id': 1,
u'result': {u'files': [{u'filetype': u'file', u'label': u"Winter's Bone", u'originaltitle': u"Winter's Bone", u'file': u'smb://READYNAS/media/Videos/HD/Films/Winter s bone/Winter s bone.mkv', u'type': u'movie', u'id': 75},
                        {u'filetype': u'file', u'label': u'Usual Suspects', u'originaltitle': u'The Usual Suspects', u'file': u'smb://READYNAS/media/Videos/HD/Films/The Usual Suspects/The Usual Suspects.mkv', u'type': u'movie', u'id': 70},
                        {u'filetype': u'file', u'label': u'Twilight - Chapitre 4 : R\xe9v\xe9lation 1\xe8re partie', u'originaltitle': u'Breaking Dawn - Part 1', u'file': u'smb://READYNAS/media/Videos/HD/Films/Twilight/Twilight - Chapitre 4 - Revelation 1ere partie/Twilight - Chapitre 4 - Revelation 1ere partie.m2ts', u'type': u'movie', u'id': 74},
                        {u'filetype': u'file', u'label': u'Twilight - Chapitre 3 : h\xe9sitation', u'originaltitle': u'Eclipse', u'file': u'smb://READYNAS/media/Videos/HD/Films/Twilight/Twilight - Chapitre 3 - Hesitation/Twilight III.mkv', u'type': u'movie', u'id': 73}
                       ],
             u'limits': {u'start': 0, u'total': 4, u'end': 4}
            }
}

How can I get movies from a playlist sorted by date ?


- Montellese - 2012-02-11

The sort method "date" does not mean the date the movie was added to the database. Those sort methods are a mess and very confusing (sorry for that) :-S

There's currently no way to automatically sort by date added. It was added to XBMC before the feature freeze but I didn't know about it and therefore it didn't make it into the JSON-RPC API for Eden. I'm not gonna change the API at this time anymore for Eden. But it will be available after Eden.


- mikebzh44 - 2012-02-11

I was confused because before today, request seems to bo OK but today, I have completly rebuild my video data so every movies was added today.

I will see tomorrow, when I will add some new movies, what the request will return.


- mikebzh44 - 2012-02-11

When I am using VideoLibrary.GetRecentlyAddedMovies, I get only 25 movies but if I use VideoLibrary.GetMovies, I get 187 movies.

GetRecentlyAddedMovies is limited ?


- Montellese - 2012-02-11

Yes as the name suggests by containing "Recently" Wink


- mikebzh44 - 2012-02-12

OK.

I want to request movie database in order to populate widgets "Random movies" and "Last added movies" for custom menus based on playlists :
http://forum.xbmc.org/showthread.php?tid=122448

There is no way to request database using SQL with JSON ?

Is it possible to add a result (as Title, Rating, Plot, ...) in Video.Fields.Movie for retrieving "database date added" ? So list could be sort by python because JSON sort by date did not do what everybody expect :S


- Montellese - 2012-02-12

No there is and will never be a way to use SQL queries through JSON-RPC. It's just too unsafe and a lot of things can go sideways. But there will be some kind of query functionality in the future.

I can't add a "Database date added" property to the result because XBMC does not store such a thing. What XBMC does to retrieve the list of recently added movies is it simply sorts the result by movieid in a descending order. So you can do that with python as well.


- mikebzh44 - 2012-02-12

Thanks for the tip of using ID !!

I think you are my saver Nod


- ErlendSB - 2012-02-13

Montellese Wrote:No there is and will never be a way to use SQL queries through JSON-RPC. It's just too unsafe and a lot of things can go sideways. But there will be some kind of query functionality in the future.
I'm sorry if this has been answered before.

I can't seem to find any methods for querying the AudioLibrary on SongTitle.
I wrote an addon that searches the library for songs matching a specific title.
(LastFMPlaylistGenerator). I solve this today by using the HTTP api queryMusicDatabase.

Will the JSPN RPC be extended to support these kinds of queries?


- Montellese - 2012-02-13

Yes the most likely implementation will be to allow to provide queries in a similar way XBMC allows to define smartplaylists. So you will send a request to VideoLibrary.GetMovies and one of the parameters will be "filter" and it will take some kind of object which might contain something like
Code:
{ "property": "title", "operator": "contains", "value": "Potter" }
which will then only list the movies which contain "Potter" in their title. Using the already existing SmartPlaylist implementation will enable JSON-RPC to provide a lot of flexibility without having to write a lot of new code and without running into a lot of new bugs (because smartplaylists are already well tested).