From 91221365945b5bb9c4c6fe6546c8a04204e710ef Mon Sep 17 00:00:00 2001 From: Pieter Janssens Date: Tue, 5 Aug 2014 09:28:53 +0200 Subject: [PATCH 1/3] Add optional KAT proxy config Fixes #1778 --- data/interfaces/default/config.html | 6 ++++++ headphones/__init__.py | 1 + headphones/searcher.py | 16 +++++++++++++++- headphones/webserve.py | 2 ++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 78dfaef2..6eb7aad8 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -396,6 +396,12 @@
+
+
+
+ + +
diff --git a/headphones/__init__.py b/headphones/__init__.py index 4d361eaf..ec6a2242 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -188,6 +188,7 @@ ALBUM_COMPLETION_PCT = None # This is used in importer.py to determine how co TORRENTBLACKHOLE_DIR = None NUMBEROFSEEDERS = 10 KAT = None +KAT_PROXY_URL = None MININOVA = None PIRATEBAY = None PIRATEBAY_PROXY_URL = None diff --git a/headphones/searcher.py b/headphones/searcher.py index ee00b075..c35a542d 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -897,7 +897,21 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None): if headphones.KAT: provider = "Kick Ass Torrents" - providerurl = url_fix("http://kickass.to/usearch/" + term) + + if headphones.KAT_PROXY_URL: + #Might need to clean up the user submitted url + kat_proxy = headphones.KAT_PROXY_URL + + if not kat_proxy.startswith('http'): + kat_proxy = 'http://' + kat_proxy + if kat_proxy.endswith('/'): + kat_proxy = kat_proxy[:-1] + + providerurl = url_fix(kat_proxy + "/usearch/" + term) + + else: + providerurl = url_fix("http://kickass.to/usearch/" + term) + if headphones.PREFERRED_QUALITY == 3 or losslessOnly: categories = "7" #music format = "2" #flac diff --git a/headphones/webserve.py b/headphones/webserve.py index 9dd20b50..1c2580d3 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -1007,6 +1007,7 @@ class WebInterface(object): "download_torrent_dir" : headphones.DOWNLOAD_TORRENT_DIR, "numberofseeders" : headphones.NUMBEROFSEEDERS, "use_kat" : checked(headphones.KAT), + "kat_proxy_url" : headphones.KAT_PROXY_URL, "use_piratebay" : checked(headphones.PIRATEBAY), "piratebay_proxy_url" : headphones.PIRATEBAY_PROXY_URL, "use_mininova" : checked(headphones.MININOVA), @@ -1224,6 +1225,7 @@ class WebInterface(object): headphones.NUMBEROFSEEDERS = numberofseeders headphones.DOWNLOAD_TORRENT_DIR = download_torrent_dir headphones.KAT = use_kat + headphones.KAT_PROXY_URL = kat_proxy_url headphones.PIRATEBAY = use_piratebay headphones.PIRATEBAY_PROXY_URL = piratebay_proxy_url headphones.MININOVA = use_mininova From 64298127c5dd3fb32f1860a077eb973e90b9bde9 Mon Sep 17 00:00:00 2001 From: Pieter Janssens Date: Tue, 5 Aug 2014 09:47:05 +0200 Subject: [PATCH 2/3] 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) From d590d037adc117233ca9b97232aad713bbf5f44e Mon Sep 17 00:00:00 2001 From: Pieter Janssens Date: Tue, 5 Aug 2014 09:53:38 +0200 Subject: [PATCH 3/3] Fix indenting --- headphones/__init__.py | 8 ++++---- headphones/searcher.py | 6 +++--- headphones/webserve.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/headphones/__init__.py b/headphones/__init__.py index ec6a2242..0edf4240 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -691,10 +691,10 @@ def initialize(): CONFIG_VERSION = '3' if CONFIG_VERSION == '3': - #Update the BLACKHOLE option to the NZB_DOWNLOADER format - if BLACKHOLE: - NZB_DOWNLOADER = 2 - CONFIG_VERSION = '4' + #Update the BLACKHOLE option to the NZB_DOWNLOADER format + if BLACKHOLE: + NZB_DOWNLOADER = 2 + CONFIG_VERSION = '4' # Enable Headphones Indexer if they have a VIP account if CONFIG_VERSION == '4': diff --git a/headphones/searcher.py b/headphones/searcher.py index c35a542d..8570e152 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -897,8 +897,8 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None): if headphones.KAT: provider = "Kick Ass Torrents" - - if headphones.KAT_PROXY_URL: + + if headphones.KAT_PROXY_URL: #Might need to clean up the user submitted url kat_proxy = headphones.KAT_PROXY_URL @@ -911,7 +911,7 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None): else: providerurl = url_fix("http://kickass.to/usearch/" + term) - + if headphones.PREFERRED_QUALITY == 3 or losslessOnly: categories = "7" #music format = "2" #flac diff --git a/headphones/webserve.py b/headphones/webserve.py index 1c2580d3..034485fe 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -1007,7 +1007,7 @@ class WebInterface(object): "download_torrent_dir" : headphones.DOWNLOAD_TORRENT_DIR, "numberofseeders" : headphones.NUMBEROFSEEDERS, "use_kat" : checked(headphones.KAT), - "kat_proxy_url" : headphones.KAT_PROXY_URL, + "kat_proxy_url" : headphones.KAT_PROXY_URL, "use_piratebay" : checked(headphones.PIRATEBAY), "piratebay_proxy_url" : headphones.PIRATEBAY_PROXY_URL, "use_mininova" : checked(headphones.MININOVA), @@ -1225,7 +1225,7 @@ class WebInterface(object): headphones.NUMBEROFSEEDERS = numberofseeders headphones.DOWNLOAD_TORRENT_DIR = download_torrent_dir headphones.KAT = use_kat - headphones.KAT_PROXY_URL = kat_proxy_url + headphones.KAT_PROXY_URL = kat_proxy_url headphones.PIRATEBAY = use_piratebay headphones.PIRATEBAY_PROXY_URL = piratebay_proxy_url headphones.MININOVA = use_mininova