Need a bit of direction please
#1
Hello,

If I were to send a Json request in a script or addon that I want to work on, to query the video database, and I want Kodi to respond by printing the results of the query on the screen do I also have to create a window or will Kodi print the results anyway?

I honestly have tried to follow the many various tutorials on the sight and still have questions as to how to exactly establish a way to get feedback from Kodi when testing code. Did I mention that I am just learning Python? Does anyone have a standard script that can be used to test code that they would share?

Anyway, thanks in advance for any help.

Mark
Reply
#2
(2020-01-20, 15:38)mwkurt Wrote: If I were to send a Json request in a script or addon that I want to work on, to query the video database, and I want Kodi to respond by printing the results of the query on the screen do I also have to create a window or will Kodi print the results anyway?

The easiest way to get info out of Kodi when you are testing like this is to write it into the logfile.

import xbmc
def log(txt, mylevel=xbmc.LOGNOTICE):
    """
    Logs to Kodi's standard logfile
    """
    message = '%s : %s' % ("Your_addon_name", txt)
    xbmc.log(msg=message, level=mylevel)

json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "xbmc.GetInfoLabels", "params":{"labels": ["player.Filename"]}, "id": 1}' )
log("Raw json returned was %s" % json_query, xbmc.LOGINFO)
log("This is a test line to test logging")
Learning Linux the hard way !!
Reply
#3
(2020-01-20, 16:37)black_eagle Wrote:
(2020-01-20, 15:38)mwkurt Wrote: If I were to send a Json request in a script or addon that I want to work on, to query the video database, and I want Kodi to respond by printing the results of the query on the screen do I also have to create a window or will Kodi print the results anyway?

The easiest way to get info out of Kodi when you are testing like this is to write it into the logfile.

import xbmc
def log(txt, mylevel=xbmc.LOGNOTICE):
    """
    Logs to Kodi's standard logfile
    """
    message = '%s : %s' % ("Your_addon_name", txt)
    xbmc.log(msg=message, level=mylevel)

json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "xbmc.GetInfoLabels", "params":{"labels": ["player.Filename"]}, "id": 1}' )
log("Raw json returned was %s" % json_query, xbmc.LOGINFO)
log("This is a test line to test logging")
 

Thank you! I'll give it a try.

mark
Reply
#4
Hello again,

I am trying to figure this out. I have the following code that doesn't work in either Kodi 17 or 18. Could someone please have a look and maybe tell me what I am doing wrong?

# import the kodi python modules we are going to use
# see the kodi api docs to find out what functionality each module provides
import xbmc
import xbmcgui
import xbmcaddon
import json


def log(txt, mylevel=xbmc.LOGNOTICE):

    """
    Logs to Kodi's standard logfile
    """
    message = '%s : %s' % ("testwindow", txt)
    xbmc.log(msg=message, level=mylevel)

json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": {"filter": {"field": "playcount", "operator": "is", "value": "1"}, "properties" : ["file"], "id": "libMovies"}} ')    


log("Raw json returned was %s" % json_query, xbmc.LOGINFO)
log("This is a test line to test logging")


The only entry I get in the log is this: 16:31:45.022 T:6536  NOTICE: testwindow : This is a test line to test logging

Thank you,
Mark
Reply
 
Thread Rating:
  • 0 Vote(s) - 0 Average



Logout Mark Read Team Forum Stats Members Help
Need a bit of direction please00