Json Call to remote instance
#16
Schumi,

I think that module I linked to previously allows for authentication too.

EDIT:
The XBMC module that I linked to has this line:
Code:
class XBMC(object):
  """XBMC client"""
  def __init__(self, url, username='xbmc', password='xbmc'):
...
So instead of initialising the class with just the url, you can also send a different username and password.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#17
@el_Paraguayo
Your right, i noticed that also but ran into a few issues when filling those fields from addon settings like this (It's an example and not working)

Code:
username = getSetting("xbmc_username")
password = getSetting("xbmc_password")
hostname = getSetting("xbmc_hostname")
port = getSetting("xbmc_port")

myxbmc = XBMC("http://%s:%s/jsonrpc", "%s", "%s" % (hostname, port, username, password))

Your linked module works perfect so far except that NZBget isn't responding anymore but that's not json module related.
At this moment I need to hardcode host settings and username pass.
Not a big issue since it's for personal use but understanding how things work could become handy for future addon development.
Reply
#18
I'm really not an expert on plugin settings, but I think you'd need the "getSetting" call to be linked to your addon i.e define your addon object first and then call addon.getSetting.

Something like this:
Code:
myaddon = xbmcaddon.Addon( "YOUR.ADDON.NAME" )
addonSetting = myaddon.getSetting

username = addonSetting("xbmc_username")

Apologies if that's what you've already done.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#19
(2014-03-22, 17:50)el_Paraguayo Wrote: I'm really not an expert on plugin settings, but I think you'd need the "getSetting" call to be linked to your addon i.e define your addon object first and then call addon.getSetting.

Something like this:
Code:
myaddon = xbmcaddon.Addon( "YOUR.ADDON.NAME" )
addonSetting = myaddon.getSetting

username = addonSetting("xbmc_username")

Apologies if that's what you've already done.
No apologies needed. The problem isn't fetching the settings but inserting them in their place.
The JSON module only seems to allow username password but not host and port.
Reply
#20
Have you tried printing the settings to see if they are retrieved ok?

My next suggestion would be:
Code:
username = getSetting("xbmc_username")
password = getSetting("xbmc_password")
hostname = getSetting("xbmc_hostname")
port = getSetting("xbmc_port")

myxbmc = XBMC("http://%s:%s/jsonrpc" % (hostname, port), username, password)
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#21
I think this line:
Code:
myxbmc = XBMC("http://%s:%s/jsonrpc", "%s", "%s" % (hostname, port, username, password))
will actually throw an error in python as you're trying to do string substitution over a number of separate strings.

The code in my post above should work.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#22
(2014-03-24, 18:37)el_Paraguayo Wrote: I think this line:
Code:
myxbmc = XBMC("http://%s:%s/jsonrpc", "%s", "%s" % (hostname, port, username, password))
will actually throw an error in python as you're trying to do string substitution over a number of separate strings.

The code in my post above should work.

Yes your right except it throws an error but i don't mind since it works now
Code:
14:59:51 T:8024   ERROR: C:\Program Files\XBMC\system\python\Lib\urllib2.py:897: UserWarning: Basic Auth Realm was unquoted
                                              url, req, headers)
Reply
#23
I'm not sure that's an error - but it's still annoying to have messages in the long.

However, if it's working now, then that's great!
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply

Logout Mark Read Team Forum Stats Members Help
Json Call to remote instance0