From 53f272515a260f0b2f3265fc33f583a1e886486a Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Thu, 9 Apr 2015 19:24:35 +0200 Subject: [PATCH] Fix Backlog Init Fix the limited backlog to execute as and when expected and in line with SickBeard. The backlog scheduled frequency is the higher of either 12 hours or 2 x the "Recent search frequency" + 7 minutes. On application startup and every backlog scheduled frequency the backlog will either ... a) do a full run if the number of days passed since the full backlog has reached the setting(1)... b) do a limited run if the number of days passed since the full backlog is less than setting(1)... ... (1) "Backlog search frequency" in Search Settings. Change the default full "Backlog search frequency" to 21 days within a range of 2 - 35 (see Search Settings). --- CHANGES.md | 3 ++- gui/slick/interfaces/default/config_search.tmpl | 2 +- gui/slick/interfaces/default/inc_bottom.tmpl | 1 + sickbeard/__init__.py | 14 ++++++-------- sickbeard/config.py | 14 +++++++------- sickbeard/searchBacklog.py | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 1d496a56..d517348d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,7 @@ -### 0.x.x (2015-xx-xx xx:xx:xx UTC) +### 0.x.x (2015-xx-xx xx:xx:xx UTC) * Add ToTV provider +* Fix Backlog scheduler initialization and change backlog frequency from minutes to days ### 0.8.1 (2015-04-15 04:16:00 UTC) diff --git a/gui/slick/interfaces/default/config_search.tmpl b/gui/slick/interfaces/default/config_search.tmpl index 63c6a362..6cb246dc 100755 --- a/gui/slick/interfaces/default/config_search.tmpl +++ b/gui/slick/interfaces/default/config_search.tmpl @@ -95,7 +95,7 @@ Backlog search frequency -

minutes between searches (minimum $sickbeard.MIN_BACKLOG_FREQUENCY)

+

days between full backlog searches (min $sickbeard.MIN_BACKLOG_FREQUENCY, default $sickbeard.DEFAULT_BACKLOG_FREQUENCY, max $sickbeard.MAX_BACKLOG_FREQUENCY)

diff --git a/gui/slick/interfaces/default/inc_bottom.tmpl b/gui/slick/interfaces/default/inc_bottom.tmpl index e8fef222..abd697f6 100644 --- a/gui/slick/interfaces/default/inc_bottom.tmpl +++ b/gui/slick/interfaces/default/inc_bottom.tmpl @@ -62,6 +62,7 @@ %> / $ep_total episodes downloaded $ep_percentage | recent search: <%= str(sickbeard.recentSearchScheduler.timeLeft()).split('.')[0] %> | backlog search: <%= str(sickbeard.backlogSearchScheduler.timeLeft()).split('.')[0] %> + | full backlog: <%= sbdatetime.sbdatetime.sbfdate(sickbeard.backlogSearchScheduler.nextRun()) %> #slurp diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index d5c9879e..267d39bd 100755 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -60,7 +60,7 @@ CFG = None CONFIG_FILE = None # This is the version of the config we EXPECT to find -CONFIG_VERSION = 9 +CONFIG_VERSION = 10 # Default encryption version (0 for None) ENCRYPTION_VERSION = 0 @@ -220,7 +220,8 @@ DEFAULT_UPDATE_FREQUENCY = 1 MIN_AUTOPOSTPROCESSER_FREQUENCY = 1 MIN_RECENTSEARCH_FREQUENCY = 10 -MIN_BACKLOG_FREQUENCY = 10 +MIN_BACKLOG_FREQUENCY = 2 +MAX_BACKLOG_FREQUENCY = 35 MIN_UPDATE_FREQUENCY = 1 BACKLOG_DAYS = 7 @@ -496,7 +497,7 @@ def initialize(consoleLogging=True): USE_KODI, KODI_ALWAYS_ON, KODI_NOTIFY_ONSNATCH, KODI_NOTIFY_ONDOWNLOAD, KODI_NOTIFY_ONSUBTITLEDOWNLOAD, KODI_UPDATE_FULL, KODI_UPDATE_ONLYFIRST, KODI_UPDATE_LIBRARY, KODI_HOST, KODI_USERNAME, KODI_PASSWORD, \ USE_TRAKT, TRAKT_USERNAME, TRAKT_PASSWORD, TRAKT_API, TRAKT_REMOVE_WATCHLIST, TRAKT_USE_WATCHLIST, TRAKT_METHOD_ADD, TRAKT_START_PAUSED, traktCheckerScheduler, TRAKT_USE_RECOMMENDED, TRAKT_SYNC, TRAKT_DEFAULT_INDEXER, TRAKT_REMOVE_SERIESLIST, \ USE_PLEX, PLEX_NOTIFY_ONSNATCH, PLEX_NOTIFY_ONDOWNLOAD, PLEX_NOTIFY_ONSUBTITLEDOWNLOAD, PLEX_UPDATE_LIBRARY, \ - PLEX_SERVER_HOST, PLEX_HOST, PLEX_USERNAME, PLEX_PASSWORD, DEFAULT_BACKLOG_FREQUENCY, MIN_BACKLOG_FREQUENCY, BACKLOG_STARTUP, SKIP_REMOVED_FILES, \ + PLEX_SERVER_HOST, PLEX_HOST, PLEX_USERNAME, PLEX_PASSWORD, DEFAULT_BACKLOG_FREQUENCY, MIN_BACKLOG_FREQUENCY, MAX_BACKLOG_FREQUENCY, BACKLOG_STARTUP, SKIP_REMOVED_FILES, \ showUpdateScheduler, __INITIALIZED__, LAUNCH_BROWSER, TRASH_REMOVE_SHOW, TRASH_ROTATE_LOGS, HOME_SEARCH_FOCUS, SORT_ARTICLE, showList, loadingShowList, UPDATE_SHOWS_ON_START, SHOW_UPDATE_HOUR, \ NEWZNAB_DATA, NZBS, NZBS_UID, NZBS_HASH, INDEXER_DEFAULT, INDEXER_TIMEOUT, USENET_RETENTION, TORRENT_DIR, \ QUALITY_DEFAULT, FLATTEN_FOLDERS_DEFAULT, SUBTITLES_DEFAULT, STATUS_DEFAULT, WANTED_BEGIN_DEFAULT, WANTED_LATEST_DEFAULT, RECENTSEARCH_STARTUP, \ @@ -727,10 +728,8 @@ def initialize(consoleLogging=True): if RECENTSEARCH_FREQUENCY < MIN_RECENTSEARCH_FREQUENCY: RECENTSEARCH_FREQUENCY = MIN_RECENTSEARCH_FREQUENCY - MIN_BACKLOG_FREQUENCY = get_backlog_cycle_time() BACKLOG_FREQUENCY = check_setting_int(CFG, 'General', 'backlog_frequency', DEFAULT_BACKLOG_FREQUENCY) - if BACKLOG_FREQUENCY < MIN_BACKLOG_FREQUENCY: - BACKLOG_FREQUENCY = MIN_BACKLOG_FREQUENCY + BACKLOG_FREQUENCY = minimax(BACKLOG_FREQUENCY, DEFAULT_BACKLOG_FREQUENCY, MIN_BACKLOG_FREQUENCY, MAX_BACKLOG_FREQUENCY) UPDATE_FREQUENCY = check_setting_int(CFG, 'General', 'update_frequency', DEFAULT_UPDATE_FREQUENCY) if UPDATE_FREQUENCY < MIN_UPDATE_FREQUENCY: @@ -1173,9 +1172,8 @@ def initialize(consoleLogging=True): run_delay=update_now if RECENTSEARCH_STARTUP else datetime.timedelta(minutes=5)) - update_interval = datetime.timedelta(minutes=BACKLOG_FREQUENCY) backlogSearchScheduler = searchBacklog.BacklogSearchScheduler(searchBacklog.BacklogSearcher(), - cycleTime=update_interval, + cycleTime=datetime.timedelta(minutes=get_backlog_cycle_time()), threadName="BACKLOG", run_delay=update_now if BACKLOG_STARTUP else datetime.timedelta(minutes=10)) diff --git a/sickbeard/config.py b/sickbeard/config.py index bd4d2cc6..7f0d629e 100644 --- a/sickbeard/config.py +++ b/sickbeard/config.py @@ -164,13 +164,9 @@ def change_RECENTSEARCH_FREQUENCY(freq): def change_BACKLOG_FREQUENCY(freq): - sickbeard.BACKLOG_FREQUENCY = to_int(freq, default=sickbeard.DEFAULT_BACKLOG_FREQUENCY) + sickbeard.BACKLOG_FREQUENCY = minimax(freq, sickbeard.DEFAULT_BACKLOG_FREQUENCY, sickbeard.MIN_BACKLOG_FREQUENCY, sickbeard.MAX_BACKLOG_FREQUENCY) - sickbeard.MIN_BACKLOG_FREQUENCY = sickbeard.get_backlog_cycle_time() - if sickbeard.BACKLOG_FREQUENCY < sickbeard.MIN_BACKLOG_FREQUENCY: - sickbeard.BACKLOG_FREQUENCY = sickbeard.MIN_BACKLOG_FREQUENCY - - sickbeard.backlogSearchScheduler.cycleTime = datetime.timedelta(minutes=sickbeard.BACKLOG_FREQUENCY) + sickbeard.backlogSearchScheduler.action.cycleTime = sickbeard.BACKLOG_FREQUENCY def change_UPDATE_FREQUENCY(freq): @@ -740,4 +736,8 @@ class ConfigMigrator(): def _migrate_v9(self): sickbeard.PUSHBULLET_ACCESS_TOKEN = check_setting_str(self.config_obj, 'Pushbullet', 'pushbullet_api', '') - sickbeard.PUSHBULLET_DEVICE_IDEN = check_setting_str(self.config_obj, 'Pushbullet', 'pushbullet_device', '') \ No newline at end of file + sickbeard.PUSHBULLET_DEVICE_IDEN = check_setting_str(self.config_obj, 'Pushbullet', 'pushbullet_device', '') + + def _migrate_v10(self): + # reset backlog frequency to default + sickbeard.BACKLOG_FREQUENCY = sickbeard.DEFAULT_BACKLOG_FREQUENCY \ No newline at end of file diff --git a/sickbeard/searchBacklog.py b/sickbeard/searchBacklog.py index ab5a6605..81a2ff29 100644 --- a/sickbeard/searchBacklog.py +++ b/sickbeard/searchBacklog.py @@ -48,7 +48,7 @@ class BacklogSearcher: def __init__(self): self._lastBacklog = self._get_lastBacklog() - self.cycleTime = sickbeard.BACKLOG_FREQUENCY / 60 / 24 + self.cycleTime = sickbeard.BACKLOG_FREQUENCY self.lock = threading.Lock() self.amActive = False self.amPaused = False