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.
Tolriq Wrote:After some tests i can confirm that System.GetInfoLabels is good for getting currently informations even with empty playlist :p
Even permit to send one less request for getting the seekposition Smile [...]
THX for the tip Smile
But it's too bad that the cover-string is always empty ("MusicPlayer.Cover", "VideoPlayer.Cover") and that there is no information available about the season- or episode-number or if the player is paused Wink
Well since the infolabels returns "" on no data, you can do a first request to get all audio and video data, this will let you know wich player is active Smile

Then a xxxplayer.state gives the states.

This is bad because asking for more data than needed in the first request but it permits to go from 4 request to 2 to have all the needed informations.
This seems to be a good compromise.

For the thumb / fanart it's really easy to get them from the file name.
And since in you case i don't think user can clear the playlist before you have made the first data get you can use the xxxplaylist.getitems to get fanart / thumb and player state instead of player.state

(Well if suppose that if the media goes to the second one after the clear it won't work Wink but can't test since don't use that).

Edit : Wiki is not complete since you can find in confluence skin that VideoPlayer.Season and VideoPlayer.episode exists Smile
For the paused there is Player.Paused but needs to be called with the System.GetInfoBooleans too bad the bool can"t be get with the other functions, still needs to make 2 requests Sad But well it's better than 4 Smile
Hehe, a few minutes ago i wrote sth. similar to yours Big Grin
I use GetInfoLabels to decide which player is active, get Volume, get Shuffle-Status etc and use the playlist's GetItems-Method to get the thumbs, player-status and episode-info (if playlist is not empty).
Although it would be better if these info were also available via info-Methods Wink

EDIT: Perfect, "VideoPlayer.Season" and "VideoPlayer.Episode" works well. But as you mentioned already: 2 requests is minimum Wink
Well another regression, in beta 3 even the httapi GetCurrentlyPlaying() does no more return correct information for movies not started from the media library view.

Seems no more choice than using getinfolabels this will break some remote software i think.

Edit : Well i speak too quick Sad Even GetInfoLabels does no more works on Beta 3 (perhaps it's normal since GetCurrentlyPlaying use this i think).

This is a very annoying problem, since using httpapi you usually play media by file name and if you do so you wont get the data back.

Edit 2 : Strange, but if using the json "XBMC.Play" with param file="" it works, so i think that the bug can be corrected i think.
Because even the skins don't have information if starting movie in file mode (that some users still uses)
Is there a way to add an array of items to playlist ?

Because audioplaylist.add by songid one by one is just really slow when dealing with large lists.

And two small remark, AudioPlaylist.GetItems always returns fanart url even if the file (the fanart) does not exists

And AudioPlaylist.GetItems returns thumbs if songs started by songid but not if started with file (but always fanart). (same bug as previous post i suppose).
I just noticed that when I call Player.GetTimeMS right after I received a PlaybackPaused announcement it contains
Code:
"paused": true,
"playing": true

Do I need to wait a certain time before I call GetTimeMS or is the "playing" value never adjusted?

EDIT: Something similar happens when calling GetTimeMS right after receiving a PlaybackSeek announcement. The value of the current position still returns the position of playback BEFORE seeking.

Furthermore when stopping a paused playback (for reproduction: start playing a song, pause it and then stop it completely) the PlaybackStopped announcement is sent twice.
Hmm, well info stuff is abit hacked together. At any rate, I'd say that those that return busy should probably not return until data is actually available.
Yes because the Busy is translated to the user locale so hard to base on the text to know if needs to retry Smile

Any idea for the regression in Beta 3 about no more getting plot or such things from Json or HTTPAPI if files are started from httpapi or json (sometimes only) filename or the xbmc file mode ? (No data in getitems, getinfolabels and httpapi getcurrentlyplaying)
Hi,

I've been porting my tool (XWMM) to JsonRPC for a while now and it works like a charm. You guys did a great job.

As a fan I have few additional requests Big Grin

- Files.GetSources does not give the USB drives
- How can I use Files.Download to copy files to the XBMC machine ?
- Can ScanForContent take a directory as parameter, to specefy where to start the scan ?
- Would it be possible to add an equivalent to "refresh item" and have JsonRPC reply with the list of possible titles to choose from (don't know how difficult it would be)?


Also, I know that JsonRPC will not support library manipulation, what would be the suggestion to do that. Should I write my own code or python scripts and execute them with the HTTP execBuiltIn function?

Thanks
slash Wrote:Hi,

I've been porting my tool (XWMM) to JsonRPC for a while now and it works like a charm. You guys did a great job.

As a fan I have few additional requests Big Grin

- Files.GetSources does not give the USB drives
- How can I use Files.Download to copy files to the XBMC machine ?
- Can ScanForContent take a directory as parameter, to specefy where to start the scan ?
- Would it be possible to add an equivalent to "refresh item" and have JsonRPC reply with the list of possible titles to choose from (don't know how difficult it would be)?


Also, I know that JsonRPC will not support library manipulation, what would be the suggestion to do that. Should I write my own code or python scripts and execute them with the HTTP execBuiltIn function?

Thanks

GetSources probably should give tem, via parameter to aggregate autoadded sources (such as optical and dvd) probably.

Files.Download will just give you direction on how to download based on your current transport. Http will just give you a URL you can access, TCP at some point might give you a port and so on.

ScanForContent won't take a parameter of path since its hard / impossible to make proper (other thread regarding this matter).

Refresh might be interesting, not sure how to code it up but definatly a nice thing if possible. Seems perfect to be able to refresh scanned items via the web interface.

As for library manipulations, I'd say its appropriate to do them via httpapi for the time being. It is planned to be doable via jsonrpc at some point. Probably needs the security addition (mostly to display them in gui, a dialog that asks if client foo can have these permissions etc.).

Please add tickets and cc me so we don't forget them.
Well, i just finished making my own mobile theme, and then i read this.

A new api Big Grin.

What are the commands for this api? So i can upgrade the script and release it.

@ Slash

Through the old http api i had a search function for searching the music DB

Code:
<?php
function xbox_sql($sql){
    $sql = str_replace(" ","%20",$sql);
    $sql = file_get_contents('http://'. XBOXIP .'/xbmcCmds/xbmcHttp?command=querymusicdatabase('.$sql.')');
    $sql = str_replace('</html>','',$sql);
    $sql = str_replace('</recordset>','',$sql);
    //$sql = explode('<li>',$sql);
    return $sql;
}


if(isset($_GET['search'])){
    $search = $_GET['search'];
    echo 'Search results for: <b>'.$search.'</b>';
    //$query = "select strArtist, strTitle, strPath, strFileName,iTimesPlayed, idSong from songview where strTitle like '%%$search%%' or strArtist like '%%$search%' or strFileName like '%%$search%' Order by iTimesPlayed DESC LIMIT 50";
    $query = "select strArtist,strTitle,strPath,strFileName,iTimesPlayed,idSong from song left join path on song.idPath = path.idPath left join artist on song.idArtist=artist.idArtist where  strTitle like '%$search%' OR strArtist like '%$search%' ORDER BY iTimesPlayed LIMIT 50";
    $search = xbox_sql($query);
$results = xbox_make_array($search); //Converts the found songs to an array
}
?>
Hey Guys, are there any support for sending simple key presses thru jsonrpc?
Hey guys

Can someone help me with the Playlist.GetItems() call?

JSONRPC.Introspect() returned this:
Code:
Playlist.GetItems [ReadData]: Retrieve items in the playlist. Parameter example {"playlist": "music" }. playlist optional.

So I tried the following which both return an error "Invalid params":
Code:
{ "jsonrpc": "2.0", "method": "Playlist.GetItems", "id": 3 }

{ "jsonrpc": "2.0", "method": "Playlist.GetItems", "params": { "playlist": "music" }, "id": 3 }

So is the "playlist" parameter not optional after all? What should I put in as a value for "playlist"? Is this some kind of enum like with Files.GetSources() or is this just a user-defined name? If so how can I access the currently active playlist without knowing its name?

Thanks a lot.
hello_man Wrote:Hey Guys, are there any support for sending simple key presses thru jsonrpc?

Short answer, no. Its been asked multiple times, search this thread for bigger explanation.
Montellese Wrote:Hey guys

Can someone help me with the Playlist.GetItems() call?

JSONRPC.Introspect() returned this:
Code:
Playlist.GetItems [ReadData]: Retrieve items in the playlist. Parameter example {"playlist": "music" }. playlist optional.

So I tried the following which both return an error "Invalid params":
Code:
{ "jsonrpc": "2.0", "method": "Playlist.GetItems", "id": 3 }

{ "jsonrpc": "2.0", "method": "Playlist.GetItems", "params": { "playlist": "music" }, "id": 3 }

So is the "playlist" parameter not optional after all? What should I put in as a value for "playlist"? Is this some kind of enum like with Files.GetSources() or is this just a user-defined name? If so how can I access the currently active playlist without knowing its name?

Thanks a lot.

Hmm, seems like introspect is wrong. will look into it