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.
Does JSON-RPC API/v6 still support TCP? And if so does it support notification over TCP, or is that a websocket only feature?
(2014-06-19, 12:10)sWORDs Wrote: [ -> ]Does JSON-RPC API/v6 still support TCP? And if so does it support notification over TCP, or is that a websocket only feature?

Why shouldn't it? TCP and websocket offer the same functionality, they just use a different protocol.
Because it's no longer mentioned in the v6 docs, but thanks!
It doesn't depend on the JSON-RPC API version. That's why it's not mentioned on the API version specific page but on the general JSON-RPC page.
I'm trying to get a list of all art for a xbmc source folder... info returns fine in a python IDE, but from within xbmc it doesn't work... any ideas?

python code:
Code:
json_query = uni('{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory": "%s", "media": "%s", "properties":["art"]}, "id": 1}' % ((path), media))
path = 'smb://192.168.0.0/TV/Orphan Black/Season 02'
media = 'video'

Output in xbmc:
Code:
19:49:03 T:22160   DEBUG: JSONRPC: Incoming request: {"jsonrpc":"2.0","method":"Files.GetDirectory","params":{"directory":"smb://192.168.0.0/TV/Orphan Black/Season 02","media":"video","properties":["art"]}, "id": 1}
19:49:03 T:22160   DEBUG: CUtil::GetMatchingSource: no matching source found for [smb://192.168.0.0/TV/Orphan Black/Season 02]

Source query to verify path is in white list:
Code:
"file": "smb://192.168.0.0/TV/",
            "label": "TV Shows"
Is it possible that you require usernamed and password for that specific samba share? Because those tend to confuse the CUtil::GetMatchingSource() logic.
(2014-06-30, 07:46)Montellese Wrote: [ -> ]Is it possible that you require usernamed and password for that specific samba share? Because those tend to confuse the CUtil::GetMatchingSource() logic.
Thanks for the responce...

the shares are accessible with or without login creds (Full access to everyone). Not sure why a external json request works and from within xbmc it doesn't.
Could you clarify with what you mean by "in a python IDE" and "from within xbmc"? Do you run the same python code but once as an external JSON-RPC client and once as an XBMC python addon? (sorry I'm not familiar with python)
Well I hope you changed the IP for the sample or use a special network mask, but 192.168.0.0 is not a valid IP with standard mask /24 (255.255.255.0) so i suppose curl or other internals in XBMC does not really well handle that.

Anyway it's not recommended to use .0 as IP as it's usually the network/subnetwork ID Wink
(2014-06-30, 10:11)Tolriq Wrote: [ -> ]Well I hope you changed the IP for the sample or use a special network mask, but 192.168.0.0 is not a valid IP with standard mask /24 (255.255.255.0) so i suppose curl or other internals in XBMC does not really well handle that.

Anyway it's not recommended to use .0 as IP as it's usually the network/subnetwork ID Wink

Lol, give me some credit... I just removed my addy info. (force of habit)

(2014-06-30, 09:03)Montellese Wrote: [ -> ]Could you clarify with what you mean by "in a python IDE" and "from within xbmc"? Do you run the same python code but once as an external JSON-RPC client and once as an XBMC python addon? (sorry I'm not familiar with python)

IDE is using http, xbmc python is using http, and if it fails internal executeJSONRPC. I have to go back and add some log entries so I can see which is being used at the time it fails... either way the same package returns on one and doesn't in the other.
I'll get back to you.

::Update::

Okay so both http and executeJSONRPC fail to find a match from within xbmc, but http works in IDE. Code works because every other json request from (IDE and XBMC) goes through except for this one.... I tried with or without password to samba.

::Update::

It's the oddest thing, I must be overlooking something.. because as I said before a different query goes through... but art parameter doesn't detect source.
I tried xbmc.validatePath and uniencode in hope that the directory string was the problem... but nothing.
(2014-06-30, 02:00)Lunatixz Wrote: [ -> ]I'm trying to get a list of all art for a xbmc source folder... info returns fine in a python IDE, but from within xbmc it doesn't work... any ideas?

python code:
Code:
json_query = uni('{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory": "%s", "media": "%s", "properties":["art"]}, "id": 1}' % ((path), media))
path = 'smb://192.168.0.0/TV/Orphan Black/Season 02'
media = 'video'

Output in xbmc:
Code:
19:49:03 T:22160   DEBUG: JSONRPC: Incoming request: {"jsonrpc":"2.0","method":"Files.GetDirectory","params":{"directory":"smb://192.168.0.0/TV/Orphan Black/Season 02","media":"video","properties":["art"]}, "id": 1}
19:49:03 T:22160   DEBUG: CUtil::GetMatchingSource: no matching source found for [smb://192.168.0.0/TV/Orphan Black/Season 02]

Source query to verify path is in white list:
Code:
"file": "smb://192.168.0.0/TV/",
            "label": "TV Shows"

You might try URL encoding the directory since it contains spaces (or at lease replace the spaces with %20). Might be an interesting data point.
(2014-06-30, 22:52)ben- Wrote: [ -> ]
(2014-06-30, 02:00)Lunatixz Wrote: [ -> ]I'm trying to get a list of all art for a xbmc source folder... info returns fine in a python IDE, but from within xbmc it doesn't work... any ideas?

python code:
Code:
json_query = uni('{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory": "%s", "media": "%s", "properties":["art"]}, "id": 1}' % ((path), media))
path = 'smb://192.168.0.0/TV/Orphan Black/Season 02'
media = 'video'

Output in xbmc:
Code:
19:49:03 T:22160   DEBUG: JSONRPC: Incoming request: {"jsonrpc":"2.0","method":"Files.GetDirectory","params":{"directory":"smb://192.168.0.0/TV/Orphan Black/Season 02","media":"video","properties":["art"]}, "id": 1}
19:49:03 T:22160   DEBUG: CUtil::GetMatchingSource: no matching source found for [smb://192.168.0.0/TV/Orphan Black/Season 02]

Source query to verify path is in white list:
Code:
"file": "smb://192.168.0.0/TV/",
            "label": "TV Shows"

You might try URL encoding the directory since it contains spaces (or at lease replace the spaces with %20). Might be an interesting data point.

No luck Sad

url encode
Code:
15:28:59 T:8812   DEBUG: JSONRPC: Incoming request: {"jsonrpc":"2.0","method":"Files.GetDirectory","params":{"directory":"smb%3A//192.168.0.1/TV/Rectify/Season%2001","media":"video","properties":["art"]},"id":1}
15:28:59 T:8812   DEBUG: CUtil::GetMatchingSource: no matching source found for [smb%3A/192.168.0.1/TV/Rectify/Season%2001]

replace space only:
Code:
15:31:48 T:4852   DEBUG: CUtil::GetMatchingSource: no matching source found for [smb://192.168.0.51/TV/Eagleheart/Season%2001]
15:31:48 T:4852   ERROR: XFILE::CDirectory::GetDirectory - Error getting smb://192.168.0.51/TV/Eagleheart/Season%2001
Still have not found a solution to my problem...

This results in a return from outside XBMC
Code:
http://localhost:8080/jsonrpc?request={"jsonrpc":"2.0","method":"Files.GetDirectory","params":{"directory":"smb://192.168.0.5/TV/Orphan Black/Season 02","media":"video","properties":["art"]},"id":10}

Same command in XBMC using both http or direct execjson doesn't work
Code:
22:27:09 T:3460   DEBUG: script.pseudotv.live-ChannelList: sendJSON command: {"jsonrpc":"2.0","method":"Files.GetDirectory","params":{"directory":"smb://192.168.0.5/TV/Once Upon a Time (2011)/Season 02","media":"video","properties":["art"]},"id":1}
22:27:09 T:3568   DEBUG: webserver: request received for /jsonrpc
22:27:09 T:3568   DEBUG: JSONRPC: Incoming request: {"jsonrpc":"2.0","method":"Files.GetDirectory","params":{"directory":"smb://192.168.0.5/TV/Once Upon a Time (2011)/Season 02","media":"video","properties":["art"]},"id":1}
22:27:09 T:3568   DEBUG: CUtil::GetMatchingSource: no matching source found for [smb://192.168.0.5/TV/Once Upon a Time (2011)/Season 02]

Any help would be appreciated... I've tried encoding the string, removing all samba authentication... is this a bug with MYSQL database?
Where can I find information on how XBMC blocks json requests? Are root directories covered? for example source smb://0.0.0.0/TV, does that give access to all sub folders?
XBMC gets the list of defined sources (based on sources.xml) and checks if one of them has a common base path with the path you passed in. But that shouldn't differ depending on where you sent it from.

Can you check your sources.xml?
(2014-07-04, 06:41)Montellese Wrote: [ -> ]XBMC gets the list of defined sources (based on sources.xml) and checks if one of them has a common base path with the path you passed in. But that shouldn't differ depending on where you sent it from.

Can you check your sources.xml?
Code:
<source>
            <name>TV Shows</name>
            <path pathversion="1">smb://192.168.0.5/TV/</path>
            <allowsharing>true</allowsharing>
        </source>

passwords.xml is empty because everything is open share...

BTW the source.xml is being path substituted and shared with multiple XBMC's