Merging changes from Prinz23, PR#156

This commit is contained in:
Nils Vogels 2014-05-06 00:48:28 +02:00
parent 27d6eff633
commit b177c1ade2
5 changed files with 55 additions and 24 deletions

View File

@ -215,6 +215,18 @@
</div>
<div id="nzbget_settings">
<div class="field-pair">
<input id="nzbget_use_https" type="checkbox" class="enabler" name="nzbget_use_https" #if $sickbeard.NZBGET_USE_HTTPS == True then "checked=\"checked\"" else ""# />
<label class="clearfix" for="use_failed_downloads">
<span class="component-title">Use HTTPS (SSL)</span>
<span class="component-desc">Use HTTPS to connect to NZBGet?</span>
</label>
<label class="nocheck clearfix" for="nzbget_use_https">
<span class="component-title">&nbsp;</span>
<span class="component-desc"><b>NOTE:</b> You have to enable Secure control in NZBGet and set the correct Secure Port here.</span>
</label>
</div>
<div class="field-pair">
<label class="nocheck clearfix">
<span class="component-title">NZBget HOST:PORT</span>

View File

@ -277,6 +277,7 @@ NZBGET_USERNAME = None
NZBGET_PASSWORD = None
NZBGET_CATEGORY = None
NZBGET_HOST = None
NZBGET_USE_HTTPS = False
TORRENT_USERNAME = None
TORRENT_PASSWORD = None
@ -464,7 +465,7 @@ def initialize(consoleLogging=True):
global ACTUAL_LOG_DIR, LOG_DIR, WEB_PORT, WEB_LOG, ENCRYPTION_VERSION, WEB_ROOT, WEB_USERNAME, WEB_PASSWORD, WEB_HOST, WEB_IPV6, USE_API, API_KEY, ENABLE_HTTPS, HTTPS_CERT, HTTPS_KEY, \
HANDLE_REVERSE_PROXY, USE_NZBS, USE_TORRENTS, NZB_METHOD, NZB_DIR, DOWNLOAD_PROPERS, PREFER_EPISODE_RELEASES, ALLOW_HIGH_PRIORITY, TORRENT_METHOD, \
SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, SAB_HOST, \
NZBGET_USERNAME, NZBGET_PASSWORD, NZBGET_CATEGORY, NZBGET_HOST, currentSearchScheduler, backlogSearchScheduler, \
NZBGET_USERNAME, NZBGET_PASSWORD, NZBGET_CATEGORY, NZBGET_HOST, NZBGET_USE_HTTPS, currentSearchScheduler, backlogSearchScheduler, \
TORRENT_USERNAME, TORRENT_PASSWORD, TORRENT_HOST, TORRENT_PATH, TORRENT_RATIO, TORRENT_SEED_TIME, TORRENT_PAUSED, TORRENT_HIGH_BANDWIDTH, TORRENT_LABEL, \
USE_XBMC, XBMC_NOTIFY_ONSNATCH, XBMC_NOTIFY_ONDOWNLOAD, XBMC_NOTIFY_ONSUBTITLEDOWNLOAD, XBMC_UPDATE_FULL, XBMC_UPDATE_ONLYFIRST, \
XBMC_UPDATE_LIBRARY, XBMC_HOST, XBMC_USERNAME, XBMC_PASSWORD, \
@ -752,6 +753,7 @@ def initialize(consoleLogging=True):
NZBGET_PASSWORD = check_setting_str(CFG, 'NZBget', 'nzbget_password', 'tegbzn6789')
NZBGET_CATEGORY = check_setting_str(CFG, 'NZBget', 'nzbget_category', 'tv')
NZBGET_HOST = check_setting_str(CFG, 'NZBget', 'nzbget_host', '')
NZBGET_USE_HTTPS = bool(check_setting_int(CFG, 'NZBget', 'nzbget_use_https', 0))
TORRENT_USERNAME = check_setting_str(CFG, 'TORRENT', 'torrent_username', '')
TORRENT_PASSWORD = check_setting_str(CFG, 'TORRENT', 'torrent_password', '')
@ -1484,6 +1486,7 @@ def save_config():
new_config['NZBget']['nzbget_password'] = helpers.encrypt(NZBGET_PASSWORD, ENCRYPTION_VERSION)
new_config['NZBget']['nzbget_category'] = NZBGET_CATEGORY
new_config['NZBget']['nzbget_host'] = NZBGET_HOST
new_config['NZBget']['nzbget_use_https'] = int(NZBGET_USE_HTTPS)
new_config['TORRENT'] = {}
new_config['TORRENT']['torrent_username'] = TORRENT_USERNAME

View File

@ -37,7 +37,11 @@ from common import Quality
def sendNZB(nzb, proper=False):
addToTop = False
nzbgetprio = 0
nzbgetXMLrpc = "http://%(username)s:%(password)s@%(host)s/xmlrpc"
if sickbeard.NZBGET_USE_HTTPS:
nzbgetXMLrpc = "https://%(username)s:%(password)s@%(host)s/xmlrpc"
else:
nzbgetXMLrpc = "http://%(username)s:%(password)s@%(host)s/xmlrpc"
if sickbeard.NZBGET_HOST == None:
logger.log(u"No NZBget host found in configuration. Please configure it.", logger.ERROR)
@ -71,7 +75,10 @@ def sendNZB(nzb, proper=False):
# if it aired recently make it high priority and generate DupeKey/Score
for curEp in nzb.episodes:
if dupekey == "":
dupekey = "Sickbeard-" + str(curEp.show.indexerid)
if curEp.show.indexer == 1:
dupekey = "Sickbeard-" + str(curEp.show.indexerid)
elif curEp.show.indexer == 2:
dupekey = "Sickbeard-tvr" + str(curEp.show.indexerid)
dupekey += "-" + str(curEp.season) + "." + str(curEp.episode)
if datetime.date.today() - curEp.airdate <= datetime.timedelta(days=7):
addToTop = True
@ -82,18 +89,10 @@ def sendNZB(nzb, proper=False):
if proper:
dupescore += 10
# if it's a normal result need to download the NZB content
if nzb.resultType == "nzb":
genProvider = GenericProvider("")
data = genProvider.getURL(nzb.url)
if (data == None):
return False
# if we get a raw data result thats even better
elif nzb.resultType == "nzbdata":
nzbcontent64 = None
if nzb.resultType == "nzbdata":
data = nzb.extraInfo[0]
nzbcontent64 = standard_b64encode(data)
nzbcontent64 = standard_b64encode(data)
logger.log(u"Sending NZB to NZBget")
logger.log(u"URL: " + url, logger.DEBUG)
@ -103,13 +102,30 @@ def sendNZB(nzb, proper=False):
nzbget_version_str = nzbGetRPC.version()
nzbget_version = helpers.tryInt(nzbget_version_str[:nzbget_version_str.find(".")])
if nzbget_version == 0:
if nzbcontent64 is not None:
nzbget_result = nzbGetRPC.append(nzb.name + ".nzb", sickbeard.NZBGET_CATEGORY, addToTop, nzbcontent64)
else:
if nzb.resultType == "nzb":
genProvider = GenericProvider("")
data = genProvider.getURL(nzb.url)
if (data == None):
return False
nzbcontent64 = standard_b64encode(data)
nzbget_result = nzbGetRPC.append(nzb.name + ".nzb", sickbeard.NZBGET_CATEGORY, addToTop, nzbcontent64)
elif nzbget_version >= 12:
nzbget_result = nzbGetRPC.append(nzb.name + ".nzb", sickbeard.NZBGET_CATEGORY, nzbgetprio, False,
nzbcontent64, False, dupekey, dupescore, "score")
if nzbcontent64 is not None:
nzbget_result = nzbGetRPC.append(nzb.name + ".nzb", sickbeard.NZBGET_CATEGORY, nzbgetprio, False,
nzbcontent64, False, dupekey, dupescore, "score")
else:
nzbget_result = nzbGetRPC.appendurl(nzb.name + ".nzb", sickbeard.NZBGET_CATEGORY, nzbgetprio, False,
nzb.url, False, dupekey, dupescore, "score")
else:
nzbget_result = nzbGetRPC.append(nzb.name + ".nzb", sickbeard.NZBGET_CATEGORY, nzbgetprio, False,
nzbcontent64)
if nzbcontent64 is not None:
nzbget_result = nzbGetRPC.append(nzb.name + ".nzb", sickbeard.NZBGET_CATEGORY, nzbgetprio, False,
nzbcontent64)
else:
nzbget_result = nzbGetRPC.appendurl(nzb.name + ".nzb", sickbeard.NZBGET_CATEGORY, nzbgetprio, False,
nzb.url)
if nzbget_result:
logger.log(u"NZB sent to NZBget successfully", logger.DEBUG)

View File

@ -116,6 +116,8 @@ def snatchEpisode(result, endStatus=SNATCHED):
for curEp in result.episodes:
if datetime.date.today() - curEp.airdate <= datetime.timedelta(days=7):
result.priority = 1
if re.search('(^|[\. _-])(proper|repack)([\. _-]|$)', result.name, re.I) != None:
endStatus = SNATCHED_PROPER
# NZBs can be sent straight to SAB or saved to disk
if result.resultType in ("nzb", "nzbdata"):
@ -124,11 +126,8 @@ def snatchEpisode(result, endStatus=SNATCHED):
elif sickbeard.NZB_METHOD == "sabnzbd":
dlResult = sab.sendNZB(result)
elif sickbeard.NZB_METHOD == "nzbget":
if endStatus == SNATCHED_PROPER:
s_prop = True
else:
s_prop = False
dlResult = nzbget.sendNZB(result, s_prop)
is_proper = True if endStatus == SNATCHED_PROPER else False
dlResult = nzbget.sendNZB(result, is_proper)
else:
logger.log(u"Unknown NZB action specified in config: " + sickbeard.NZB_METHOD, logger.ERROR)
dlResult = False

View File

@ -1063,7 +1063,7 @@ class ConfigSearch:
@cherrypy.expose
def saveSearch(self, use_nzbs=None, use_torrents=None, nzb_dir=None, sab_username=None, sab_password=None,
sab_apikey=None, sab_category=None, sab_host=None, nzbget_username=None, nzbget_password=None,
nzbget_category=None, nzbget_host=None,
nzbget_category=None, nzbget_host=None, nzbget_use_https=None,
nzb_method=None, torrent_method=None, usenet_retention=None, search_frequency=None,
download_propers=None, prefer_episode_releases=None, allow_high_priority=None,
torrent_dir=None, torrent_username=None, torrent_password=None, torrent_host=None,
@ -1108,6 +1108,7 @@ class ConfigSearch:
sickbeard.NZBGET_PASSWORD = nzbget_password
sickbeard.NZBGET_CATEGORY = nzbget_category
sickbeard.NZBGET_HOST = config.clean_host(nzbget_host)
sickbeard.NZBGET_USE_HTTPS = config.checkbox_to_value(nzbget_use_https)
sickbeard.TORRENT_USERNAME = torrent_username
sickbeard.TORRENT_PASSWORD = torrent_password