From aae27f36f65c795106bf0f6bc984c1dbdc2419c4 Mon Sep 17 00:00:00 2001 From: SickBeard Custom User Date: Wed, 23 Apr 2014 11:48:07 +0100 Subject: [PATCH 1/6] use proxies --- sickbeard/providers/kat.py | 7 ++++++- sickbeard/providers/thepiratebay.py | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/sickbeard/providers/kat.py b/sickbeard/providers/kat.py index 3e700549..84fb1e8f 100644 --- a/sickbeard/providers/kat.py +++ b/sickbeard/providers/kat.py @@ -312,8 +312,13 @@ class KATProvider(generic.TorrentProvider): parsed = list(urlparse.urlparse(url)) parsed[2] = re.sub("/{2,}", "/", parsed[2]) # replace two or more / with one url = urlparse.urlunparse(parsed) + + proxies = { + "http": "http://192.168.1.11:8118", + "https": "http://192.168.1.11:8118", + } - r = requests.get(url) + r = requests.get(url, proxies=proxies) except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError), e: logger.log(u"Error loading " + self.name + " URL: " + str(sys.exc_info()) + " - " + ex(e), logger.ERROR) return None diff --git a/sickbeard/providers/thepiratebay.py b/sickbeard/providers/thepiratebay.py index 5c540e40..82f50495 100644 --- a/sickbeard/providers/thepiratebay.py +++ b/sickbeard/providers/thepiratebay.py @@ -307,8 +307,13 @@ class ThePirateBayProvider(generic.TorrentProvider): if self.proxy.isEnabled(): headers.update({'referer': self.proxy.getProxyURL()}) + proxies = { + "http": "http://192.168.1.11:8118", + "https": "http://192.168.1.11:8118", + } + try: - r = requests.get(url, headers=headers) + r = requests.get(url, headers=headers, proxies=proxies) except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError), e: logger.log(u"Error loading " + self.name + " URL: " + str(sys.exc_info()) + " - " + ex(e), logger.ERROR) return None From 65e0dd9ff7c73f8fee0c0ee08b708635a4585064 Mon Sep 17 00:00:00 2001 From: SickBeard Custom User Date: Wed, 23 Apr 2014 12:21:20 +0100 Subject: [PATCH 2/6] use tor for generic providers:w --- sickbeard/helpers.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sickbeard/helpers.py b/sickbeard/helpers.py index 96013ff0..8e3fd579 100644 --- a/sickbeard/helpers.py +++ b/sickbeard/helpers.py @@ -184,7 +184,13 @@ Returns a byte-string retrieved from the url provider. url = urlparse.urlunparse(parsed) it = iter(req_headers) - resp = requests.get(url, params=params, data=post_data, headers=dict(zip(it, it))) + + proxies = { + "http": "http://192.168.1.11:8118", + "https": "http://192.168.1.11:8118", + } + + resp = requests.get(url, params=params, data=post_data, headers=dict(zip(it, it)), proxies=proxies) except requests.HTTPError, e: logger.log(u"HTTP error " + str(e.errno) + " while loading URL " + url, logger.WARNING) return None @@ -981,4 +987,4 @@ def real_path(path): """ Returns: the canonicalized absolute pathname. The resulting path will have no symbolic link, '/./' or '/../' components. """ - return ek.ek(os.path.normpath, ek.ek(os.path.normcase, ek.ek(os.path.realpath, path))) \ No newline at end of file + return ek.ek(os.path.normpath, ek.ek(os.path.normcase, ek.ek(os.path.realpath, path))) From 484dba0de852ce8b055e71e8c20e7d4dec0f432e Mon Sep 17 00:00:00 2001 From: SickBeard Custom User Date: Thu, 24 Apr 2014 16:50:35 +0100 Subject: [PATCH 3/6] proper settings for proxy --- gui/slick/interfaces/default/config_general.tmpl | 10 ++++++++++ sickbeard/__init__.py | 5 ++++- sickbeard/helpers.py | 13 ++++++++----- sickbeard/providers/kat.py | 13 ++++++++----- sickbeard/providers/thepiratebay.py | 10 +++++++++- sickbeard/webserve.py | 5 +++-- 6 files changed, 42 insertions(+), 14 deletions(-) diff --git a/gui/slick/interfaces/default/config_general.tmpl b/gui/slick/interfaces/default/config_general.tmpl index 2dcad7c0..919e91e8 100644 --- a/gui/slick/interfaces/default/config_general.tmpl +++ b/gui/slick/interfaces/default/config_general.tmpl @@ -274,6 +274,16 @@ +
+ + +
diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index b99e3b45..79ff342c 100644 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -487,7 +487,8 @@ def initialize(consoleLogging=True): GUI_NAME, HOME_LAYOUT, HISTORY_LAYOUT, DISPLAY_SHOW_SPECIALS, COMING_EPS_LAYOUT, COMING_EPS_SORT, COMING_EPS_DISPLAY_PAUSED, COMING_EPS_MISSED_RANGE, DATE_PRESET, TIME_PRESET, TIME_PRESET_W_SECONDS, \ METADATA_WDTV, METADATA_TIVO, IGNORE_WORDS, CALENDAR_UNPROTECTED, CREATE_MISSING_SHOW_DIRS, \ ADD_SHOWS_WO_DIR, USE_SUBTITLES, SUBTITLES_LANGUAGES, SUBTITLES_DIR, SUBTITLES_SERVICES_LIST, SUBTITLES_SERVICES_ENABLED, SUBTITLES_HISTORY, SUBTITLES_FINDER_FREQUENCY, subtitlesFinderScheduler, \ - USE_FAILED_DOWNLOADS, DELETE_FAILED, ANON_REDIRECT, LOCALHOST_IP, TMDB_API_KEY + USE_FAILED_DOWNLOADS, DELETE_FAILED, ANON_REDIRECT, LOCALHOST_IP, TMDB_API_KEY, \ + PROXY_SETTING if __INITIALIZED__: return False @@ -541,6 +542,7 @@ def initialize(consoleLogging=True): LOCALHOST_IP = check_setting_str(CFG, 'General', 'localhost_ip', '') ANON_REDIRECT = check_setting_str(CFG, 'General', 'anon_redirect', 'http://dereferer.org/?') + PROXY_SETTING = check_setting_str(CFG, 'General', 'proxy_setting', 'http://192.168.1.11:8118') # attempt to help prevent users from breaking links by using a bad url if not ANON_REDIRECT.endswith('?'): ANON_REDIRECT = '' @@ -1300,6 +1302,7 @@ def save_config(): new_config['General']['launch_browser'] = int(LAUNCH_BROWSER) new_config['General']['update_shows_on_start'] = int(UPDATE_SHOWS_ON_START) new_config['General']['sort_article'] = int(SORT_ARTICLE) + new_config['General']['proxy_setting'] = PROXY_SETTING if PROXY_SETTING else '' new_config['General']['use_listview'] = int(USE_LISTVIEW) new_config['General']['metadata_xbmc'] = METADATA_XBMC diff --git a/sickbeard/helpers.py b/sickbeard/helpers.py index 8e3fd579..0bb6f6a2 100644 --- a/sickbeard/helpers.py +++ b/sickbeard/helpers.py @@ -185,12 +185,15 @@ Returns a byte-string retrieved from the url provider. it = iter(req_headers) - proxies = { - "http": "http://192.168.1.11:8118", - "https": "http://192.168.1.11:8118", - } + if sickbeard.PROXY_SETTING: + proxies = { + "http": sickbeard.PROXY_SETTING, + "https": sickbeard.PROXY_SETTING, + } - resp = requests.get(url, params=params, data=post_data, headers=dict(zip(it, it)), proxies=proxies) + resp = requests.get(url, params=params, data=post_data, headers=dict(zip(it, it)), proxies=proxies) + else: + resp = requests.get(url, params=params, data=post_data, headers=dict(zip(it, it))) except requests.HTTPError, e: logger.log(u"HTTP error " + str(e.errno) + " while loading URL " + url, logger.WARNING) return None diff --git a/sickbeard/providers/kat.py b/sickbeard/providers/kat.py index 84fb1e8f..bb2cb841 100644 --- a/sickbeard/providers/kat.py +++ b/sickbeard/providers/kat.py @@ -313,12 +313,15 @@ class KATProvider(generic.TorrentProvider): parsed[2] = re.sub("/{2,}", "/", parsed[2]) # replace two or more / with one url = urlparse.urlunparse(parsed) - proxies = { - "http": "http://192.168.1.11:8118", - "https": "http://192.168.1.11:8118", - } + if sickbeard.PROXY_SETTING: + proxies = { + "http": sickbeard.PROXY_SETTING, + "https": sickbeard.PROXY_SETTING, + } - r = requests.get(url, proxies=proxies) + r = requests.get(url, proxies=proxies) + else: + r = requests.get(url) except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError), e: logger.log(u"Error loading " + self.name + " URL: " + str(sys.exc_info()) + " - " + ex(e), logger.ERROR) return None diff --git a/sickbeard/providers/thepiratebay.py b/sickbeard/providers/thepiratebay.py index 82f50495..9dff25a8 100644 --- a/sickbeard/providers/thepiratebay.py +++ b/sickbeard/providers/thepiratebay.py @@ -313,7 +313,15 @@ class ThePirateBayProvider(generic.TorrentProvider): } try: - r = requests.get(url, headers=headers, proxies=proxies) + if sickbeard.PROXY_SETTING: + proxies = { + "http": sickbeard.PROXY_SETTING, + "https": sickbeard.PROXY_SETTING, + } + + r = requests.get(url, headers=headers, proxies=proxies) + else: + r = requests.get(url, headers=headers) except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError), e: logger.log(u"Error loading " + self.name + " URL: " + str(sys.exc_info()) + " - " + ex(e), logger.ERROR) return None diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 61de1d87..c797926b 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -976,7 +976,7 @@ class ConfigGeneral: def saveGeneral(self, log_dir=None, web_port=None, web_log=None, encryption_version=None, web_ipv6=None, update_shows_on_start=None, launch_browser=None, web_username=None, use_api=None, api_key=None, web_password=None, version_notify=None, enable_https=None, https_cert=None, https_key=None, - sort_article=None, auto_update=None, + sort_article=None, auto_update=None, proxy_settings=None, anon_redirect=None, git_path=None, calendar_unprotected=None, date_preset=None, time_preset=None): results = [] @@ -991,6 +991,7 @@ class ConfigGeneral: sickbeard.LAUNCH_BROWSER = config.checkbox_to_value(launch_browser) sickbeard.SORT_ARTICLE = config.checkbox_to_value(sort_article) sickbeard.ANON_REDIRECT = anon_redirect + sickbeard.PROXY_SETTINGS = proxy_settings sickbeard.GIT_PATH = git_path sickbeard.CALENDAR_UNPROTECTED = config.checkbox_to_value(calendar_unprotected) # sickbeard.LOG_DIR is set in config.change_LOG_DIR() @@ -3727,4 +3728,4 @@ class WebInterface: errorlogs = ErrorLogs() - ui = UI() \ No newline at end of file + ui = UI() From 09b106ec6b5a9f312dba215aa53c0736ccd09c57 Mon Sep 17 00:00:00 2001 From: Peter Maciocia Date: Thu, 24 Apr 2014 17:19:38 +0100 Subject: [PATCH 4/6] remove duplicate variable --- sickbeard/providers/thepiratebay.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/sickbeard/providers/thepiratebay.py b/sickbeard/providers/thepiratebay.py index 9dff25a8..13f98568 100644 --- a/sickbeard/providers/thepiratebay.py +++ b/sickbeard/providers/thepiratebay.py @@ -306,12 +306,7 @@ class ThePirateBayProvider(generic.TorrentProvider): # We have to fake a search on the proxy site to get data if self.proxy.isEnabled(): headers.update({'referer': self.proxy.getProxyURL()}) - - proxies = { - "http": "http://192.168.1.11:8118", - "https": "http://192.168.1.11:8118", - } - + try: if sickbeard.PROXY_SETTING: proxies = { From ddaa5bb5e671f18aaa9bc403275106c507eb4bf9 Mon Sep 17 00:00:00 2001 From: Peter Maciocia Date: Thu, 24 Apr 2014 18:08:24 +0100 Subject: [PATCH 5/6] remove default proxy setting, fix indent --- gui/slick/interfaces/default/config_general.tmpl | 2 +- sickbeard/__init__.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gui/slick/interfaces/default/config_general.tmpl b/gui/slick/interfaces/default/config_general.tmpl index 919e91e8..afd01d09 100644 --- a/gui/slick/interfaces/default/config_general.tmpl +++ b/gui/slick/interfaces/default/config_general.tmpl @@ -281,7 +281,7 @@ diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index 79ff342c..ae6c4d1f 100644 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -488,7 +488,7 @@ def initialize(consoleLogging=True): METADATA_WDTV, METADATA_TIVO, IGNORE_WORDS, CALENDAR_UNPROTECTED, CREATE_MISSING_SHOW_DIRS, \ ADD_SHOWS_WO_DIR, USE_SUBTITLES, SUBTITLES_LANGUAGES, SUBTITLES_DIR, SUBTITLES_SERVICES_LIST, SUBTITLES_SERVICES_ENABLED, SUBTITLES_HISTORY, SUBTITLES_FINDER_FREQUENCY, subtitlesFinderScheduler, \ USE_FAILED_DOWNLOADS, DELETE_FAILED, ANON_REDIRECT, LOCALHOST_IP, TMDB_API_KEY, \ - PROXY_SETTING + PROXY_SETTING if __INITIALIZED__: return False @@ -542,7 +542,7 @@ def initialize(consoleLogging=True): LOCALHOST_IP = check_setting_str(CFG, 'General', 'localhost_ip', '') ANON_REDIRECT = check_setting_str(CFG, 'General', 'anon_redirect', 'http://dereferer.org/?') - PROXY_SETTING = check_setting_str(CFG, 'General', 'proxy_setting', 'http://192.168.1.11:8118') + PROXY_SETTING = check_setting_str(CFG, 'General', 'proxy_setting', '') # attempt to help prevent users from breaking links by using a bad url if not ANON_REDIRECT.endswith('?'): ANON_REDIRECT = '' From 5007b806a55a95162fc4cf1305dfd27bab856143 Mon Sep 17 00:00:00 2001 From: Peter Maciocia Date: Thu, 24 Apr 2014 18:41:44 +0100 Subject: [PATCH 6/6] fix indent --- sickbeard/webserve.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index c797926b..e1286e42 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -991,7 +991,7 @@ class ConfigGeneral: sickbeard.LAUNCH_BROWSER = config.checkbox_to_value(launch_browser) sickbeard.SORT_ARTICLE = config.checkbox_to_value(sort_article) sickbeard.ANON_REDIRECT = anon_redirect - sickbeard.PROXY_SETTINGS = proxy_settings + sickbeard.PROXY_SETTINGS = proxy_settings sickbeard.GIT_PATH = git_path sickbeard.CALENDAR_UNPROTECTED = config.checkbox_to_value(calendar_unprotected) # sickbeard.LOG_DIR is set in config.change_LOG_DIR()