1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-13 03:22:22 -05:00

rss cache updates and daily search have been joined into one function.

fixed more issues of missing vars causing saving of config issues.
This commit is contained in:
echel0n 2014-05-17 11:14:48 -07:00
parent 04213bebf2
commit 55f27c4f40
11 changed files with 26 additions and 140 deletions

View File

@ -77,17 +77,6 @@
</label>
</div>
<div class="field-pair">
<label class="nocheck clearfix">
<span class="component-title">RSS Cache Update Frequency</span>
<input type="text" name="rssupdate_frequency" value="$sickbeard.RSSUPDATE_FREQUENCY" size="5" />
</label>
<label class="nocheck clearfix">
<span class="component-title">&nbsp;</span>
<span class="component-desc">Time in minutes between searches (eg. 60)</span>
</label>
</div>
<div class="field-pair">
<label class="nocheck clearfix">
<span class="component-title">Daily Search Frequency</span>
@ -146,13 +135,6 @@
<span class="component-desc">Start daily search upon startup of SickRage?</span>
</label>
</div>
<div class="field-pair">
<input type="checkbox" name="rssupdate_startup" id="rssupdate_startup" #if $sickbeard.RSSUPDATE_STARTUP == True then "checked=\"checked\"" else ""# />
<label class="clearfix" for="rssupdate_startup">
<span class="component title">RSS Cache Updates on startup</span>
<span class="component-desc">Start RSS cache updates upon startup of SickRage?</span>
</label>
</div>
<div class="field-pair">
<input type="checkbox" name="backlog_startup" id="backlog_startup" #if $sickbeard.BACKLOG_STARTUP == True then "checked=\"checked\"" else ""# />
<label class="clearfix" for="backlog_startup">

View File

@ -14,7 +14,6 @@
#set $numDLEpisodes = $myDB.select("SELECT COUNT(*) FROM tv_episodes WHERE status IN ("+",".join([str(x) for x in $Quality.DOWNLOADED + [$ARCHIVED]])+") AND season != 0 and episode != 0 AND airdate <= "+$today+"")[0][0]
#set $numEpisodes = $myDB.select("SELECT COUNT(*) FROM tv_episodes WHERE season != 0 and episode != 0 AND (airdate != 1 OR status IN ("+",".join([str(x) for x in ($Quality.DOWNLOADED + $Quality.SNATCHED + $Quality.SNATCHED_PROPER) + [$ARCHIVED]])+")) AND airdate <= "+$today+" AND status != "+str($IGNORED)+"")[0][0]
<b>$numShows shows</b> ($numGoodShows active) | <b>$numDLEpisodes/$numEpisodes</b> episodes downloaded |
<b>RSS Update</b>: <%=str(sickbeard.updateRSSScheduler.timeLeft()).split('.')[0]%> |
<b>Daily Search</b>: <%=str(sickbeard.dailySearchScheduler.timeLeft()).split('.')[0]%> |
<b>Backlog</b>: $sbdatetime.sbdatetime.sbfdate($sickbeard.backlogSearchScheduler.nextRun())
</div>

View File

@ -36,15 +36,6 @@ In Progress<br />
#end if
<br />
<h3>RSS Cache Update:</h3>
<a class="btn" href="$sbRoot/manage/manageSearches/forceRSS"><i class="icon-exclamation-sign"></i> Force</a>
#if not $rssStatus:
Not in progress<br />
#else:
In Progress<br />
#end if
<br />
<h3>Version Check:</h3>
<a class="btn" href="$sbRoot/manage/manageSearches/forceVersionCheck"><i class="icon-check"></i> Force Check</a>
<br />

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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.

View File

@ -1,47 +0,0 @@
# Author: Nic Wolfe <nic@wolfeden.ca>
# 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 <http://www.gnu.org/licenses/>.
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

View File

@ -16,6 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with Sick Beard. If not, see <http://www.gnu.org/licenses/>.
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

View File

@ -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):

View File

@ -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