PlexKodiConnect/resources/lib/plexbmchelper/settings.py

54 lines
1.5 KiB
Python
Raw Normal View History

2016-01-15 22:12:52 +11:00
import uuid
import xbmc
import xbmcaddon
from xml.dom.minidom import parse
2016-01-23 03:34:26 +11:00
import utils
2016-01-15 22:12:52 +11:00
settings = {}
try:
2016-03-25 04:52:02 +11:00
path = xbmc.translatePath(
'special://userdata/guisettings.xml').decode('utf-8')
guidoc = parse(path)
2016-01-15 22:12:52 +11:00
except:
2016-03-25 04:52:02 +11:00
print "PlexKodiConnect - Unable to read XBMC's guisettings.xml"
2016-01-15 22:12:52 +11:00
def getGUI(name):
global guidoc
if guidoc is None:
return False
try:
return guidoc.getElementsByTagName(name)[0].firstChild.nodeValue
except:
return ""
addon = xbmcaddon.Addon()
plexbmc = xbmcaddon.Addon('plugin.video.plexkodiconnect')
2016-01-15 22:12:52 +11:00
2016-01-23 03:34:26 +11:00
settings['debug'] = utils.settings('companionDebugging')
settings['gdm_debug'] = utils.settings('companionGDMDebugging')
# Transform 'true' into True because of the way Kodi's file settings work
kodiSettingsList = ['debug', 'gdm_debug']
for entry in kodiSettingsList:
if settings[entry] == 'true':
settings[entry] = True
else:
settings[entry] = False
settings['client_name'] = plexbmc.getSetting('deviceName')
2016-01-15 22:12:52 +11:00
# XBMC web server settings
2016-03-25 04:52:02 +11:00
xbmc.sleep(5000)
2016-01-15 22:12:52 +11:00
settings['webserver_enabled'] = (getGUI('webserver') == "true")
settings['port'] = int(getGUI('webserverport'))
settings['user'] = getGUI('webserverusername')
settings['passwd'] = getGUI('webserverpassword')
settings['uuid'] = plexbmc.getSetting('plex_client_Id')
settings['version'] = plexbmc.getAddonInfo('version')
2016-01-15 22:12:52 +11:00
settings['plexbmc_version'] = plexbmc.getAddonInfo('version')
settings['myplex_user'] = plexbmc.getSetting('username')
2016-01-15 22:12:52 +11:00
settings['serverList'] = []
settings['myport'] = addon.getSetting('companionPort')