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)



RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-03-16

JSON-RPC does not support any recursive behaviour for directories etc (yet). So if you point it at a directory that only contains sub-directories it won't find anything useful in that directory because it doesn't look into the subdirectories.
(2012-03-16, 23:02)MindTooth Wrote: Response:
Code:
{"id":1,"jsonrpc":"2.0","result":{"limits":{"end":0,"start":0,"total":0}}}

Code:
{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": { "properties": ["title"], "tvshowid": 50}, "id": 1}
Gives the same response above.

Code:
{"jsonrpc" : "2.0", "method" : "VideoLibrary.GetTVShows", "id" : 1}
Gives:
Code:
{"id":1,"jsonrpc":"2.0","result":{"limits":{"end":51,"start":0,"total":51},"tvshows":[{"label":"A History of Scotland","tvshowid":65},{"label":"American Chopper: Senior vs Junior","tvshowid":64},{"label":"Archer (2009)","tvshowid":63},{"label":"Being Human","tvshowid":61},{"label":"Boardwalk Empire","tvshowid":60},{"label":"Breaking Bad","tvshowid":59},{"label":"Breakout Kings","tvshowid":57},{"label":"British Masters","tvshowid":70},{"label":"Californication","tvshowid":56},{"label":"Castle (2009)","tvshowid":54},{"label":"Cougar Town","tvshowid":51},{"label":"Dexter","tvshowid":50},{"label":"Face Off","tvshowid":48},{"label":"Fringe","tvshowid":45},{"label":"Game of Thrones","tvshowid":44},{"label":"Halo Legends","tvshowid":42},{"label":"Hawaii Five-0 (2010)","tvshowid":41},{"label":"Homeland","tvshowid":138},{"label":"House","tvshowid":40},{"label":"How the States Got Their Shapes","tvshowid":84},{"label":"Justified","tvshowid":36},{"label":"Leverage","tvshowid":35},{"label":"Lost Girl","tvshowid":33},{"label":"Merlin (2008)","tvshowid":32},{"label":"Monty Python: Almost The Truth (The Lawyer's Cut)","tvshowid":31},{"label":"Nikita","tvshowid":29},{"label":"Psych","tvshowid":26},{"label":"Republic of Doyle","tvshowid":25},{"label":"Restoration Home","tvshowid":24},{"label":"Richard Hammond's Journey To...","tvshowid":67},{"label":"Ringer","tvshowid":200},{"label":"Rising Rebuilding Ground Zero","tvshowid":95},{"label":"Royal Pains","tvshowid":23},{"label":"Sons of Anarchy","tvshowid":96},{"label":"Supernatural","tvshowid":20},{"label":"Teen Wolf","tvshowid":19},{"label":"The Big Bang Theory","tvshowid":18},{"label":"The Borgias","tvshowid":17},{"label":"The Impressionists Painting and Revolution","tvshowid":97},{"label":"The Killing (2011)","tvshowid":15},{"label":"The Mentalist","tvshowid":14},{"label":"The Restoration Man","tvshowid":201},{"label":"The Secret Circle","tvshowid":195},{"label":"The Vampire Diaries","tvshowid":11},{"label":"The Walking Dead","tvshowid":10},{"label":"Top Gear","tvshowid":8},{"label":"Transformers","tvshowid":7},{"label":"Warehouse 13","tvshowid":5},{"label":"Weeds","tvshowid":4},{"label":"White Collar","tvshowid":3},{"label":"XIII (2011)","tvshowid":2}]}}

Hm that's rather odd and would suggest that there are no episodes for the TV show with ID 50 (i.e. Dexter in your case). Do you see any episodes belonging to Dexter in the tv show view of XBMC?


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Millencolin007 - 2012-03-17

Hi,

I was trying to stream files using the vfs path but it looks like my "range request" headers are ignored since it returns the full file every time (tested on Eden RC2 and Eden Beta 1). Unfortunately it is not possible to seek inside a music file or movie without the support of range requests. Is this going to be supported in the future?

First Request
Code:
GET /vfs/E%3a%2fMusic%2fMichael%20Jackson%20%2d%20Number%20Ones%20%2d%202003%2f03%20%2d%20Michael%20Jackson%20%2d%20Billie%20Jean%2emp3 HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/5.0(iPad; U; CPU OS 4_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8F191 Safari/6533.18.52.3.7)

HTTP/1.1 200 OK
Content-Length: 7047088
Expires: Sun, 18 Mar 2012 09:50:02 GMT
Content-Type: audio/mpeg3
Date: Sat, 17 Mar 2012 09:50:02 GMT

ID3...... TIT2.......Billie JeanTPE1.......Michael JacksonTALB.......Number OnesTYER.......2003TRCK.......03TCON.......(13)TLEN....@..293000.................................d................................Info......+..k......

Range Request
Code:
GET /vfs/E%3a%2fMusic%2fMichael%20Jackson%20%2d%20Number%20Ones%20%2d%202003%2f03%20%2d%20Michael%20Jackson%20%2d%20Billie%20Jean%2emp3 HTTP/1.1
Host: 127.0.0.1
Range: bytes=4423423-
User-Agent: Mozilla/5.0(iPad; U; CPU OS 4_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8F191 Safari/6533.18.52.3.7)

HTTP/1.1 200 OK
Content-Length: 7047088
Expires: Sun, 18 Mar 2012 09:50:06 GMT
Content-Type: audio/mpeg3
Date: Sat, 17 Mar 2012 09:50:06 GMT

ID3...... TIT2.......Billie JeanTPE1.......Michael JacksonTALB.......Number OnesTYER.......2003TRCK.......03TCON.......(13)TLEN....@..293000.................................d................................Info......+..k......



RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-03-18

(2012-03-17, 12:28)Millencolin007 Wrote: Hi,

I was trying to stream files using the vfs path but it looks like my "range request" headers are ignored since it returns the full file every time (tested on Eden RC2 and Eden Beta 1). Unfortunately it is not possible to seek inside a music file or movie without the support of range requests. Is this going to be supported in the future?

Uhm what does this have to do with JSON-RPC? Sure it has to do with the webserver but not with JSON-RPC. Please create a feature request ticket on Trac.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Millencolin007 - 2012-03-18

Oh, I didn't know that the vfs is not part of json-rpc but from the webserver module. After a bit of searching I found a ticket describing the same issue at http://trac.xbmc.org/ticket/11524 so I won't open another one


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-03-18

The VFS is part of XBMC and it is exposed through the webserver and it can also be used through JSON-RPC but JSON-RPC currently doesn't support any direct file access/streaming so it's a new feature for the webserver.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - mzanetti - 2012-03-18

(2012-03-16, 00:17)Montellese Wrote: It returns Invalid Parameter if there is no valid file in the directory you provided does not contain any playable files.

Hmm... It returns also Invalid Parameter for directories which contain valid images (used to create a slideshow with pictures).

Could it be that a few months back the Playlist.Add has been working in a recursive mode? I feel so certain that this has been working when I implemented the Files stuff in my client...

Thanks


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-03-19

The only place where you get recursive behaviour in JSON-RPC is if you provide the "recursive" parameter in Player.Open for slideshows.

Hm the picture/slideshow handling in the Playlist namespace is a bit of a hack because XBMC handles slideshows completely different than video or audio playlists. Furthermore there's no picture database as there is for audio and video so it might be that JSON-RPC behaves a little different when it comes to pictures/images in the Playlist namespace.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - grifter - 2012-03-20

I think I may have uncovered a JSON bug

if I want to play a video file named XYZ.JPG i send the command

Code:
{"jsonrpc": "2.0", "method": "Playlist.Add","params": {"playlistid": 1, "item": {"file" : "smb://homestorage/XYZ.JPG"}}, "id": 1}
and it starts to play

But if I try to play the following Top Gear episode that contains a "ü" in the filename it fails.
Code:
{"jsonrpc": "2.0", "method": "Playlist.Add","params": {"playlistid": 1, "item": {"file" : "smb://homestorage/Array2/Movies/RSS/Top Gear/Season 06/Top Gear - 6x07 - Ford Transit at Nürburgring.avi"}}, "id": 1}

tried this next to see if I could escape the "ü"
Code:
{"jsonrpc": "2.0", "method": "Playlist.Add","params": {"playlistid": 1, "item": {"file" : "smb://homestorage/Array2/Movies/RSS/Top Gear/Season 06/Top Gear - 6x07 - Ford Transit at N\ürburgring.avi"}}, "id": 1}

also doesn't work, however renaming the file to remove the "ü" and it works.

I have also recreated this on a few other files containing similar characters.

"Top Gear - 7x04 - £10.mpg"
"¡Rob! - 1x01 - Pilot.mpg"

Thoughts?



RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - mikebzh44 - 2012-03-20

I think you should unicode your filename :

Code:
filename = unicode("smb://homestorage/Array2/Movies/RSS/Top Gear/Season 06/Top Gear - 6x07 - Ford Transit at Nürburgring.avi", 'utf-8', errors='ignore')



RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-03-20

As mikebzh44 JSON-RPC is completely UTF-8 based so that's what you should send.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - mzanetti - 2012-03-21

While it is true that escaping/encoding the filenames properly leads mostly to success, I also have noticed some strange behavior if the files are located on a mounted share which uses a different encoding that then the machine xbmc runs on. For example I had issues that local files (on the xbmc host) with special characters have been working but remote ones (on a mounted share) not. After UTF-8 encoding my commands I only could open the remote ones, but not the local ones any more.

I have also reported a bug for this back then: http://trac.xbmc.org/ticket/11634

@grifter: It might help if you add your findings there so we might can see a pattern which makes it easier to find the issue.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - grifter - 2012-03-21

(2012-03-20, 04:34)grifter Wrote: I think I may have uncovered a JSON bug

if I want to play a video file named XYZ.JPG i send the command

Code:
{"jsonrpc": "2.0", "method": "Playlist.Add","params": {"playlistid": 1, "item": {"file" : "smb://homestorage/XYZ.JPG"}}, "id": 1}
and it starts to play

But if I try to play the following Top Gear episode that contains a "ü" in the filename it fails.
Code:
{"jsonrpc": "2.0", "method": "Playlist.Add","params": {"playlistid": 1, "item": {"file" : "smb://homestorage/Array2/Movies/RSS/Top Gear/Season 06/Top Gear - 6x07 - Ford Transit at Nürburgring.avi"}}, "id": 1}

tried this next to see if I could escape the "ü"
Code:
{"jsonrpc": "2.0", "method": "Playlist.Add","params": {"playlistid": 1, "item": {"file" : "smb://homestorage/Array2/Movies/RSS/Top Gear/Season 06/Top Gear - 6x07 - Ford Transit at N\ürburgring.avi"}}, "id": 1}

also doesn't work, however renaming the file to remove the "ü" and it works.

I have also recreated this on a few other files containing similar characters.

"Top Gear - 7x04 - £10.mpg"
"¡Rob! - 1x01 - Pilot.mpg"

Thoughts?

Thanks to Mzanetti, Montellese and Mikebzh44, UTF-8 did the trick!

@mzanetti, I have re-tested the 3 files I have, loading them off of a Windows UNC path from an Apple TV running XBMC and they all work fine. I will try moving small files with the same filenames local to the Apple TV and test again. I also have a few windows XBMC machines kicking around the house I can test. If I find any problems I will post them to http://trac.xbmc.org/ticket/11634

Thanks again to all that replied.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Juan_Garcia - 2012-03-22

Hello. First, sorry for my poor english.

I´m thinking to make a app for iPhone/iPad, where you navigate for internet with a embebbed browser... when the app detect a video´s link in current web page, let to the user to send the url to XBMC (I don´t want airplay).

Besides the url I want to send the session (cookie header) too for autenthication sites (XBMC should be in the same intranet), it´s possible to do it with current api? or maybe I need to make a plugin first?

Thanks


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2012-03-22

You can send any URL to XBMC through Player.Open using the "file" property of the "item" parameter
Code:
{ "jsonrpc": "2.0", "method:" Player.Open", "params": { "item": { "file": "http://www.xyz.com/foo?bar" } }, "id": 1 }
but providing a session/cookie/context isn't possible.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Juan_Garcia - 2012-03-22

I see thank you.

Do you think this will be supported in the future?