Dynamically construct nzbget URL

This allows config for no http prefix or with http/https prefix for the
nzbget URL.
This commit is contained in:
Pieter Janssens
2014-08-05 09:47:05 +02:00
parent 9122136594
commit 64298127c5

View File

@@ -35,12 +35,20 @@ from headphones import logger
def sendNZB(nzb):
addToTop = False
nzbgetXMLrpc = "http://%(username)s:%(password)s@%(host)s/xmlrpc"
nzbgetXMLrpc = "%(username)s:%(password)s@%(host)s/xmlrpc"
if headphones.NZBGET_HOST == None:
logger.error(u"No NZBget host found in configuration. Please configure it.")
return False
if headphones.NZBGET_HOST.startswith('https://'):
nzbgetXMLrpc = 'https://' + nzbgetXMLrpc
headphones.NZBGET_HOST.replace('https://','',1)
else
nzbgetXMLrpc = 'http://' + nzbgetXMLrpc
headphones.NZBGET_HOST.replace('http://','',1)
url = nzbgetXMLrpc % {"host": headphones.NZBGET_HOST, "username": headphones.NZBGET_USERNAME, "password": headphones.NZBGET_PASSWORD}
nzbGetRPC = xmlrpclib.ServerProxy(url)