Kodi Community Forum

Full Version: Addon Settings Problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

I dont know if this has been asked before but searching just seems to open an ocean of unrelated posts

I've fairly new to addon development but i've run into an issue and im not sure whether its a bug or im just doing something wrong

In my app i've defined a function to handle my http calls, and in the addon settings i've provided options to enter a username / password combo

basically the username / password are used to form the url eg. http://username:[email protected]/... this is all done within the http function

def http_get(querystring={}):
qs = urllib.urlencode(querystring)
url = httpScheme+"://"+gui.setting("username")+":"+gui.setting("password")+"@"+ hostname + localpath + qs
rs = requests.get(url)
if rs.status_code != 200:
dia = xbmcgui.Dialog()
dia.ok("Content Unavailable","Server returned status " + str(rs.status_code), status_to_string(rs.status_code),url)
return ""

html = rs.content
return html

So for the majority of calls this function works fine, but one particular call causes the settings to return empty like http://:@domain.com/.. which throws an error

FYI gui.setting is my file.function for getting settings

As you can see, the http calls and settings are always called in exactly the same way, yet one function causes the settings to return empty, theres nothing unusual about the function and its in the same .py as other routines that call the http function without issue

Ideas anyone?

Thanks in advance
I've found the cause of the problem, it appears that when calling xbmcplugin.addDirectoryItem with the property isFolder=False then the settings are not retrieved

My workaround is to read and parse the userdata/addons/..../settings.xml file directly,

def xmlSetting(key):
ob = ""
try:
a = xbmcaddon.Addon(id='[plugin name]')
pth = xbmc.translatePath(a.getAddonInfo('profile') )
t = et.parse(pth + '/settings.xml')

for i in t.findall("setting"):
if i.attrib['id'] == key:
ob = i.attrib['value']

except:
ob = ""

return ob


Seems to work ok