Merge pull request #1108 from JackDandy/feature/AddNzbgetMapper

Add nzbget mapper
This commit is contained in:
JackDandy 2018-06-15 19:12:44 +01:00 committed by GitHub
commit e1d1b92e96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 69 additions and 35 deletions

View file

@ -1,5 +1,6 @@
### 0.17.0 (2018-xx-xx xx:xx:xx UTC) ### 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 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 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 * Add "Keep up to x most recent downloads" to Edit Show/Other

View file

@ -2,7 +2,7 @@
GOTO :main 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. Script to copy select files to a location for SickGear to post process.

View file

@ -240,7 +240,7 @@
<span class="component-title">Send .nzb files to:</span> <span class="component-title">Send .nzb files to:</span>
<span class="component-desc"> <span class="component-desc">
<select name="nzb_method" id="nzb_method" class="form-control input-sm"> <select name="nzb_method" id="nzb_method" class="form-control input-sm">
#set $nzb_method_text = {'blackhole': "Black hole", 'sabnzbd': "SABnzbd", 'nzbget': "NZBget"} #set $nzb_method_text = {'blackhole': "Black hole", 'sabnzbd': "SABnzbd", 'nzbget': "NZBGet"}
#for $curAction in ('sabnzbd', 'blackhole', 'nzbget'): #for $curAction in ('sabnzbd', 'blackhole', 'nzbget'):
#set $selected = $html_selected if $sickbeard.NZB_METHOD == $curAction else '' #set $selected = $html_selected if $sickbeard.NZB_METHOD == $curAction else ''
<option value="$curAction"$selected>$nzb_method_text[$curAction]</option> <option value="$curAction"$selected>$nzb_method_text[$curAction]</option>
@ -328,18 +328,18 @@
<div class="field-pair"> <div class="field-pair">
<label> <label>
<span class="component-title">NZBget host:port</span> <span class="component-title">NZBGet host:port</span>
<span class="component-desc"> <span class="component-desc">
<input type="text" name="nzbget_host" id="nzbget_host" value="$sickbeard.NZBGET_HOST" class="form-control input-sm input350"> <input type="text" name="nzbget_host" id="nzbget_host" value="$sickbeard.NZBGET_HOST" class="form-control input-sm input350">
<p>(e.g. localhost:6789)</p> <p>(e.g. localhost:6789)</p>
<p class="clear-left note">NZBget RPC host name and port number (not NZBgetweb!)</p> <p class="clear-left note">NZBGet RPC host name and port number (not NZBGetweb!)</p>
</span> </span>
</label> </label>
</div> </div>
<div class="field-pair"> <div class="field-pair">
<label> <label>
<span class="component-title">NZBget username</span> <span class="component-title">NZBGet username</span>
<span class="component-desc"> <span class="component-desc">
<input type="text" name="nzbget_username" id="nzbget_username" value="$sickbeard.NZBGET_USERNAME" class="form-control input-sm input200"> <input type="text" name="nzbget_username" id="nzbget_username" value="$sickbeard.NZBGET_USERNAME" class="form-control input-sm input200">
<p>locate in nzbget.conf (default:nzbget)</p> <p>locate in nzbget.conf (default:nzbget)</p>
@ -349,7 +349,7 @@
<div class="field-pair"> <div class="field-pair">
<label> <label>
<span class="component-title">NZBget password</span> <span class="component-title">NZBGet password</span>
<span class="component-desc"> <span class="component-desc">
<input type="password" autocomplete="nope" name="nzbget_password" id="nzbget_password" value="#echo '*' * len($sickbeard.NZBGET_PASSWORD)#" class="form-control input-sm input200"> <input type="password" autocomplete="nope" name="nzbget_password" id="nzbget_password" value="#echo '*' * len($sickbeard.NZBGET_PASSWORD)#" class="form-control input-sm input200">
<p>locate in nzbget.conf (default:tegbzn6789)</p> <p>locate in nzbget.conf (default:tegbzn6789)</p>
@ -359,7 +359,7 @@
<div class="field-pair"> <div class="field-pair">
<label> <label>
<span class="component-title">Use NZBget category</span> <span class="component-title">Use NZBGet category</span>
<span class="component-desc"> <span class="component-desc">
<input type="text" name="nzbget_category" id="nzbget_category" value="$sickbeard.NZBGET_CATEGORY" class="form-control input-sm input200"> <input type="text" name="nzbget_category" id="nzbget_category" value="$sickbeard.NZBGET_CATEGORY" class="form-control input-sm input200">
<p>send downloads marked this category (e.g. TV)</p> <p>send downloads marked this category (e.g. TV)</p>
@ -390,7 +390,7 @@
#end if #end if
<div class="field-pair"> <div class="field-pair">
<label> <label>
<span class="component-title">NZBget priority</span> <span class="component-title">NZBGet priority</span>
<span class="component-desc"> <span class="component-desc">
<select name="nzbget_priority" id="nzbget_priority" class="form-control input-sm"> <select name="nzbget_priority" id="nzbget_priority" class="form-control input-sm">
<option value="-100"${prio_verylow}>Very low</option> <option value="-100"${prio_verylow}>Very low</option>
@ -404,11 +404,24 @@
</span> </span>
</label> </label>
</div> </div>
<div class="field-pair">
<label>
<span class="component-title">Map an NZBGet "DestDir"</span>
<span class="component-desc">
<input type="text" name="nzbget_parent_map" value="$sickbeard.NZBGET_MAP" placeholder="DestDir=path known locally as" class="form-control input-sm input250">
<p>link a remote path to a local path</p>
<div class="clear-left" style="line-height:initial"><p>optional: where SG is not installed on the NZBGet system (used by process media)<br>
(e.g. d:\tvstuff = c:\tv, /mnt/tv = /tv, /remote/nzbget/DestDir = /locally/known/as/dir)</p></div>
</span>
</label>
</div>
</div> </div>
<div class="test-notification" id="test-nzb-result">Click below to test</div> <div class="test-notification" id="test-nzb-result">Click below to test</div>
<input type="button" value="Test SABnzbd" id="test_sabnzbd" class="btn test-button sabnzbd"> <input type="button" value="Test SABnzbd" id="test_sabnzbd" class="btn test-button sabnzbd">
<input type="button" value="Test NZBget" id="test_nzbget" class="btn test-button nzbget"> <input type="button" value="Test NZBGet" id="test_nzbget" class="btn test-button nzbget">
<input type="submit" class="btn config_submitter" value="Save Changes"><br /> <input type="submit" class="btn config_submitter" value="Save Changes"><br />
</div><!-- /content_use_nzbs //--> </div><!-- /content_use_nzbs //-->

View file

@ -268,6 +268,7 @@ NZBGET_HOST = None
NZBGET_USE_HTTPS = False NZBGET_USE_HTTPS = False
NZBGET_PRIORITY = 100 NZBGET_PRIORITY = 100
NZBGET_SCRIPT_VERSION = None NZBGET_SCRIPT_VERSION = None
NZBGET_MAP = None
SAB_USERNAME = None SAB_USERNAME = None
SAB_PASSWORD = None SAB_PASSWORD = None
@ -615,7 +616,7 @@ def initialize(console_logging=True):
# Search Settings/NZB search # Search Settings/NZB search
global USE_NZBS, NZB_METHOD, NZB_DIR, SAB_HOST, SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, \ 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_USE_HTTPS, NZBGET_HOST, NZBGET_USERNAME, NZBGET_PASSWORD, NZBGET_CATEGORY, NZBGET_PRIORITY, \
NZBGET_SCRIPT_VERSION NZBGET_SCRIPT_VERSION, NZBGET_MAP
# Search Settings/Torrent search # Search Settings/Torrent search
global USE_TORRENTS, TORRENT_METHOD, TORRENT_DIR, TORRENT_HOST, TORRENT_USERNAME, TORRENT_PASSWORD, \ 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 TORRENT_LABEL, TORRENT_PATH, TORRENT_SEED_TIME, TORRENT_PAUSED, TORRENT_HIGH_BANDWIDTH, TORRENT_VERIFY_CERT
@ -690,7 +691,7 @@ def initialize(console_logging=True):
if __INITIALIZED__: if __INITIALIZED__:
return False return False
for stanza in ('General', 'Blackhole', 'SABnzbd', 'NZBget', 'Emby', 'Kodi', 'XBMC', 'PLEX', for stanza in ('General', 'Blackhole', 'SABnzbd', 'NZBGet', 'Emby', 'Kodi', 'XBMC', 'PLEX',
'Growl', 'Prowl', 'Twitter', 'Slack', 'Discordapp', 'Boxcar2', 'NMJ', 'NMJv2', 'Growl', 'Prowl', 'Twitter', 'Slack', 'Discordapp', 'Boxcar2', 'NMJ', 'NMJv2',
'Synology', 'SynologyNotifier', 'Synology', 'SynologyNotifier',
'pyTivo', 'Pushalot', 'Pushbullet', 'Subtitles'): 'pyTivo', 'Pushalot', 'Pushbullet', 'Subtitles'):
@ -918,12 +919,21 @@ def initialize(console_logging=True):
SAB_CATEGORY = check_setting_str(CFG, 'SABnzbd', 'sab_category', 'tv') SAB_CATEGORY = check_setting_str(CFG, 'SABnzbd', 'sab_category', 'tv')
SAB_HOST = check_setting_str(CFG, 'SABnzbd', 'sab_host', '') SAB_HOST = check_setting_str(CFG, 'SABnzbd', 'sab_host', '')
NZBGET_USERNAME = check_setting_str(CFG, 'NZBget', 'nzbget_username', 'nzbget') # first check using official name case, then with case of legacy
NZBGET_PASSWORD = check_setting_str(CFG, 'NZBget', 'nzbget_password', 'tegbzn6789') # todo: migrate config, (just not atm due to testing map feature)
NZBGET_CATEGORY = check_setting_str(CFG, 'NZBget', 'nzbget_category', 'tv') NZBGET_USERNAME = (check_setting_str(CFG, 'NZBGet', 'nzbget_username', None)
NZBGET_HOST = check_setting_str(CFG, 'NZBget', 'nzbget_host', '') or check_setting_str(CFG, 'NZBget', 'nzbget_username', 'nzbget'))
NZBGET_USE_HTTPS = bool(check_setting_int(CFG, 'NZBget', 'nzbget_use_https', 0)) NZBGET_PASSWORD = (check_setting_str(CFG, 'NZBGet', 'nzbget_password', None)
NZBGET_PRIORITY = check_setting_int(CFG, 'NZBget', 'nzbget_priority', 100) or check_setting_str(CFG, 'NZBget', 'nzbget_password', 'tegbzn6789'))
NZBGET_CATEGORY = (check_setting_str(CFG, 'NZBGet', 'nzbget_category', None)
or check_setting_str(CFG, 'NZBget', 'nzbget_category', 'tv'))
NZBGET_HOST = (check_setting_str(CFG, 'NZBGet', 'nzbget_host', None)
or check_setting_str(CFG, 'NZBget', 'nzbget_host', ''))
NZBGET_USE_HTTPS = (bool(check_setting_int(CFG, 'NZBGet', 'nzbget_use_https', None))
or bool(check_setting_int(CFG, 'NZBget', 'nzbget_use_https', 0)))
NZBGET_PRIORITY = (check_setting_int(CFG, 'NZBGet', 'nzbget_priority', None)
or check_setting_int(CFG, 'NZBget', 'nzbget_priority', 100))
NZBGET_MAP = check_setting_str(CFG, 'NZBGet', 'nzbget_map', '')
try: try:
ng_script_file = ek.ek(os.path.join, ek.ek(os.path.dirname, ek.ek(os.path.dirname, __file__)), ng_script_file = ek.ek(os.path.join, ek.ek(os.path.dirname, ek.ek(os.path.dirname, __file__)),
@ -1758,14 +1768,15 @@ def save_config():
new_config['SABnzbd']['sab_category'] = SAB_CATEGORY new_config['SABnzbd']['sab_category'] = SAB_CATEGORY
new_config['SABnzbd']['sab_host'] = SAB_HOST new_config['SABnzbd']['sab_host'] = SAB_HOST
new_config['NZBget'] = {} new_config['NZBGet'] = {}
new_config['NZBget']['nzbget_username'] = NZBGET_USERNAME new_config['NZBGet']['nzbget_username'] = NZBGET_USERNAME
new_config['NZBget']['nzbget_password'] = helpers.encrypt(NZBGET_PASSWORD, ENCRYPTION_VERSION) new_config['NZBGet']['nzbget_password'] = helpers.encrypt(NZBGET_PASSWORD, ENCRYPTION_VERSION)
new_config['NZBget']['nzbget_category'] = NZBGET_CATEGORY new_config['NZBGet']['nzbget_category'] = NZBGET_CATEGORY
new_config['NZBget']['nzbget_host'] = NZBGET_HOST new_config['NZBGet']['nzbget_host'] = NZBGET_HOST
new_config['NZBget']['nzbget_use_https'] = int(NZBGET_USE_HTTPS) new_config['NZBGet']['nzbget_use_https'] = int(NZBGET_USE_HTTPS)
new_config['NZBget']['nzbget_priority'] = NZBGET_PRIORITY new_config['NZBGet']['nzbget_priority'] = NZBGET_PRIORITY
new_config['NZBGet']['nzbget_map'] = NZBGET_MAP
new_config['TORRENT'] = {} new_config['TORRENT'] = {}
new_config['TORRENT']['torrent_username'] = TORRENT_USERNAME new_config['TORRENT']['torrent_username'] = TORRENT_USERNAME

View file

@ -1728,7 +1728,7 @@ def path_mapper(search, replace, subject):
replace = re.sub(r'[\\]', delim, replace) replace = re.sub(r'[\\]', delim, replace)
path = re.sub(r'[\\]', delim, subject) path = re.sub(r'[\\]', delim, subject)
result = re.sub('(?i)^%s' % search, replace, path) 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 return result, result != subject

View file

@ -30,7 +30,7 @@ def test_nzbget(host, use_https, username, password):
result = False result = False
if not host: if not host:
msg = 'No NZBget host found. Please configure it' msg = 'No NZBGet host found. Please configure it'
logger.log(msg, logger.ERROR) logger.log(msg, logger.ERROR)
return result, msg, None return result, msg, None
@ -49,12 +49,12 @@ def test_nzbget(host, use_https, username, password):
logger.log(u'NZBGet URL: %s' % url, logger.DEBUG) logger.log(u'NZBGet URL: %s' % url, logger.DEBUG)
except moves.http_client.socket.error: except moves.http_client.socket.error:
msg = 'Please check NZBget host and port (if it is running). NZBget is not responding to these values' msg = 'Please check NZBGet host and port (if it is running). NZBGet is not responding to these values'
logger.log(msg, logger.ERROR) logger.log(msg, logger.ERROR)
except moves.xmlrpc_client.ProtocolError as e: except moves.xmlrpc_client.ProtocolError as e:
if 'Unauthorized' == e.errmsg: if 'Unauthorized' == e.errmsg:
msg = 'NZBget username or password is incorrect' msg = 'NZBGet username or password is incorrect'
logger.log(msg, logger.ERROR) logger.log(msg, logger.ERROR)
else: else:
msg = 'Protocol Error: %s' % e.errmsg msg = 'Protocol Error: %s' % e.errmsg
@ -150,11 +150,11 @@ def send_nzb(nzb):
nzbget_prio, False, nzb.url) nzbget_prio, False, nzb.url)
if nzbget_result: if nzbget_result:
logger.log(u'NZB sent to NZBget successfully', logger.DEBUG) logger.log(u'NZB sent to NZBGet successfully', logger.DEBUG)
result = True result = True
else: else:
logger.log(u'NZBget could not add %s to the queue' % ('%s.nzb' % nzb.name), logger.ERROR) logger.log(u'NZBGet could not add %s to the queue' % ('%s.nzb' % nzb.name), logger.ERROR)
except(StandardError, Exception): except(StandardError, Exception):
logger.log(u'Connect Error to NZBget: could not add %s to the queue' % ('%s.nzb' % nzb.name), logger.ERROR) logger.log(u'Connect Error to NZBGet: could not add %s to the queue' % ('%s.nzb' % nzb.name), logger.ERROR)
return result return result

View file

@ -2996,7 +2996,14 @@ class HomePostProcess(Home):
logger.log('Calling SickGear-NG.py script %s is not current version %s, please update.' % 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) (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, process_method=process_method, type=type,
cleanup='cleanup' in kwargs and kwargs['cleanup'] in ['on', '1'], cleanup='cleanup' in kwargs and kwargs['cleanup'] in ['on', '1'],
force=force in ['on', '1'], force=force in ['on', '1'],
@ -5909,9 +5916,10 @@ class ConfigSearch(Config):
pass pass
return t.respond() return t.respond()
def saveSearch(self, use_nzbs=None, use_torrents=None, nzb_dir=None, sab_username=None, sab_password=None, def saveSearch(self, use_nzbs=None, use_torrents=None, nzb_dir=None,
sab_apikey=None, sab_category=None, sab_host=None, nzbget_username=None, nzbget_password=None, sab_host=None, sab_username=None, sab_password=None, sab_apikey=None, sab_category=None,
nzbget_category=None, nzbget_priority=None, nzbget_host=None, nzbget_use_https=None, nzbget_use_https=None, nzbget_host=None, nzbget_username=None, nzbget_password=None,
nzbget_category=None, nzbget_priority=None, nzbget_parent_map=None,
backlog_days=None, backlog_frequency=None, search_unaired=None, unaired_recent_search_only=None, backlog_days=None, backlog_frequency=None, search_unaired=None, unaired_recent_search_only=None,
recentsearch_frequency=None, nzb_method=None, torrent_method=None, usenet_retention=None, recentsearch_frequency=None, nzb_method=None, torrent_method=None, usenet_retention=None,
download_propers=None, propers_webdl_onegrp=None, download_propers=None, propers_webdl_onegrp=None,
@ -5975,6 +5983,7 @@ class ConfigSearch(Config):
sickbeard.NZBGET_HOST = config.clean_host(nzbget_host) sickbeard.NZBGET_HOST = config.clean_host(nzbget_host)
sickbeard.NZBGET_USE_HTTPS = config.checkbox_to_value(nzbget_use_https) sickbeard.NZBGET_USE_HTTPS = config.checkbox_to_value(nzbget_use_https)
sickbeard.NZBGET_PRIORITY = config.to_int(nzbget_priority, default=100) sickbeard.NZBGET_PRIORITY = config.to_int(nzbget_priority, default=100)
sickbeard.NZBGET_MAP = config.kv_csv(nzbget_parent_map)
sickbeard.TORRENT_USERNAME = torrent_username sickbeard.TORRENT_USERNAME = torrent_username
if set('*') != set(torrent_password): if set('*') != set(torrent_password):