mirror of
https://github.com/rembo10/headphones.git
synced 2026-07-21 08:24:00 +01:00
Support for multiple XBMC hosts
This commit is contained in:
@@ -600,7 +600,7 @@
|
|||||||
<h3><input type="checkbox" name="xbmc_enabled" id="xbmc" value="1" ${config['xbmc_enabled']} />Enable XBMC Updates</h3><br>
|
<h3><input type="checkbox" name="xbmc_enabled" id="xbmc" value="1" ${config['xbmc_enabled']} />Enable XBMC Updates</h3><br>
|
||||||
<div id="xbmcoptions">
|
<div id="xbmcoptions">
|
||||||
<h3>XBMC Host:Port:</h3><input type="text" name="xbmc_host" value="${config['xbmc_host']}" size="30"><br>
|
<h3>XBMC Host:Port:</h3><input type="text" name="xbmc_host" value="${config['xbmc_host']}" size="30"><br>
|
||||||
<i class="smalltext">e.g. http://localhost:8080</i><br>
|
<div class="tooltip"><span>e.g. http://localhost:8080. Separate hosts with commas</span></div>
|
||||||
<h3>XBMC Username:</h3><input type="text" name="xbmc_username" value="${config['xbmc_username']}" size="30"><br><br>
|
<h3>XBMC Username:</h3><input type="text" name="xbmc_username" value="${config['xbmc_username']}" size="30"><br><br>
|
||||||
<h3>XBMC Password:</h3><input type="password" name="xbmc_password" value="${config['xbmc_password']}" size="30"><br><br>
|
<h3>XBMC Password:</h3><input type="password" name="xbmc_password" value="${config['xbmc_password']}" size="30"><br><br>
|
||||||
<h3><input type="checkbox" name="xbmc_update" value="1" ${config['xbmc_update']} />Update XBMC Library</h3><br>
|
<h3><input type="checkbox" name="xbmc_update" value="1" ${config['xbmc_update']} />Update XBMC Library</h3><br>
|
||||||
|
|||||||
@@ -448,7 +448,7 @@
|
|||||||
<h3><input type="checkbox" name="xbmc_enabled" id="xbmc" value="1" ${config['xbmc_enabled']} />Enable XBMC Updates</h3><br>
|
<h3><input type="checkbox" name="xbmc_enabled" id="xbmc" value="1" ${config['xbmc_enabled']} />Enable XBMC Updates</h3><br>
|
||||||
<div id="xbmcoptions">
|
<div id="xbmcoptions">
|
||||||
<h3>XBMC Host:Port:</h3><input type="text" name="xbmc_host" value="${config['xbmc_host']}" size="30"><br>
|
<h3>XBMC Host:Port:</h3><input type="text" name="xbmc_host" value="${config['xbmc_host']}" size="30"><br>
|
||||||
<i class="smalltext">e.g. http://localhost:8080</i><br>
|
<i class="smalltext">e.g. http://localhost:8080. Separate hosts with commas</i><br>
|
||||||
<h3>XBMC Username:</h3><input type="text" name="xbmc_username" value="${config['xbmc_username']}" size="30"><br><br>
|
<h3>XBMC Username:</h3><input type="text" name="xbmc_username" value="${config['xbmc_username']}" size="30"><br><br>
|
||||||
<h3>XBMC Password:</h3><input type="password" name="xbmc_password" value="${config['xbmc_password']}" size="30"><br><br>
|
<h3>XBMC Password:</h3><input type="password" name="xbmc_password" value="${config['xbmc_password']}" size="30"><br><br>
|
||||||
<h3><input type="checkbox" name="xbmc_update" value="1" ${config['xbmc_update']} />Update XBMC Library</h3><br>
|
<h3><input type="checkbox" name="xbmc_update" value="1" ${config['xbmc_update']} />Update XBMC Library</h3><br>
|
||||||
|
|||||||
@@ -448,7 +448,7 @@
|
|||||||
<h3><input type="checkbox" name="xbmc_enabled" id="xbmc" value="1" ${config['xbmc_enabled']} />Enable XBMC Updates</h3><br>
|
<h3><input type="checkbox" name="xbmc_enabled" id="xbmc" value="1" ${config['xbmc_enabled']} />Enable XBMC Updates</h3><br>
|
||||||
<div id="xbmcoptions">
|
<div id="xbmcoptions">
|
||||||
<h3>XBMC Host:Port:</h3><input type="text" name="xbmc_host" value="${config['xbmc_host']}" size="30"><br>
|
<h3>XBMC Host:Port:</h3><input type="text" name="xbmc_host" value="${config['xbmc_host']}" size="30"><br>
|
||||||
<i class="smalltext">e.g. http://localhost:8080</i><br>
|
<i class="smalltext">e.g. http://localhost:8080. Separate hosts with commas</i><br>
|
||||||
<h3>XBMC Username:</h3><input type="text" name="xbmc_username" value="${config['xbmc_username']}" size="30"><br><br>
|
<h3>XBMC Username:</h3><input type="text" name="xbmc_username" value="${config['xbmc_username']}" size="30"><br><br>
|
||||||
<h3>XBMC Password:</h3><input type="password" name="xbmc_password" value="${config['xbmc_password']}" size="30"><br><br>
|
<h3>XBMC Password:</h3><input type="password" name="xbmc_password" value="${config['xbmc_password']}" size="30"><br><br>
|
||||||
<h3><input type="checkbox" name="xbmc_update" value="1" ${config['xbmc_update']} />Update XBMC Library</h3><br>
|
<h3><input type="checkbox" name="xbmc_update" value="1" ${config['xbmc_update']} />Update XBMC Library</h3><br>
|
||||||
|
|||||||
+21
-19
@@ -66,37 +66,39 @@ class XBMC:
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.host = headphones.XBMC_HOST
|
self.hosts = headphones.XBMC_HOST
|
||||||
self.username = headphones.XBMC_USERNAME
|
self.username = headphones.XBMC_USERNAME
|
||||||
self.password = headphones.XBMC_PASSWORD
|
self.password = headphones.XBMC_PASSWORD
|
||||||
|
|
||||||
def _send(self, command):
|
def _send(self, command):
|
||||||
|
|
||||||
host = self.host
|
hosts = [x.strip() for x in self.hosts.split(',')]
|
||||||
username = self.username
|
username = self.username
|
||||||
password = self.password
|
password = self.password
|
||||||
|
|
||||||
url_command = urllib.urlencode(command)
|
url_command = urllib.urlencode(command)
|
||||||
|
|
||||||
url = host + '/xbmcCmds/xbmcHttp/?' + url_command
|
for host in hosts:
|
||||||
|
|
||||||
req = urllib2.Request(url)
|
url = host + '/xbmcCmds/xbmcHttp/?' + url_command
|
||||||
|
|
||||||
if password:
|
|
||||||
base64string = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
|
|
||||||
req.add_header("Authorization", "Basic %s" % base64string)
|
|
||||||
|
|
||||||
logger.info('XBMC url: %s' % url)
|
req = urllib2.Request(url)
|
||||||
|
|
||||||
try:
|
if password:
|
||||||
handle = urllib2.urlopen(req)
|
base64string = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
|
||||||
except Exception, e:
|
req.add_header("Authorization", "Basic %s" % base64string)
|
||||||
logger.warn('Error opening XBMC url: ' % e)
|
|
||||||
return
|
logger.info('XBMC url: %s' % url)
|
||||||
|
|
||||||
response = handle.read().decode(headphones.SYS_ENCODING)
|
try:
|
||||||
|
handle = urllib2.urlopen(req)
|
||||||
return response
|
except Exception, e:
|
||||||
|
logger.warn('Error opening XBMC url: ' % e)
|
||||||
|
return
|
||||||
|
|
||||||
|
response = handle.read().decode(headphones.SYS_ENCODING)
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user