XBMC Community Forum
JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Printable Version

+- XBMC Community Forum (http://forum.xbmc.org)
+-- Forum: Development (/forumdisplay.php?fid=32)
+--- Forum: Development (/forumdisplay.php?fid=93)
+---- Forum: JSON-RPC (/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 - mzanetti - 2012-03-18 15:58

(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 09:44

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 04:34

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 09:07

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 09:40

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 00:08

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 03:09

(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 13:11

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 13:15

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 16:50

I see thank you.

Do you think this will be supported in the future?