From 1458314c1796b04f60d920ad005bb688e82efaf8 Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Wed, 13 Jun 2018 22:35:36 +0200 Subject: [PATCH 1/2] Add base mapping logic for NZBGet. --- sickbeard/__init__.py | 5 ++++- sickbeard/helpers.py | 2 +- sickbeard/webserve.py | 9 ++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index 7ca118ac..b02a0a0d 100755 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -268,6 +268,7 @@ NZBGET_HOST = None NZBGET_USE_HTTPS = False NZBGET_PRIORITY = 100 NZBGET_SCRIPT_VERSION = None +NZBGET_MAP = None SAB_USERNAME = None SAB_PASSWORD = None @@ -615,7 +616,7 @@ def initialize(console_logging=True): # Search Settings/NZB search global USE_NZBS, NZB_METHOD, NZB_DIR, SAB_HOST, SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, \ NZBGET_USE_HTTPS, NZBGET_HOST, NZBGET_USERNAME, NZBGET_PASSWORD, NZBGET_CATEGORY, NZBGET_PRIORITY, \ - NZBGET_SCRIPT_VERSION + NZBGET_SCRIPT_VERSION, NZBGET_MAP # Search Settings/Torrent search global USE_TORRENTS, TORRENT_METHOD, TORRENT_DIR, TORRENT_HOST, TORRENT_USERNAME, TORRENT_PASSWORD, \ TORRENT_LABEL, TORRENT_PATH, TORRENT_SEED_TIME, TORRENT_PAUSED, TORRENT_HIGH_BANDWIDTH, TORRENT_VERIFY_CERT @@ -924,6 +925,7 @@ def initialize(console_logging=True): NZBGET_HOST = check_setting_str(CFG, 'NZBget', 'nzbget_host', '') NZBGET_USE_HTTPS = bool(check_setting_int(CFG, 'NZBget', 'nzbget_use_https', 0)) NZBGET_PRIORITY = check_setting_int(CFG, 'NZBget', 'nzbget_priority', 100) + NZBGET_MAP = check_setting_str(CFG, 'NZBget', 'nzbget_map', '') try: ng_script_file = ek.ek(os.path.join, ek.ek(os.path.dirname, ek.ek(os.path.dirname, __file__)), @@ -1766,6 +1768,7 @@ def save_config(): new_config['NZBget']['nzbget_host'] = NZBGET_HOST new_config['NZBget']['nzbget_use_https'] = int(NZBGET_USE_HTTPS) new_config['NZBget']['nzbget_priority'] = NZBGET_PRIORITY + new_config['NZBget']['nzbget_map'] = NZBGET_MAP new_config['TORRENT'] = {} new_config['TORRENT']['torrent_username'] = TORRENT_USERNAME diff --git a/sickbeard/helpers.py b/sickbeard/helpers.py index 098c0146..30388e8a 100644 --- a/sickbeard/helpers.py +++ b/sickbeard/helpers.py @@ -1728,7 +1728,7 @@ def path_mapper(search, replace, subject): replace = re.sub(r'[\\]', delim, replace) path = re.sub(r'[\\]', delim, subject) result = re.sub('(?i)^%s' % search, replace, path) - result = os.path.normpath(re.sub(delim, '/', result)) + result = ek.ek(os.path.normpath, re.sub(delim, '/', result)) return result, result != subject diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 54a44a9c..643b385f 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -2996,7 +2996,14 @@ class HomePostProcess(Home): logger.log('Calling SickGear-NG.py script %s is not current version %s, please update.' % (kwargs.get('ppVersion', '0'), sickbeard.NZBGET_SCRIPT_VERSION), logger.ERROR) - result = processTV.processDir(dir.decode('utf-8') if dir else None, nzbName.decode('utf-8') if nzbName else None, + if isinstance(dir, basestring): + dir = dir.decode('utf-8') + if isinstance(client, basestring) and 'nzbget' == client and \ + isinstance(sickbeard.NZBGET_MAP, basestring) and sickbeard.NZBGET_MAP: + m = sickbeard.NZBGET_MAP.split('=') + dir, not_used = helpers.path_mapper(m[0], m[1], dir) + + result = processTV.processDir(dir if dir else None, nzbName.decode('utf-8') if nzbName else None, process_method=process_method, type=type, cleanup='cleanup' in kwargs and kwargs['cleanup'] in ['on', '1'], force=force in ['on', '1'], From 15d2907c041137a4b2409b766778645f0963b28d Mon Sep 17 00:00:00 2001 From: JackDandy Date: Fri, 15 Jun 2018 13:48:03 +0100 Subject: [PATCH 2/2] Add 'Map an NZBGet "DestDir"' setting to config/Search/NZB Results tab (select NZBGet). --- CHANGES.md | 1 + autoProcessTV/onTxComplete.bat | 2 +- .../interfaces/default/config_search.tmpl | 29 ++++++++++---- sickbeard/__init__.py | 40 +++++++++++-------- sickbeard/nzbget.py | 12 +++--- sickbeard/webserve.py | 8 ++-- 6 files changed, 58 insertions(+), 34 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 283911b0..7d3ba10d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,6 @@ ### 0.17.0 (2018-xx-xx xx:xx:xx UTC) +* Add 'Map an NZBGet "DestDir"' setting to config/Search/NZB Results tab (select NZBGet) * Add TVDB, TheXem, and GitHub buttons to page History/Layout "Provider fails" that fetches a site Up/Down report * Add bubble links to History/Provider fails when more than one provider has failures * Add "Keep up to x most recent downloads" to Edit Show/Other diff --git a/autoProcessTV/onTxComplete.bat b/autoProcessTV/onTxComplete.bat index fed73539..dc758949 100644 --- a/autoProcessTV/onTxComplete.bat +++ b/autoProcessTV/onTxComplete.bat @@ -2,7 +2,7 @@ GOTO :main ******************************************************************************* -onTxComplete.bat v1.0 for Sickgear +onTxComplete.bat v1.0 for SickGear Script to copy select files to a location for SickGear to post process. diff --git a/gui/slick/interfaces/default/config_search.tmpl b/gui/slick/interfaces/default/config_search.tmpl index c01c8c3a..6fd8b1c8 100755 --- a/gui/slick/interfaces/default/config_search.tmpl +++ b/gui/slick/interfaces/default/config_search.tmpl @@ -240,7 +240,7 @@ Send .nzb files to:

(e.g. localhost:6789)

-

NZBget RPC host name and port number (not NZBgetweb!)

+

NZBGet RPC host name and port number (not NZBGetweb!)