From 64298127c5dd3fb32f1860a077eb973e90b9bde9 Mon Sep 17 00:00:00 2001 From: Pieter Janssens Date: Tue, 5 Aug 2014 09:47:05 +0200 Subject: [PATCH] Dynamically construct nzbget URL This allows config for no http prefix or with http/https prefix for the nzbget URL. --- headphones/nzbget.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/headphones/nzbget.py b/headphones/nzbget.py index d3abba57..d8a874cf 100644 --- a/headphones/nzbget.py +++ b/headphones/nzbget.py @@ -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)