PlexKodiConnect/resources/lib/plexbmchelper/plexsettings.py

63 lines
2 KiB
Python
Raw Permalink Normal View History

import logging
from utils import guisettingsXML, settings
2017-01-25 02:53:50 +11:00
import variables as v
2016-01-15 22:12:52 +11:00
###############################################################################
log = logging.getLogger("PLEX."+__name__)
###############################################################################
2016-01-15 22:12:52 +11:00
def getGUI(name):
xml = guisettingsXML()
2016-01-15 22:12:52 +11:00
try:
ans = list(xml.iter(name))[0].text
2016-03-30 05:17:07 +11:00
if ans is None:
ans = ''
2016-01-15 22:12:52 +11:00
except:
ans = ''
return ans
def getSettings():
options = {}
options['gdm_debug'] = settings('companionGDMDebugging')
options['gdm_debug'] = True if options['gdm_debug'] == 'true' else False
options['client_name'] = v.DEVICENAME
# XBMC web server options
options['webserver_enabled'] = (getGUI('webserver') == "true")
log.info('Webserver is set to %s' % options['webserver_enabled'])
webserverport = getGUI('webserverport')
try:
webserverport = int(webserverport)
log.info('Using webserver port %s' % str(webserverport))
except:
log.info('No setting for webserver port found in guisettings.xml.'
'Using default fallback port 8080')
webserverport = 8080
options['port'] = webserverport
options['user'] = getGUI('webserverusername')
options['passwd'] = getGUI('webserverpassword')
log.info('Webserver username: %s, password: %s'
2016-09-05 00:50:34 +10:00
% (options['user'], options['passwd']))
2017-01-25 02:53:50 +11:00
options['addonName'] = v.ADDON_NAME
options['uuid'] = settings('plex_client_Id')
2017-01-25 02:53:50 +11:00
options['platform'] = v.PLATFORM
options['version'] = v.ADDON_VERSION
options['plexbmc_version'] = options['version']
options['myplex_user'] = settings('username')
try:
options['myport'] = int(settings('companionPort'))
log.info('Using Plex Companion Port %s' % str(options['myport']))
except:
log.error('Error getting Plex Companion Port from file settings. '
'Using fallback port 39005')
options['myport'] = 39005
return options