JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC

  Thread Rating:
  • 7 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Tolriq Offline
Member+
Posts: 1,874
Joined: Jun 2009
Reputation: 53
Location: France
Post: #2881
Are you serious ? Smile

None of your sample does looks like those in this post.

Either you use a very recent Gotham and the params must looks like

"params": { "showhidewatched": true}

Or use the Player.Open with all params in the URL to bypass the bug.

Yatse 2 : Media Center Remote Control for Touch Screens
Yatse, the Xbmc Remote and Widgets for Android
find quote
claymic Offline
Member
Posts: 90
Joined: Apr 2012
Reputation: 2
Post: #2882
Sorry, i tested again in another xbmc version and its working:
Quote:{"jsonrpc":"2.0","method":"Addons.ExecuteAddon","params": { "addonid":"script.cavplus","params":["showhidewatched=true"]},"id":1}
Was a stupid mistake mine, i install a script with a different name in the addon.xml.
The other stupid mistake, i forgot to insert the "Key" in the params:
Quote:{"jsonrpc":"2.0","method":"Addons.ExecuteAddon","params": { "addonid":"script.cavplus","params":{"showhidewatched":"true"}},"id":1}
I believe that the code above will work too.
Clayton
find quote
claymic Offline
Member
Posts: 90
Joined: Apr 2012
Reputation: 2
Post: #2883
Buy the way Tolriq, i am always serious. I made my request based on the examples on the topic, of course, i put my "codes".
(This post was last modified: 2013-05-20 19:41 by claymic.)
find quote
MilhouseVH Offline
Posting Freak
Posts: 1,058
Joined: Jan 2011
Reputation: 21
Post: #2884
When retrieving sources with Files.GetSources, is there no way to obtain the "content" type for each source (ie. none, movies, music videos, tvshows)? This would be very useful.
find quote
claymic Offline
Member
Posts: 90
Joined: Apr 2012
Reputation: 2
Post: #2885
Hi
How can i insert several files at once in a Playlist using Playlist.Insert? Can i made a "chain" insert ?
find quote
Tolriq Offline
Member+
Posts: 1,874
Joined: Jun 2009
Reputation: 53
Location: France
Post: #2886
You can't you can only use batch commands. multiple json commands in a [] Smile

Be aware that the Team have said that in the future batch commands can be treated in any order and so that batch commands may in the future not insert the media in the correct order.

Leaving to no official long living solution but making lots of requests.

Yatse 2 : Media Center Remote Control for Touch Screens
Yatse, the Xbmc Remote and Widgets for Android
find quote
claymic Offline
Member
Posts: 90
Joined: Apr 2012
Reputation: 2
Post: #2887
(2013-05-24 13:03)Tolriq Wrote:  You can't you can only use batch commands. multiple json commands in a [] Smile

Be aware that the Team have said that in the future batch commands can be treated in any order and so that batch commands may in the future not insert the media in the correct order.

Leaving to no official long living solution but making lots of requests.

Very thanks Tolriq, i have this similar problem with my interface since i am using javascript. If i try to get all the episodes with a playcount = 0 and then insert in a playlist i will always have a out of order episodes numbers, since all my requests are asynchronous i have to use a setTimeout function, its not a good thing to use. For now i have to use a smartplaylist or a little script that i made.
The best for me to get this working (easily insert non watched episodes in a playlist) is using the script
Quote:def _unWatchedEpisodes(self):
log("playlist insert")
playlist = xbmc.PlayList(1)
playlist.clear()
tvshowid = int(self.UNWATCHEDEPISODES)
json_filter = '"filter":{"field": "playcount", "operator": "is", "value": "0"}'
json_params = '"params": {"sort": {"order": "ascending", "method": "episode"},"properties": ["episode", "season", "playcount","file"], "tvshowid":%s,%s }' % (tvshowid,json_filter)
json_request = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes",%s , "id": 1}'% json_params)
json_request = unicode(json_request, 'utf-8', errors='ignore')
json_response = simplejson.loads(json_request)
if json_response.has_key('result') and json_response['result'] != None and json_response['result'].has_key('episodes'):
for episodesList in json_response['result']['episodes']:
#if episodesList.has_key('playcount'):
playcount = int(episodesList['playcount'])
if playcount==0:
file = episodesList['file']
fileReplace = file.replace("\\","/")
episodeid = int(episodesList['episodeid'])
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Playlist.Add","params":{"playlistid":1, "item": {"episodeid": %d}}}'%episodeid)
#playlist.add(url=file)
If i use this i can insert all the non watched episodes at once and i will avoid to use another loop in my interface.
Maybe i am missing something and there is another easy way to do this directly in the JSON, i dont see in the Wiki, but maybe i am missing something.
Clayton
find quote
Fuzzwah Offline
Junior Member
Posts: 3
Joined: Jun 2013
Reputation: 0
Post: #2888
I'm running XBMC Frodo and having an issue trying to kick off playback of music from a m3u playlist using the JSON api.

I've confirmed that my playlist works fine when I start playing it via the GUI. But when I fire the following API call I get shown an empty black screen:

Quote:curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "file": "special://profile/playlists/music/QueensOfTheStoneAge-LikeClockwork.m3u" }}, "id": 1 }' http://localhost:8080/jsonrpc

Here is the output I see from my curl command:

Quote:xbian@xbian ~/.xbmc/userdata/playlists/music $ curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "file": "special://profile/playlists/music/QueensOfTheStoneAge-LikeClockwork.m3u" }}, "id": 1 }' http://localhost:8080/jsonrpc
* About to connect() to localhost port 8080 (#0)
* Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 8080 (#0)
> POST /jsonrpc HTTP/1.1
> User-Agent: curl/7.26.0
> Host: localhost:8080
> Accept: application/json
> Content-type: application/json
> Content-Length: 162
>
* upload completely sent off: 162 out of 162 bytes
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* additional stuff not fine transfer.c:1037: 0 0
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 200 OK
< Content-Length: 38
< Content-Type: application/json
< Date: Sun, 16 Jun 2013 15:01:25 GMT
<
* Connection #0 to host localhost left intact
{"id":1,"jsonrpc":"2.0","result":"OK"}* Closing connection #0

If I then check what is in the playlist I see that it is empty:

Quote:xbian@xbian ~/.xbmc/userdata/playlists/music $ curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{ "jsonrpc": "2.0", "method": "Playlist.GetItems", "params": { "playlistid": 0 }, "id": 1 }' http://localhost:8080/jsonrpc
* About to connect() to localhost port 8080 (#0)
* Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 8080 (#0)
> POST /jsonrpc HTTP/1.1
> User-Agent: curl/7.26.0
> Host: localhost:8080
> Accept: application/json
> Content-type: application/json
> Content-Length: 91
>
* upload completely sent off: 91 out of 91 bytes
* additional stuff not fine transfer.c:1037: 0 0
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 200 OK
< Content-Length: 74
< Content-Type: application/json
< Date: Sun, 16 Jun 2013 15:01:35 GMT
<
* Connection #0 to host localhost left intact
{"id":1,"jsonrpc":"2.0","result":{"limits":{"end":0,"start":0,"total":0}}}* Closing connection #0

If I make a smart playlist which contains the following:

Quote:<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<smartplaylist type="albums">
<name>QueensOfTheStoneAge-LikeClockwork</name>
<match>all</match>
<rule field="artist" operator="contains">
<value>Queens of the Stone Age</value>
</rule>
<rule field="year" operator="is">
<value>2013</value>
</rule>
</smartplaylist>

And launch it in the same way:

Quote:curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "file": "special://profile/playlists/music/QueensOfTheStoneAge-LikeClockwork.xsp" }}, "id": 1 }' http://localhost:8080/jsonrpc

Everything works as expected. The album playsback and I can see in the playlist:

Quote:{"id":1,"jsonrpc":"2.0","result":{"items":[{"id":7327,"label":"Keep Your Eyes Peeled","type":"song"},{"id":7328,"label":"I Sat By The Ocean","type":"song"},{"id":7329,"label":"The Vampyre Of Time And Memory","type":"song"},{"id":7330,"label":"If I Had A Tail","type":"song"},{"id":7331,"label":"My God Is The Sun","type":"song"},{"id":7332,"label":"Kalopsia","type":"song"},{"id":7333,"label":"Fairweather Friends","type":"song"},{"id":7334,"label":"Smooth Sailing","type":"song"},{"id":7335,"label":"I Appear Missing","type":"song"},{"id":7336,"label":"…Like Clockwork","type":"song"}],"limits":{"end":10,"start":0,"total":10}}}

My guess is that firing a Player.Open containing a m3u file is actually kicking off an image playback, rather than music playback. I base this on the output I see in my xbmc.log file:

Quote:08:08:12 T:3042213888 DEBUG: We have an error loading a picture!
08:08:12 T:3042213888 ERROR: CGUIWindowSlideShow::RenderErrorMessage - cant get label control!

For now I guess I am going to have to fix up all the tags in my albums and use smartplaylists. I wanted to avoid this as it is far easier for me to programatically generate m3u files.
find quote
Tolriq Offline
Member+
Posts: 1,874
Joined: Jun 2009
Reputation: 53
Location: France
Post: #2889
Well known still unresolved don't know why problem Smile

m3u are associated by default with pictures, simple solution :

You just need to add the following in your advanced settings in Xbmc installation
<pictureextensions>
<remove>.m3u</remove>
</pictureextensions>

Yatse 2 : Media Center Remote Control for Touch Screens
Yatse, the Xbmc Remote and Widgets for Android
find quote
Fuzzwah Offline
Junior Member
Posts: 3
Joined: Jun 2013
Reputation: 0
Post: #2890
(2013-06-16 17:12)Tolriq Wrote:  Well known still unresolved don't know why problem Smile

m3u are associated by default with pictures, simple solution :

You just need to add the following in your advanced settings in Xbmc installation
<pictureextensions>
<remove>.m3u</remove>
</pictureextensions>

Thanks! It is always so awesome when it is a 4 line fix for something you've been banging around head against a wall for a few days over.

My searching for a solution here on the forums was difficult because I couldn't just search for m3u (too short!).
find quote
Post Reply