Add new feature, check propers interval.

Allow user to select an interval between searches for propers.
This commit is contained in:
JackDandy 2014-05-14 23:23:59 +01:00
parent e0558ea4cd
commit fe74efbf23
4 changed files with 47 additions and 8 deletions

View File

@ -38,13 +38,34 @@
<fieldset class="component-group-list">
<div class="field-pair">
<input type="checkbox" name="download_propers" id="download_propers" #if $sickbeard.DOWNLOAD_PROPERS == True then "checked=\"checked\"" else ""# />
<input type="checkbox" name="download_propers" id="download_propers" class="enabler" #if $sickbeard.DOWNLOAD_PROPERS == True then "checked=\"checked\"" else ""# />
<label class="clearfix" for="download_propers">
<span class="component-title">Download Propers</span>
<span class="component-desc">Replace original download with "Proper/Repack" if nuked?</span>
</label>
</div>
<div id="content_download_propers">
<div class="field-pair">
<label class="nocheck clearfix" for="check_propers_interval">
<span class="component-title">Check Propers Every:</span>
<span class="component-desc">
<select id="check_propers_interval" name="check_propers_interval">
#set $check_propers_interval_text = {'daily': "24 hours", '4h': "4 hours", '90m': "90 mins", '45m': "45 mins", '15m': "15 mins"}
#for $curInterval in ('daily', '4h', '90m', '45m', '15m'):
#if $sickbeard.CHECK_PROPERS_INTERVAL == $curInterval:
#set $selMode = " selected=\"selected\""
#else
#set $selMode = ""
#end if
<option value="$curInterval"$selMode>$check_propers_interval_text[$curInterval]</option>
#end for
</select>
</span>
</label>
</div>
</div>
<div class="field-pair">
<label class="nocheck clearfix">
<span class="component-title">Backlog Search Frequency</span>

View File

@ -173,6 +173,7 @@ USENET_RETENTION = None
TORRENT_METHOD = None
TORRENT_DIR = None
DOWNLOAD_PROPERS = None
CHECK_PROPERS_INTERVAL = None
PREFER_EPISODE_RELEASES = None
ALLOW_HIGH_PRIORITY = None
@ -488,7 +489,7 @@ def initialize(consoleLogging=True):
with INIT_LOCK:
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, \
HANDLE_REVERSE_PROXY, USE_NZBS, USE_TORRENTS, NZB_METHOD, NZB_DIR, DOWNLOAD_PROPERS, CHECK_PROPERS_INTERVAL, 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, NZBGET_USE_HTTPS, backlogSearchScheduler, \
TORRENT_USERNAME, TORRENT_PASSWORD, TORRENT_HOST, TORRENT_PATH, TORRENT_RATIO, TORRENT_SEED_TIME, TORRENT_PAUSED, TORRENT_HIGH_BANDWIDTH, TORRENT_LABEL, TORRENT_VERIFY_CERT, \
@ -662,6 +663,9 @@ def initialize(consoleLogging=True):
TORRENT_METHOD = 'blackhole'
DOWNLOAD_PROPERS = bool(check_setting_int(CFG, 'General', 'download_propers', 1))
CHECK_PROPERS_INTERVAL = check_setting_str(CFG, 'General', 'check_propers_interval', '')
if CHECK_PROPERS_INTERVAL not in ('15m', '45m', '90m', '4h', 'daily'):
CHECK_PROPERS_INTERVAL = 'daily'
PREFER_EPISODE_RELEASES = bool(check_setting_int(CFG, 'General', 'prefer_episode_releases', 0))
@ -1409,6 +1413,7 @@ def save_config():
new_config['General']['backlog_frequency'] = int(BACKLOG_FREQUENCY)
new_config['General']['update_frequency'] = int(UPDATE_FREQUENCY)
new_config['General']['download_propers'] = int(DOWNLOAD_PROPERS)
new_config['General']['check_propers_interval'] = CHECK_PROPERS_INTERVAL
new_config['General']['prefer_episode_releases'] = int(PREFER_EPISODE_RELEASES)
new_config['General']['allow_high_priority'] = int(ALLOW_HIGH_PRIORITY)
new_config['General']['rssupdate_startup'] = int(RSSUPDATE_STARTUP)

View File

@ -39,6 +39,11 @@ class ProperFinder():
def __init__(self):
self.updateInterval = datetime.timedelta(hours=1)
check_propers_interval = {'15m': 15, '45m': 45, '90m': 90, '4h': 4*60, 'daily': 24*60}
for curInterval in ('15m', '45m', '90m', '4h', 'daily'):
if sickbeard.CHECK_PROPERS_INTERVAL == curInterval:
self.updateInterval = datetime.timedelta(minutes = check_propers_interval[curInterval])
def run(self):
if not sickbeard.DOWNLOAD_PROPERS:
@ -52,11 +57,12 @@ class ProperFinder():
hourDiff = datetime.datetime.today().time().hour - updateTime.hour
dayDiff = (datetime.date.today() - self._get_lastProperSearch()).days
# if it's less than an interval after the update time then do an update
if hourDiff >= 0 and hourDiff < self.updateInterval.seconds / 3600 or dayDiff >= 1:
logger.log(u"Beginning the search for new propers")
else:
return
if sickbeard.CHECK_PROPERS_INTERVAL == "daily":
# if it's less than an interval after the update time then do an update
if not (hourDiff >= 0 and hourDiff < self.updateInterval.seconds / 3600 or dayDiff >= 1):
return
logger.log(u"Beginning the search for new propers")
propers = self._getProperList()
@ -64,6 +70,12 @@ class ProperFinder():
self._set_lastProperSearch(datetime.datetime.today().toordinal())
msg = u"Completed the search for new propers, next check "
if sickbeard.CHECK_PROPERS_INTERVAL == "daily":
logger.log(u"%sat 1am tomorrow" % msg)
else:
logger.log(u"%sin ~%s" % (msg, sickbeard.CHECK_PROPERS_INTERVAL))
def _getProperList(self):
propers = {}

View File

@ -1054,7 +1054,7 @@ class ConfigSearch:
sab_apikey=None, sab_category=None, sab_host=None, nzbget_username=None, nzbget_password=None,
nzbget_category=None, nzbget_host=None, nzbget_use_https=None,
nzb_method=None, torrent_method=None, usenet_retention=None, rssupdate_frequency=None, backlog_frequency=None,
download_propers=None, prefer_episode_releases=None, allow_high_priority=None, backlog_startup=None,
download_propers=None, check_propers_interval=None, prefer_episode_releases=None, allow_high_priority=None, backlog_startup=None,
torrent_dir=None, torrent_username=None, torrent_password=None, torrent_host=None, rssupdate_startup=None,
torrent_label=None, torrent_path=None, torrent_verify_cert=None,
torrent_ratio=None, torrent_seed_time=None, torrent_paused=None, torrent_high_bandwidth=None, ignore_words=None):
@ -1083,6 +1083,7 @@ class ConfigSearch:
sickbeard.properFinderScheduler.silent = False
else:
sickbeard.properFinderScheduler.silent = True
sickbeard.CHECK_PROPERS_INTERVAL = check_propers_interval
sickbeard.PREFER_EPISODE_RELEASES = config.checkbox_to_value(prefer_episode_releases)
sickbeard.ALLOW_HIGH_PRIORITY = config.checkbox_to_value(allow_high_priority)