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
joethefox Offline
Team-XBMC Member
Posts: 939
Joined: Nov 2010
Reputation: 15
Post: #1871
(2012-04-09 22:12)Mizaki Wrote:  Yep. I was going to try and do it manually for movies but I did other things instead Smile

like patching XBMC JSON API for VideoLibrary.GetMovies? Big Grin
(This post was last modified: 2012-04-10 12:29 by joethefox.)
find quote
Mizaki Offline
Fan
Posts: 663
Joined: Apr 2011
Reputation: 12
Post: #1872
I wish I could. I do JS badly at best Smile I was just going to take the genre from GetMovies and build the lists from that.

[Image: watched-clearlogo.jpg]
AWXi - Ajax web interface. Wiki
find quote
bradvido88 Offline
Member+
Posts: 736
Joined: Nov 2008
Reputation: 7
Location: MN
Post: #1873
In previous versions on XBMC (early Eden), when listing upnp:// directories (PlayOn is my upnp server in this example), xbmc would return the http:// path to the file in the "file" field.

Previously, i would get a http:// url:
Code:
http://127.0.0.1:63478/netflix-3fafe162-7ea8-4219-a789-c7367386b9d9/1-netflix-3fafe162-7ea8-4219-a789-c7367386b9d9.mpg

In Eden final, I get a upnp:// url
Code:
upnp://9306789e-2927-4a65-a08d-58a4c8337492/netflix%2d4620b511%2ded24%2d4921%2dae3a%2def450a4a07b3

Here is a sample from the xbmc log where i play a upnp:// path and it resolved it to http://
Code:
09:00:32 T:12672   DEBUG: CApplication::OnKey: return (f00d) pressed, action is Select
09:00:32 T:12672   DEBUG: CGUIWindowVideoBase::OnPlayMedia upnp://9306789e-2927-4a65-a08d-58a4c8337492/abc%2d1939a4d1%2d1a83%2d471e%2db529%2d90a690324a02
09:00:32 T:12672   DEBUG: CUPnPDirectory::GetResource - resource protocol info 'http-get:*:video/mpeg:DLNA.ORG_PN=MPEG_PS_NTSC;DLNA.ORG_OP=01;DLNA.ORG_CI=1;DLNA.ORG_FLAGS=257000​00000000000000000000000000'
09:00:32 T:12672   DEBUG: CPlayerCoreFactory::GetPlayers(http://127.0.0.1:63478/abc-1939a4d1-1a83-471e-b529-90a690324a02/1-abc-1939a4d1-1a83-471e-b529-90a690324a02.mpg)
09:00:32 T:12672  NOTICE: DVDPlayer: Opening: http://127.0.0.1:63478/abc-1939a4d1-1a83-471e-b529-90a690324a02/1-abc-1939a4d1-1a83-471e-b529-90a690324a02.mpg
The http:// is much more useful to me. Is there any way to resolve the upnp:// path into the http:// path that it references (using JSON-RPC)?
When I play the upnp:// file in XBMC, I can see from XBMC's log that it resolved the upnp:// path to a http:// path, then plays the http:// file.

XBMC.MyLibrary (add anything to the library)
ForTheLibrary (ForTheRecord & XBMC Library Integration)
SageTV & XBMC PVR Integration
Delete unused thumbs
(This post was last modified: 2012-04-11 16:04 by bradvido88.)
find quote
topfs2 Offline
Team-XBMC Developer
Posts: 3,825
Joined: Dec 2007
Reputation: 8
Post: #1874
(2012-04-11 15:51)bradvido88 Wrote:  In previous versions on XBMC (early Eden), when listing upnp:// directories (PlayOn is my upnp server in this example), xbmc would return the http:// path to the file in the "file" field.

Previously, i would get a http:// url:
Code:
http://127.0.0.1:63478/netflix-3fafe162-7ea8-4219-a789-c7367386b9d9/1-netflix-3fafe162-7ea8-4219-a789-c7367386b9d9.mpg

In Eden final, I get a upnp:// url
Code:
upnp://9306789e-2927-4a65-a08d-58a4c8337492/netflix%2d4620b511%2ded24%2d4921%2dae3a%2def450a4a07b3

Here is a sample from the xbmc log where i play a upnp:// path and it resolved it to http://
Code:
09:00:32 T:12672   DEBUG: CApplication::OnKey: return (f00d) pressed, action is Select
09:00:32 T:12672   DEBUG: CGUIWindowVideoBase::OnPlayMedia upnp://9306789e-2927-4a65-a08d-58a4c8337492/abc%2d1939a4d1%2d1a83%2d471e%2db529%2d90a690324a02
09:00:32 T:12672   DEBUG: CUPnPDirectory::GetResource - resource protocol info 'http-get:*:video/mpeg:DLNA.ORG_PN=MPEG_PS_NTSC;DLNA.ORG_OP=01;DLNA.ORG_CI=1;DLNA.ORG_FLAGS=257000​00000000000000000000000000'
09:00:32 T:12672   DEBUG: CPlayerCoreFactory::GetPlayers(http://127.0.0.1:63478/abc-1939a4d1-1a83-471e-b529-90a690324a02/1-abc-1939a4d1-1a83-471e-b529-90a690324a02.mpg)
09:00:32 T:12672  NOTICE: DVDPlayer: Opening: http://127.0.0.1:63478/abc-1939a4d1-1a83-471e-b529-90a690324a02/1-abc-1939a4d1-1a83-471e-b529-90a690324a02.mpg
The http:// is much more useful to me. Is there any way to resolve the upnp:// path into the http:// path that it references (using JSON-RPC)?
When I play the upnp:// file in XBMC, I can see from XBMC's log that it resolved the upnp:// path to a http:// path, then plays the http:// file.

Problem with returning http in the file object is due to the fact that in accordance with upnp that path could change so its loosy for a client to cache, the upnp path is much nicer as that forces xbmc to do the lookup and decide what protocol to use (a upnp path could end up in several transport options and we can choose which is best, http, rtsp, samba etc and with several transcoding options). I haven't followed xbmc code closely with upnp but I'm guessing this was an internal url change to allow for scanning upnp stuff into the database (as that had the problem before that the http changed).

I'm guessing you want to resolve the upnp url to a http one so you could stream it in your client without going through xbmc? One way to do that would be to actually ask the upnp device about the transports, i.e. you ask it what we ask it. The downside being that you need to be on the same network (which you had to be before too) and that you need to talk upnp (which is actually just xml and http), the biggest problem is that you need to resolve the uuid into an IP, for that you'd need to do an ssdp lookup which requires more than http IIRC.

As for letting xbmc doing this resolve I'm not sure if it would be good, one could append different alternative file paths but knowing that they aren't garantued, kindof how upnp does with the transport. Or have a method you can call to xbmc to do that resolve (might be nicer to just do it in the initial file object fetch.)

EDIT: I guess I'm saying that you'd need to request that our internal filesystem directory calls provides alternative filepaths to the object, much as how upnp does. That way the jsonrpc could report those also. Not sure if we want to add that to our filesystem or not but could be worth a feature request. Might be nice for addon creators to be able to provide alternatives (as with stream details as quality etc.)

If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


[Image: badge.gif]

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
(This post was last modified: 2012-04-11 16:31 by topfs2.)
find quote
bradvido88 Offline
Member+
Posts: 736
Joined: Nov 2008
Reputation: 7
Location: MN
Post: #1875
(2012-04-11 16:26)topfs2 Wrote:  As for letting xbmc doing this resolve I'm not sure if it would be good, one could append different alternative file paths but knowing that they aren't garantued, kindof how upnp does with the transport. Or have a method you can call to xbmc to do that resolve (might be nicer to just do it in the initial file object fetch.)

Yes, I agree with what you said about how the http:// urls can change, but I'm trying to track if a particular upnp file has been watched, and XBMC stores watched status based on the http:// file path of the video, not the upnp:// path.
So, maybe that it a problem in and of itself for the way XBMC tracks upnp files in its database.

Still, it would be very useful to have a resolve method that will use XBMC's internal methods to change the upnp:// path to a tangible video file path (or just do this in the initial file object fetch).

XBMC.MyLibrary (add anything to the library)
ForTheLibrary (ForTheRecord & XBMC Library Integration)
SageTV & XBMC PVR Integration
Delete unused thumbs
find quote
bradvido88 Offline
Member+
Posts: 736
Joined: Nov 2008
Reputation: 7
Location: MN
Post: #1876
On another topic, regarding the JSON-RPC announcements.
Is there any way to find out what file was started when Player.OnPlay is sent? From what I've seen (in Eden Final), it does not give any indication about the file being played.

Sample announcement:
Code:
{"method":"Player.OnPlay","params":{"sender":"xbmc","data":{"title":"","player":{"speed":1,"playerid":1},"item":{"type":"movie"}}},"jsonrpc":"2.0"}
\


Edit:
I am using Player.GetItem to get the file for the currently playing item,which works well enough.

However, if I am playing a .strm (a playlist), is there any way to get the name of the strm/playlist instead of the currently playing file?

I couldn't seem to find a way to get the name of the currently playing playlist

XBMC.MyLibrary (add anything to the library)
ForTheLibrary (ForTheRecord & XBMC Library Integration)
SageTV & XBMC PVR Integration
Delete unused thumbs
(This post was last modified: 2012-04-12 01:31 by bradvido88.)
find quote
Montellese Online
Team-XBMC Developer
Posts: 2,790
Joined: Jan 2009
Reputation: 20
Location: Switzerland
Post: #1877
(2012-04-03 18:12)Mizaki Wrote:  I see there are some PRs which look good. I didn't see anything about playlists. Is that still on your radar?
As soon as someone has improved/reworked the playlist handling in XBMC itself, yes.

(2012-04-03 18:12)Mizaki Wrote:  The other thing (which I'll make a feature request for if you think it's doable) is getting the library in small chunks (5, 10 etc. items). As I've mentioned before people with low(er) powered PCs with large libraries can take a long (I'm guessing 15 seconds +) time to retrieve. I guess the DB query is the thing that takes the time so the only way to grab small chunks would be without sorting. Without sorting though it does limit how useful it would be.

I'm wondering if you think it's even possible atm?
This will be possible once I have finished my work on extended filtering which will be possible by providing smartplaylist filters in JSON-RPC requests. XBMC's smartplaylists provide the possibility to already do the limitting and sorting in the database and not after having retrieved the whole list (which JSON-RPC does right now).

(2012-04-04 20:47)joethefox Wrote:  Hi all,
there a remote procedure call to obtain what user has chosen for the "Ignore article when sorting"?

Settings>Appearance>File Lists>Ignore article when sorting (e.g. "the") : ON/OFF
No JSON-RPC does not provide access to any (GUI) settings (yet).

(2012-04-08 08:36)N3MIS15 Wrote:  Montellese, are you planning on including thumbnail/fanart params to your FooLibrary.Set pull request? If so, are you also planning on making the remote images stored in the database available thru jsonrpc?
My current implementation doesn't because I have to work myself into the stuff jmarshall has done on the thumbnail/image caching so the first implementation will probably not support setting the thumbnail but later on it might be added. Not sure yet though in what way because uploading images through JSON-RPC is (currently) not possible.

(2012-04-08 08:36)N3MIS15 Wrote:  Also, while on the subject. I have been unable to change a movie set. I can only append, is there a way to replace or remove? Its quite possible im just doing something wrong, im fairly new to coding.
JSON-RPC doesn't allow you to change anything right now in XBMC's library/database.

(2012-04-09 06:37)doozer Wrote:  I'm using Playlist.GetItems to pull down the currently queued songs. This is working fine. I just tried doing a similar thing to get a list of queued movies. This also works, but I don't seem to be able to include the "movieid" value in the list. Is there a way to obtain a list of queued movies and their corresponding Library id?
Hm the "id" property should be returned independant of whether it's a video or audio playlist. I just gave it a try and I got a valid "id" property and the "type" property contains "movie" so that seems to work fine.

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

[Image: badge.gif]
find quote
N3MIS15 Offline
Fan
Posts: 464
Joined: Jul 2010
Reputation: 12
Location: Melbourne, VIC
Post: #1878
(2012-04-12 12:06)Montellese Wrote:  JSON-RPC doesn't allow you to change anything right now in XBMC's library/database.

I was refering to the FooLibrary.Set pull request. i built a copy of xbmc eden with those changes and I have been able to change everything but movie sets. I can only append them.
find quote
joethefox Offline
Team-XBMC Member
Posts: 939
Joined: Nov 2010
Reputation: 15
Post: #1879
(2012-04-12 12:06)Montellese Wrote:  
(2012-04-04 20:47)joethefox Wrote:  Hi all,
there a remote procedure call to obtain what user has chosen for the "Ignore article when sorting"?

Settings>Appearance>File Lists>Ignore article when sorting (e.g. "the") : ON/OFF
No JSON-RPC does not provide access to any (GUI) settings (yet).
Waiting for this, could be feasible to obtain an automatic choice (so the GUI choice) for the ignorearticle if you create the List.Sort object without the ignorearticle property?
(This post was last modified: 2012-04-12 12:48 by joethefox.)
find quote
Montellese Online
Team-XBMC Developer
Posts: 2,790
Joined: Jan 2009
Reputation: 20
Location: Switzerland
Post: #1880
(2012-04-11 19:39)bradvido88 Wrote:  On another topic, regarding the JSON-RPC announcements.
Is there any way to find out what file was started when Player.OnPlay is sent? From what I've seen (in Eden Final), it does not give any indication about the file being played.

Sample announcement:
Code:
{"method":"Player.OnPlay","params":{"sender":"xbmc","data":{"title":"","player":{"speed":1,"playerid":1},"item":{"type":"movie"}}},"jsonrpc":"2.0"}
Yup you are right. If JSON-RPC notices that the currently playing item is not in the database it tries to retrieve things like title etc but it only sends out information that is not empty. It might make sense to add the "file" property if there is no database ID.

(2012-04-11 19:39)bradvido88 Wrote:  Edit:
I am using Player.GetItem to get the file for the currently playing item,which works well enough.

However, if I am playing a .strm (a playlist), is there any way to get the name of the strm/playlist instead of the currently playing file?

I couldn't seem to find a way to get the name of the currently playing playlist
I don't really know how strm files work but if they work similar to m3u files then XBMC does not remember that filename after it has loaded the actually playable files from it.

(2012-04-12 12:27)N3MIS15 Wrote:  
(2012-04-12 12:06)Montellese Wrote:  JSON-RPC doesn't allow you to change anything right now in XBMC's library/database.

I was refering to the FooLibrary.Set pull request. i built a copy of xbmc eden with those changes and I have been able to change everything but movie sets. I can only append them.
Ah right now I understand. Well the problem is that you aren't really able to do any of those things in XBMC either. XBMC itself doesn't even allow you to manually add items to a set. As long as that support is missing in XBMC itself it will most likely be missing in JSON-RPC as well.

(2012-04-12 12:48)joethefox Wrote:  
(2012-04-12 12:06)Montellese Wrote:  No JSON-RPC does not provide access to any (GUI) settings (yet).
Waiting for this, could be feasible to obtain an automatic choice (so the GUI choice) for the ignorearticle if you create the List.Sort object without the ignorearticle property?
No, JSON-RPC listing/sorting does not care about the GUI setting for irgnoring articles in sorting.

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

[Image: badge.gif]
find quote
Post Reply