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 - mikebzh44 - 2013-03-15

(2013-03-14, 16:02)mikebzh44 Wrote: Hi.

I'm trying to get Artist ID from Albums smart playlist.

I'm using this code :

Code:
_json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory": "%s", "media": "music", "properties": ["title", "description", "albumlabel", "artist", "artistid", "genre", "year", "thumbnail", "fanart", "rating", "playcount", "dateadded"]}, "id": 1}' %(PLAYLIST))

But artistid is not returned Sad
Any idea why ArtistID is not returned ?


AW: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Montellese - 2013-03-15

Retrieving artistid (and some other fields) requires extra logic which is currently not available in Files.GetDirectory.


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Milhouse - 2013-03-15

(2013-03-15, 13:01)Montellese Wrote: The notifications are sent to any client that has an open two-way connection (TCP socket or WebSocket) to the XBMC client sending the notifications.

Ok thanks again, the penny has finally dropped! For anyone wondering in future, this is a simple code example to initiate a video library scan using sockets and then wait until the OnScanFinished notification is received:

Code:
#!/usr/bin/python

import json, socket

def jsonWaitForScanFinished(id, method, params):
  print "Got: id %s, method %s, data %s" % (id, method, params)
  if method == "VideoLibrary.OnScanFinished": return False
  return True

def sendJSON(request, id, callback):
  TCP_IP = '127.0.0.1'
  TCP_PORT = 9090
  BUFFER_SIZE = 1024

  request['jsonrpc'] = '2.0'
  request['id'] =  id

  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.connect((TCP_IP, TCP_PORT))
  s.send(json.dumps(request))

  while 1:
    data = s.recv(BUFFER_SIZE)
#    print "received data:", data
    if callback:
      data = json.loads(data)
      id = data["id"] if "id" in data else None
      method = data["method"] if "method" in data else data["result"]
      params = data["params"] if "params" in data else None
      if not callback(id, method, params): break
  s.close()

sendJSON({"method": "VideoLibrary.Scan",
          "params": {"directory": "nfs://192.168.0.3/mnt/share/media/Video/TV Serials/Arrow/Season 1"}},
          1, jsonWaitForScanFinished)

which should return:

Code:
Got: id 1, method OK, data None
Got: id None, method VideoLibrary.OnScanStarted, data {u'data': None, u'sender': u'xbmc'}
Got: id None, method VideoLibrary.OnScanFinished, data {u'data': None, u'sender': u'xbmc'}



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

@Montellese:

Is there any reason why the Files.PrepareDownload method is not supported ("Method not found") while using TCP sockets?

Code:
{"jsonrpc": "2.0", "params": {"path": "image://nfs%3a%2f%2f192.168.0.3%2fmnt%2fshare%2fmedia%2fVideo%2fMovies%2fBad%20Santa%20(2003)%5bDirectors%20Cut%5d%5bDVDRip%5d-fanart.jpg/"}, "method": "Files.PrepareDownload", "id": "1"}
{"error":{"code":-32601,"message":"Method not found."},"id":"1","jsonrpc":"2.0"}

However the same request works fine over HTTP.

I realise that to download the image HTTP must be used (redirect), but I'm just wondering why this particular method is not working over sockets and thus has to be special cased (switching to HTTP for this method alone).


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

Files.PrepareDownload is only available on transport protocols that also support the download of the data itself.


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

Hello

Is it possible to get the exif-data of the current shown Picture with a json request.


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

Currently not.


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

(2013-02-26, 18:25)Montellese Wrote: For some reason yet unknown to me "lastmodified" is provided in localized datetime representation whereas all other dates are provided in SQL format as stated by Tolriq. Will have to check if there's a reason for it or not.

Just an additional note to this, through a bug found by a user. Not only is the date in the wrong format but also midnight time is shown with a single 0 instead of 00

Example output:
"lastmodified": 04-02-2013 0:04:39


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

I have a user who is not getting any thumbnails through Files.GetDirectory. Both art and thumbnail json return empty strings.
The thumbnails for the files have definitely been scanned in and are visible with VideoLibrary.GetMovies.
Looking at the users database I can see multiple thumnbails and fanart under the movies table columns c08 and c20.

The user is using XBMC 12.1 on a Windows machine.

Paths to the users files are network paths and are returned by Files.GetDirectory for example as //Network/films/thefilm.
In the database under movies (c22) it is listed as smb://Network/films/thefilm.

Any idea why the thumbnail or art is empty when using Files.GetDirectory?


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Milhouse - 2013-03-26

I'm retrieving streamdetails for tvshow episodes, but unless I've listed the episode in the GUI, or played back the episode, the streamdetails are always empty according to JSON.

Is there any way to force JSON to extract this information from the media (which I'm guessing is what the GUI does when you list episodes and wait for the SD/HD tags to appear), rather than return no details?


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

It's a problem with how/when we do the streamdetails extraction. Currently it's only done when listing an item in the GUI and it's done in the background to speed up the scanning of items into the library and the retrieval of the items to show in the GUI. There's no way to force that extraction right now and there's no easy solution, or at least every solution seems to have a drawback Undecided


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Milhouse - 2013-03-26

(2013-03-26, 15:28)Montellese Wrote: It's a problem with how/when we do the streamdetails extraction. Currently it's only done when listing an item in the GUI and it's done in the background to speed up the scanning of items into the library and the retrieval of the items to show in the GUI. There's no way to force that extraction right now and there's no easy solution, or at least every solution seems to have a drawback Undecided

Thanks, to give you some context theuni was asking about it in relation to a pre-loading script I've written. It would be quite nice if, at some point in the future, it were possible to have JSON pull this stuff in dynamically, even if it meant a short delay. Not getting any results for stream details just because the media hasn't been pulled up in the GUI, or played back at least once, despite having been scraped in, is really quite unfortunate (choosing my words carefully there! Wink)

Somewhat related is the missing cast artwork, which are also being pulled in dynamically by the GUI, but inaccessible via JSON - it's been heavily discussed on this trac ticket. Your input would be much appreciated! Smile


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - marcosreg - 2013-03-31

I am controlling my xbmc media center using the XBMC JSON FRODO network codes downloaded from iRule.
I am using the GO TO (MUSIC, VIDEOS, PICTURES) MENU, that are working fine.
I would like to have similar codes for MUSICVIDEO and TVSHOWS.
If I replace the menu name (video) on the command:
jsonrpc?request=%7B%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22GUI.ActivateWindow%22%2C%22params%22%3A%7B%22window%22%3A%22video%22%7D%2C%22id%22%3A%221%22%7D%7D
nothing happens.
Any help?
marcosreg


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

You need to pass in an additional parameter to tell the video window which node to open. IIRC the correct parameter for tvshows is "videodb://2/2" and for musicvideos it's "videodb://3/2".


RE: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - marcosreg - 2013-03-31

(2013-03-31, 10:24)Montellese Wrote: You need to pass in an additional parameter to tell the video window which node to open. IIRC the correct parameter for tvshows is "videodb://2/2" and for musicvideos it's "videodb://3/2".

Dear Montellese,
Thank you for your quick answer,
I changed the word video on the command on my previous post by:
"videodb://2/2" and also videodb://2/2 but nothing has changed.
If I change the word video by music it works normally, so I understand that the command replacement method I am using is OK.
Best regards,
Marcos