From 55f27c4f400934c68147e7ea96c8fe4b16c389b8 Mon Sep 17 00:00:00 2001 From: echel0n Date: Sat, 17 May 2014 11:14:48 -0700 Subject: [PATCH] rss cache updates and daily search have been joined into one function. fixed more issues of missing vars causing saving of config issues. --- .../interfaces/default/config_search.tmpl | 18 ------- gui/slick/interfaces/default/inc_bottom.tmpl | 1 - .../default/manage_manageSearches.tmpl | 9 ---- sickbeard/__init__.py | 40 +++------------- sickbeard/config.py | 8 ---- sickbeard/dailysearcher.py | 11 +++-- sickbeard/providers/generic.py | 4 +- sickbeard/rssupdater.py | 47 ------------------- sickbeard/subtitles.py | 4 ++ sickbeard/tv.py | 5 +- sickbeard/webserve.py | 19 +------- 11 files changed, 26 insertions(+), 140 deletions(-) delete mode 100644 sickbeard/rssupdater.py diff --git a/gui/slick/interfaces/default/config_search.tmpl b/gui/slick/interfaces/default/config_search.tmpl index 66200403..ad5a0e37 100644 --- a/gui/slick/interfaces/default/config_search.tmpl +++ b/gui/slick/interfaces/default/config_search.tmpl @@ -77,17 +77,6 @@ -
- - -
-
-
- - -
diff --git a/gui/slick/interfaces/default/manage_manageSearches.tmpl b/gui/slick/interfaces/default/manage_manageSearches.tmpl index 08ff2fe2..0aa359fa 100644 --- a/gui/slick/interfaces/default/manage_manageSearches.tmpl +++ b/gui/slick/interfaces/default/manage_manageSearches.tmpl @@ -36,15 +36,6 @@ In Progress
#end if
-

RSS Cache Update:

- Force -#if not $rssStatus: -Not in progress
-#else: -In Progress
-#end if -
-

Version Check:

Force Check
diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index 868af57f..005442fb 100644 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -40,7 +40,6 @@ from sickbeard import searchBacklog, showUpdater, versionChecker, properFinder, from sickbeard import helpers, db, exceptions, show_queue, search_queue, scheduler, show_name_helpers from sickbeard import logger from sickbeard import naming -from sickbeard import rssupdater from sickbeard import dailysearcher from sickbeard import scene_numbering, scene_exceptions, name_cache from indexers.indexer_api import indexerApi @@ -186,20 +185,16 @@ PREFER_EPISODE_RELEASES = None ALLOW_HIGH_PRIORITY = None DAILYSEARCH_FREQUENCY = None -RSSUPDATE_FREQUENCY = None UPDATE_FREQUENCY = None BACKLOG_FREQUENCY = None DAILYSEARCH_STARTUP = None -RSSUPDATE_STARTUP = None BACKLOG_STARTUP = None MIN_BACKLOG_FREQUENCY = 10 -MIN_RSSUPDATE_FREQUENCY = 10 MIN_DAILYSEARCH_FREQUENCY = 10 MIN_UPDATE_FREQUENCY = 1 DEFAULT_BACKLOG_FREQUENCY = 10080 -DEFAULT_RSSUPDATE_FREQUENCY = 60 -DEFAULT_DAILYSEARCH_FREQUENCY = 30 +DEFAULT_DAILYSEARCH_FREQUENCY = 60 DEFAULT_UPDATE_FREQUENCY = 1 ADD_SHOWS_WO_DIR = None @@ -432,20 +427,20 @@ def initialize(consoleLogging=True): 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, \ USE_XBMC, XBMC_ALWAYS_ON, XBMC_NOTIFY_ONSNATCH, XBMC_NOTIFY_ONDOWNLOAD, XBMC_NOTIFY_ONSUBTITLEDOWNLOAD, XBMC_UPDATE_FULL, XBMC_UPDATE_ONLYFIRST, \ - XBMC_UPDATE_LIBRARY, XBMC_HOST, XBMC_USERNAME, XBMC_PASSWORD, \ + XBMC_UPDATE_LIBRARY, XBMC_HOST, XBMC_USERNAME, XBMC_PASSWORD, BACKLOG_FREQUENCY, \ USE_TRAKT, TRAKT_USERNAME, TRAKT_PASSWORD, TRAKT_API, TRAKT_REMOVE_WATCHLIST, TRAKT_USE_WATCHLIST, TRAKT_METHOD_ADD, TRAKT_START_PAUSED, traktWatchListCheckerSchedular, \ 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, \ showUpdateScheduler, __INITIALIZED__, LAUNCH_BROWSER, UPDATE_SHOWS_ON_START, SORT_ARTICLE, showList, loadingShowList, \ - NEWZNAB_DATA, NZBS, NZBS_UID, NZBS_HASH, INDEXER_DEFAULT, USENET_RETENTION, TORRENT_DIR, RSSUPDATE_FREQUENCY, \ - QUALITY_DEFAULT, FLATTEN_FOLDERS_DEFAULT, SUBTITLES_DEFAULT, STATUS_DEFAULT, RSSUPDATE_STARTUP, DAILYSEARCH_STARTUP,\ + NEWZNAB_DATA, NZBS, NZBS_UID, NZBS_HASH, INDEXER_DEFAULT, USENET_RETENTION, TORRENT_DIR,\ + QUALITY_DEFAULT, FLATTEN_FOLDERS_DEFAULT, SUBTITLES_DEFAULT, STATUS_DEFAULT, DAILYSEARCH_STARTUP,\ GROWL_NOTIFY_ONSNATCH, GROWL_NOTIFY_ONDOWNLOAD, GROWL_NOTIFY_ONSUBTITLEDOWNLOAD, TWITTER_NOTIFY_ONSNATCH, TWITTER_NOTIFY_ONDOWNLOAD, TWITTER_NOTIFY_ONSUBTITLEDOWNLOAD, \ USE_GROWL, GROWL_HOST, GROWL_PASSWORD, USE_PROWL, PROWL_NOTIFY_ONSNATCH, PROWL_NOTIFY_ONDOWNLOAD, PROWL_NOTIFY_ONSUBTITLEDOWNLOAD, PROWL_API, PROWL_PRIORITY, PROG_DIR, \ USE_PYTIVO, PYTIVO_NOTIFY_ONSNATCH, PYTIVO_NOTIFY_ONDOWNLOAD, PYTIVO_NOTIFY_ONSUBTITLEDOWNLOAD, PYTIVO_UPDATE_LIBRARY, PYTIVO_HOST, PYTIVO_SHARE_NAME, PYTIVO_TIVO_NAME, \ USE_NMA, NMA_NOTIFY_ONSNATCH, NMA_NOTIFY_ONDOWNLOAD, NMA_NOTIFY_ONSUBTITLEDOWNLOAD, NMA_API, NMA_PRIORITY, \ USE_PUSHALOT, PUSHALOT_NOTIFY_ONSNATCH, PUSHALOT_NOTIFY_ONDOWNLOAD, PUSHALOT_NOTIFY_ONSUBTITLEDOWNLOAD, PUSHALOT_AUTHORIZATIONTOKEN, \ USE_PUSHBULLET, PUSHBULLET_NOTIFY_ONSNATCH, PUSHBULLET_NOTIFY_ONDOWNLOAD, PUSHBULLET_NOTIFY_ONSUBTITLEDOWNLOAD, PUSHBULLET_API, PUSHBULLET_DEVICE, \ - versionCheckScheduler, VERSION_NOTIFY, AUTO_UPDATE, PROCESS_AUTOMATICALLY, UNPACK, CPU_PRESET, MIN_RSSUPDATE_FREQUENCY, \ + versionCheckScheduler, VERSION_NOTIFY, AUTO_UPDATE, PROCESS_AUTOMATICALLY, UNPACK, CPU_PRESET, \ KEEP_PROCESSED_DIR, PROCESS_METHOD, TV_DOWNLOAD_DIR, MIN_DAILYSEARCH_FREQUENCY, DEFAULT_UPDATE_FREQUENCY, MIN_UPDATE_FREQUENCY, UPDATE_FREQUENCY, \ showQueueScheduler, searchQueueScheduler, ROOT_DIRS, CACHE_DIR, ACTUAL_CACHE_DIR, TIMEZONE_DISPLAY, \ NAMING_PATTERN, NAMING_MULTI_EP, NAMING_FORCE_FOLDERS, NAMING_ABD_PATTERN, NAMING_CUSTOM_ABD, NAMING_SPORTS_PATTERN, NAMING_CUSTOM_SPORTS, NAMING_STRIP_YEAR, \ @@ -608,7 +603,6 @@ def initialize(consoleLogging=True): ALLOW_HIGH_PRIORITY = bool(check_setting_int(CFG, 'General', 'allow_high_priority', 1)) DAILYSEARCH_STARTUP = bool(check_setting_int(CFG, 'General', 'dailysearch_startup', 1)) - RSSUPDATE_STARTUP = bool(check_setting_int(CFG, 'General', 'rssupdate_startup', 1)) BACKLOG_STARTUP = bool(check_setting_int(CFG, 'General', 'backlog_startup', 1)) USENET_RETENTION = check_setting_int(CFG, 'General', 'usenet_retention', 500) @@ -617,10 +611,6 @@ def initialize(consoleLogging=True): if DAILYSEARCH_FREQUENCY < MIN_DAILYSEARCH_FREQUENCY: DAILYSEARCH_FREQUENCY = MIN_DAILYSEARCH_FREQUENCY - RSSUPDATE_FREQUENCY = check_setting_int(CFG, 'General', 'rssupdate_frequency', DEFAULT_RSSUPDATE_FREQUENCY) - if RSSUPDATE_FREQUENCY < MIN_RSSUPDATE_FREQUENCY: - RSSUPDATE_FREQUENCY = MIN_RSSUPDATE_FREQUENCY - BACKLOG_FREQUENCY = check_setting_int(CFG, 'General', 'backlog_frequency', DEFAULT_BACKLOG_FREQUENCY) if BACKLOG_FREQUENCY < MIN_BACKLOG_FREQUENCY: BACKLOG_FREQUENCY = MIN_BACKLOG_FREQUENCY @@ -985,12 +975,6 @@ def initialize(consoleLogging=True): threadName="FINDSUBTITLES", runImmediately=True) - updateRSSScheduler = scheduler.Scheduler(rssupdater.RSSUpdater(), - cycleTime=datetime.timedelta(minutes=RSSUPDATE_FREQUENCY), - threadName="RSSUPDATER", - silent=True, - runImmediately=RSSUPDATE_STARTUP) - if not USE_SUBTITLES: subtitlesFinderScheduler.silent = True @@ -1064,7 +1048,7 @@ def start(): showUpdateScheduler, versionCheckScheduler, showQueueScheduler, \ properFinderScheduler, autoPostProcesserScheduler, searchQueueScheduler, \ subtitlesFinderScheduler, started, USE_SUBTITLES, \ - traktWatchListCheckerSchedular, updateRSSScheduler, dailySearchScheduler, started + traktWatchListCheckerSchedular, dailySearchScheduler, started with INIT_LOCK: @@ -1073,9 +1057,6 @@ def start(): # start the version checker versionCheckScheduler.thread.start() - # start the RSS cache updater - updateRSSScheduler.thread.start() - # start the daily search scheduler dailySearchScheduler.thread.start() @@ -1191,13 +1172,6 @@ def halt(): except: pass - updateRSSScheduler.abort = True - logger.log(u"Waiting for the RSSUPDATER thread to exit") - try: - updateRSSScheduler.thread.join(10) - except: - pass - __INITIALIZED__ = False @@ -1335,7 +1309,6 @@ def save_config(): new_config['General']['torrent_method'] = TORRENT_METHOD new_config['General']['usenet_retention'] = int(USENET_RETENTION) new_config['General']['dailysearch_frequency'] = int(DAILYSEARCH_FREQUENCY) - new_config['General']['rssupdate_frequency'] = int(RSSUPDATE_FREQUENCY) new_config['General']['backlog_frequency'] = int(BACKLOG_FREQUENCY) new_config['General']['update_frequency'] = int(UPDATE_FREQUENCY) new_config['General']['download_propers'] = int(DOWNLOAD_PROPERS) @@ -1343,7 +1316,6 @@ def save_config(): new_config['General']['prefer_episode_releases'] = int(PREFER_EPISODE_RELEASES) new_config['General']['allow_high_priority'] = int(ALLOW_HIGH_PRIORITY) new_config['General']['dailysearch_startup'] = int(DAILYSEARCH_STARTUP) - new_config['General']['rssupdate_startup'] = int(RSSUPDATE_STARTUP) new_config['General']['backlog_startup'] = int(BACKLOG_STARTUP) new_config['General']['quality_default'] = int(QUALITY_DEFAULT) new_config['General']['status_default'] = int(STATUS_DEFAULT) diff --git a/sickbeard/config.py b/sickbeard/config.py index 59723c7b..756f2879 100644 --- a/sickbeard/config.py +++ b/sickbeard/config.py @@ -165,14 +165,6 @@ def change_DAILYSEARCH_FREQUENCY(freq): sickbeard.dailySearchScheduler.cycleTime = datetime.timedelta(minutes=sickbeard.DAILYSEARCH_FREQUENCY) -def change_RSSUPDATE_FREQUENCY(freq): - sickbeard.RSSUPDATE_FREQUENCY = to_int(freq, default=sickbeard.DEFAULT_RSSUPDATE_FREQUENCY) - - if sickbeard.RSSUPDATE_FREQUENCY < sickbeard.MIN_RSSUPDATE_FREQUENCY: - sickbeard.RSSUPDATE_FREQUENCY = sickbeard.MIN_RSSUPDATE_FREQUENCY - - sickbeard.updateRSSScheduler.cycleTime = datetime.timedelta(minutes=sickbeard.RSSUPDATE_FREQUENCY) - def change_BACKLOG_FREQUENCY(freq): sickbeard.BACKLOG_FREQUENCY = to_int(freq, default=sickbeard.DEFAULT_BACKLOG_FREQUENCY) diff --git a/sickbeard/dailysearcher.py b/sickbeard/dailysearcher.py index 9408eb67..eaa3df3e 100644 --- a/sickbeard/dailysearcher.py +++ b/sickbeard/dailysearcher.py @@ -43,7 +43,10 @@ class DailySearcher(): self.amActive = True self._changeUnairedEpisodes() - logger.log(u"Searching for todays new releases ...") + # remove names from cache that link back to active shows that we watch + sickbeard.name_cache.syncNameCache() + + logger.log(u"Starting Daily Searcher ...") foundResults = self.searchForNeededEpisodes() if not len(foundResults): @@ -87,8 +90,6 @@ class DailySearcher(): def searchForNeededEpisodes(self): - logger.log(u"Searching RSS Cache for any new releases we may want to snatch ...") - foundResults = {} didSearch = False @@ -100,6 +101,10 @@ class DailySearcher(): threading.currentThread().name = threadName + ":[" + curProvider.name + "]" try: + logger.log(u"Updating RSS cache ...") + curProvider.cache.updateCache() + + logger.log(u"Searching RSS cache ...") curFoundResults = curProvider.searchRSS() except exceptions.AuthException, e: logger.log(u"Authentication error: " + ex(e), logger.ERROR) diff --git a/sickbeard/providers/generic.py b/sickbeard/providers/generic.py index 0ad90dcc..4d61e1d8 100644 --- a/sickbeard/providers/generic.py +++ b/sickbeard/providers/generic.py @@ -265,11 +265,11 @@ class GenericProvider: itemList += self._doSearch(curString, len(episodes)) # next episode if no search results - if not itemList: + if not len(itemList): continue # remove duplicate items - itemList = [i for n, i in enumerate(itemList) if i not in itemList[n + 1:]] + #itemList = [i for n, i in enumerate(itemList) if i not in itemList[n + 1:]] searchItems[epObj] = itemList # if we have cached results return them. diff --git a/sickbeard/rssupdater.py b/sickbeard/rssupdater.py deleted file mode 100644 index d9384f96..00000000 --- a/sickbeard/rssupdater.py +++ /dev/null @@ -1,47 +0,0 @@ -# Author: Nic Wolfe -# URL: http://code.google.com/p/sickbeard/ -# -# This file is part of Sick Beard. -# -# Sick Beard is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Sick Beard is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Sick Beard. If not, see . - -from __future__ import with_statement - -import sickbeard - -from sickbeard import logger - -import threading - -class RSSUpdater(): - def __init__(self): - self.lock = threading.Lock() - - self.amActive = False - - def run(self): - self.amActive = True - threadName = threading.currentThread().name - - # remove names from cache that link back to active shows that we watch - sickbeard.name_cache.syncNameCache() - - # update RSS cache - providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive()] - for provider in providers: - threading.currentThread().name = threadName + ":[" + provider.name + "]" - logger.log(u"Updating RSS cache ...") - provider.cache.updateCache() - - self.amActive = False \ No newline at end of file diff --git a/sickbeard/subtitles.py b/sickbeard/subtitles.py index 7bb15f2b..e4e77c3a 100644 --- a/sickbeard/subtitles.py +++ b/sickbeard/subtitles.py @@ -16,6 +16,7 @@ # You should have received a copy of the GNU General Public License # along with Sick Beard. If not, see . +import time import datetime import sickbeard from sickbeard.common import * @@ -114,6 +115,9 @@ class SubtitlesFinder(): rules = self._getRules() now = datetime.datetime.now() for epToSub in sqlResults: + + time.sleep(cpu_presets[sickbeard.CPU_PRESET]) + if not ek.ek(os.path.isfile, epToSub['location']): logger.log('Episode file does not exist, cannot download subtitles for episode %dx%d of show %s' % (epToSub['season'], epToSub['episode'], epToSub['show_name']), logger.DEBUG) continue diff --git a/sickbeard/tv.py b/sickbeard/tv.py index 7498c6c2..ec009272 100644 --- a/sickbeard/tv.py +++ b/sickbeard/tv.py @@ -54,7 +54,7 @@ from common import DOWNLOADED, SNATCHED, SNATCHED_PROPER, SNATCHED_BEST, ARCHIVE UNKNOWN, FAILED from common import NAMING_DUPLICATE, NAMING_EXTEND, NAMING_LIMITED_EXTEND, NAMING_SEPARATED_REPEAT, \ NAMING_LIMITED_EXTEND_E_PREFIXED - +from common import cpu_presets class TVShow(object): def __init__(self, indexer, indexerid, lang=""): @@ -881,6 +881,9 @@ class TVShow(object): for sqlEp in sqlResults: curEp = self.getEpisode(int(sqlEp["season"]), int(sqlEp["episode"])) foundEps.append(curEp) + + time.sleep(cpu_presets[sickbeard.CPU_PRESET]) + return foundEps def deleteShow(self): diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 6fbdeecd..a9f71da4 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -207,7 +207,6 @@ class ManageSearches: t.backlogPaused = sickbeard.searchQueueScheduler.action.is_backlog_paused() # @UndefinedVariable t.backlogRunning = sickbeard.searchQueueScheduler.action.is_backlog_in_progress() # @UndefinedVariable t.searchStatus = sickbeard.dailySearchScheduler.action.amActive # @UndefinedVariable - t.rssStatus = sickbeard.updateRSSScheduler.action.amActive # @UndefinedVariable t.submenu = ManageMenu() @@ -236,18 +235,6 @@ class ManageSearches: redirect("/manage/manageSearches/") - @cherrypy.expose - def forceRSS(self): - - # force it to run the next time it looks - result = sickbeard.updateRSSScheduler.forceRun() - if result: - logger.log(u"RSS cache update forced") - ui.notifications.message('RSS cache update started', - 'Note: RSS feeds may not be updated if retrieved recently') - - redirect("/manage/manageSearches/") - @cherrypy.expose def pauseBacklog(self, paused=None): if paused == "1": @@ -1094,9 +1081,9 @@ class ConfigSearch: 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_use_https=None, dailysearch_frequency=None, - nzb_method=None, torrent_method=None, usenet_retention=None, rssupdate_frequency=None, backlog_frequency=None, + nzb_method=None, torrent_method=None, usenet_retention=None, backlog_frequency=None, download_propers=None, check_propers_interval=None, prefer_episode_releases=None, allow_high_priority=None, - backlog_startup=None, dailysearch_startup=None, rssupdate_startup=None, + backlog_startup=None, dailysearch_startup=None, torrent_dir=None, torrent_username=None, torrent_password=None, torrent_host=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): @@ -1110,7 +1097,6 @@ class ConfigSearch: results += ["Unable to create directory " + os.path.normpath(torrent_dir) + ", dir not changed."] config.change_DAILYSEARCH_FREQUENCY(dailysearch_frequency) - config.change_RSSUPDATE_FREQUENCY(rssupdate_frequency) config.change_BACKLOG_FREQUENCY(backlog_frequency) sickbeard.USE_NZBS = config.checkbox_to_value(use_nzbs) @@ -1133,7 +1119,6 @@ class ConfigSearch: sickbeard.ALLOW_HIGH_PRIORITY = config.checkbox_to_value(allow_high_priority) sickbeard.DAILYSEARCH_STARTUP = config.checkbox_to_value(dailysearch_startup) - sickbeard.RSSUPDATE_STARTUP = config.checkbox_to_value(rssupdate_startup) sickbeard.BACKLOG_STARTUP = config.checkbox_to_value(backlog_startup) sickbeard.SAB_USERNAME = sab_username