mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-13 03:22:22 -05:00
Removed maintance schedualer and moved the routines from it to happen before a search is started to ensure things are up to date and to stop waking up synology devices, regexes also made less greedy.
This commit is contained in:
parent
3eab86478a
commit
c8d899ad66
12
SickBeard.py
12
SickBeard.py
@ -60,7 +60,7 @@ import sickbeard
|
||||
|
||||
from sickbeard import db
|
||||
from sickbeard.tv import TVShow
|
||||
from sickbeard import logger
|
||||
from sickbeard import logger, network_timezones, failed_history, name_cache
|
||||
from sickbeard.webserveInit import SRWebServer
|
||||
from sickbeard.version import SICKBEARD_VERSION
|
||||
from sickbeard.databases.mainDB import MIN_DB_VERSION
|
||||
@ -313,6 +313,16 @@ class SickRage(object):
|
||||
# Fire up all our threads
|
||||
sickbeard.start()
|
||||
|
||||
# Build internal name cache
|
||||
name_cache.buildNameCache()
|
||||
|
||||
# refresh network timezones
|
||||
network_timezones.update_network_dict()
|
||||
|
||||
# sure, why not?
|
||||
if sickbeard.USE_FAILED_DOWNLOADS:
|
||||
failed_history.trimHistory()
|
||||
|
||||
# Start an update if we're supposed to
|
||||
if self.forceUpdate or sickbeard.UPDATE_SHOWS_ON_START:
|
||||
sickbeard.showUpdateScheduler.action.run(force=True) # @UndefinedVariable
|
||||
|
@ -41,7 +41,6 @@ from sickbeard import helpers, db, exceptions, show_queue, search_queue, schedul
|
||||
from sickbeard import logger
|
||||
from sickbeard import naming
|
||||
from sickbeard import dailysearcher
|
||||
from sickbeard import maintenance
|
||||
from sickbeard import scene_numbering, scene_exceptions, name_cache
|
||||
from indexers.indexer_api import indexerApi
|
||||
from indexers.indexer_exceptions import indexer_shownotfound, indexer_exception, indexer_error, indexer_episodenotfound, \
|
||||
@ -76,7 +75,6 @@ PIDFILE = ''
|
||||
DAEMON = None
|
||||
NO_RESIZE = False
|
||||
|
||||
maintenanceScheduler = None
|
||||
dailySearchScheduler = None
|
||||
backlogSearchScheduler = None
|
||||
showUpdateScheduler = None
|
||||
@ -479,7 +477,7 @@ def initialize(consoleLogging=True):
|
||||
USE_FAILED_DOWNLOADS, DELETE_FAILED, ANON_REDIRECT, LOCALHOST_IP, TMDB_API_KEY, DEBUG, PROXY_SETTING, \
|
||||
AUTOPOSTPROCESSER_FREQUENCY, DEFAULT_AUTOPOSTPROCESSER_FREQUENCY, MIN_AUTOPOSTPROCESSER_FREQUENCY, \
|
||||
ANIME_DEFAULT, NAMING_ANIME, ANIMESUPPORT, USE_ANIDB, ANIDB_USERNAME, ANIDB_PASSWORD, ANIDB_USE_MYLIST, \
|
||||
ANIME_SPLIT_HOME, maintenanceScheduler, SCENE_DEFAULT
|
||||
ANIME_SPLIT_HOME, SCENE_DEFAULT
|
||||
|
||||
if __INITIALIZED__:
|
||||
return False
|
||||
@ -957,10 +955,6 @@ def initialize(consoleLogging=True):
|
||||
threadName="CHECKVERSION",
|
||||
silent=False)
|
||||
|
||||
maintenanceScheduler = scheduler.Scheduler(maintenance.Maintenance(),
|
||||
cycleTime=datetime.timedelta(hours=1),
|
||||
threadName="MAINTENANCE")
|
||||
|
||||
showQueueScheduler = scheduler.Scheduler(show_queue.ShowQueue(),
|
||||
cycleTime=datetime.timedelta(seconds=3),
|
||||
threadName="SHOWQUEUE")
|
||||
@ -1123,7 +1117,7 @@ def initialize(consoleLogging=True):
|
||||
|
||||
|
||||
def start():
|
||||
global __INITIALIZED__, maintenanceScheduler, backlogSearchScheduler, \
|
||||
global __INITIALIZED__, backlogSearchScheduler, \
|
||||
showUpdateScheduler, versionCheckScheduler, showQueueScheduler, \
|
||||
properFinderScheduler, autoPostProcesserScheduler, searchQueueScheduler, \
|
||||
subtitlesFinderScheduler, USE_SUBTITLES,traktCheckerScheduler, \
|
||||
@ -1133,9 +1127,6 @@ def start():
|
||||
|
||||
if __INITIALIZED__:
|
||||
|
||||
# start the maintenance scheduler
|
||||
maintenanceScheduler.thread.start()
|
||||
|
||||
# start the daily search scheduler
|
||||
dailySearchScheduler.thread.start()
|
||||
|
||||
@ -1171,7 +1162,7 @@ def start():
|
||||
|
||||
|
||||
def halt():
|
||||
global __INITIALIZED__, maintenanceScheduler, backlogSearchScheduler, \
|
||||
global __INITIALIZED__, backlogSearchScheduler, \
|
||||
showUpdateScheduler, versionCheckScheduler, showQueueScheduler, \
|
||||
properFinderScheduler, autoPostProcesserScheduler, searchQueueScheduler, \
|
||||
subtitlesFinderScheduler, traktCheckerScheduler, \
|
||||
@ -1185,13 +1176,6 @@ def halt():
|
||||
|
||||
# abort all the threads
|
||||
|
||||
maintenanceScheduler.abort = True
|
||||
logger.log(u"Waiting for the MAINTENANCE scheduler thread to exit")
|
||||
try:
|
||||
maintenanceScheduler.thread.join(10)
|
||||
except:
|
||||
pass
|
||||
|
||||
dailySearchScheduler.abort = True
|
||||
logger.log(u"Waiting for the DAILYSEARCH thread to exit")
|
||||
try:
|
||||
|
@ -1,53 +0,0 @@
|
||||
# Author: Nic Wolfe <nic@wolfeden.ca>
|
||||
# URL: http://code.google.com/p/sickbeard/
|
||||
#
|
||||
# This file is part of SickRage.
|
||||
#
|
||||
# SickRage 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.
|
||||
#
|
||||
# SickRage 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 SickRage. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import with_statement
|
||||
import threading
|
||||
import sickbeard
|
||||
|
||||
from sickbeard import scene_exceptions
|
||||
from sickbeard import failed_history
|
||||
from sickbeard import network_timezones
|
||||
from sickbeard import name_cache
|
||||
|
||||
class Maintenance():
|
||||
def __init__(self):
|
||||
self.lock = threading.Lock()
|
||||
|
||||
self.amActive = False
|
||||
|
||||
def run(self, force=False):
|
||||
self.amActive = True
|
||||
|
||||
# clear internal name cache
|
||||
name_cache.clearCache()
|
||||
|
||||
# get and update scene exceptions lists
|
||||
scene_exceptions.retrieve_exceptions()
|
||||
|
||||
# build internal name cache for searches and parsing
|
||||
name_cache.buildNameCache()
|
||||
|
||||
# refresh network timezones
|
||||
network_timezones.update_network_dict()
|
||||
|
||||
# sure, why not?
|
||||
if sickbeard.USE_FAILED_DOWNLOADS:
|
||||
failed_history.trimHistory()
|
||||
|
||||
self.amActive = False
|
@ -96,7 +96,10 @@ def buildNameCache():
|
||||
# clear internal name cache
|
||||
clearCache()
|
||||
|
||||
logger.log(u"Updating internal name cache", logger.MESSAGE)
|
||||
# update scene exception names
|
||||
sickbeard.scene_exceptions.retrieve_exceptions()
|
||||
|
||||
logger.log(u"Building internal name cache", logger.MESSAGE)
|
||||
|
||||
cacheDB = db.DBConnection('cache.db')
|
||||
cache_results = cacheDB.select("SELECT * FROM scene_names")
|
||||
@ -111,5 +114,4 @@ def buildNameCache():
|
||||
for name in sickbeard.scene_exceptions.get_scene_exceptions(show.indexerid, season=curSeason):
|
||||
nameCache[sickbeard.helpers.full_sanitizeSceneName(name)] = show.indexerid
|
||||
|
||||
logger.log(u"Updated internal name cache", logger.MESSAGE)
|
||||
logger.log(u"Internal name cache set to: " + str(nameCache), logger.DEBUG)
|
@ -123,8 +123,8 @@ class NameParser(object):
|
||||
if not self.showObj and not self.naming_pattern:
|
||||
# Regex pattern to return the Show / Series Name regardless of the file pattern tossed at it, matched 53 show name examples from regexes.py
|
||||
show_patterns = [
|
||||
'''^(?P<show_name>.*?)\W+(?:(?:S\d[\dE._ -])|(?:\d\d?x)|(?:\d{4}\W\d\d\W\d\d)|(?:(?:part|pt)[\._ -]?(\d|[ivx]))|Season\W+\d+\W+|E\d+\W+|(?:\d{1,3}.+\d{1,}[a-zA-Z]{2}\W+[a-zA-Z]{3,}\W+\d{4}.+))''',
|
||||
'''^((\[.*?\])|(\d+[\.-]))*[ _\.]*(?P<show_name>.*?)(([ ._-]+\d+)|([ ._-]+s\d{2})).*'''
|
||||
'''^(?P<show_name>.*)\W+(?:(?:S\d[\dE._ -])|(?:\d\d?x)|(?:\d{4}\W\d\d\W\d\d)|(?:(?:part|pt)[\._ -]?(\d|[ivx]))|Season\W+\d+\W+|E\d+\W+|(?:\d{1,3}.+\d{1,}[a-zA-Z]{2}\W+[a-zA-Z]{3,}\W+\d{4}.+))''',
|
||||
'''^((\[.*?\])|(\d+[\.-]))*[ _\.]*(?P<show_name>.*)(([ ._-]+\d+)|([ ._-]+s\d{2})).*'''
|
||||
]
|
||||
|
||||
# find show object
|
||||
|
@ -43,9 +43,6 @@ class SearchQueue(generic_queue.GenericQueue):
|
||||
generic_queue.GenericQueue.__init__(self)
|
||||
self.queue_name = "SEARCHQUEUE"
|
||||
|
||||
def __del__(self):
|
||||
pass
|
||||
|
||||
def is_in_queue(self, show, segment):
|
||||
for cur_item in self.queue:
|
||||
if isinstance(cur_item, BacklogQueueItem) and cur_item.show == show and cur_item.segment == segment:
|
||||
@ -77,17 +74,20 @@ class SearchQueue(generic_queue.GenericQueue):
|
||||
def add_item(self, item):
|
||||
|
||||
if isinstance(item, DailySearchQueueItem) and not self.is_in_queue(item.show, item.segment):
|
||||
sickbeard.name_cache.buildNameCache()
|
||||
generic_queue.GenericQueue.add_item(self, item)
|
||||
elif isinstance(item, BacklogQueueItem) and not self.is_in_queue(item.show, item.segment):
|
||||
sickbeard.name_cache.buildNameCache()
|
||||
generic_queue.GenericQueue.add_item(self, item)
|
||||
elif isinstance(item, ManualSearchQueueItem) and not self.is_in_queue(item.show, item.segment):
|
||||
sickbeard.name_cache.buildNameCache()
|
||||
generic_queue.GenericQueue.add_item(self, item)
|
||||
elif isinstance(item, FailedQueueItem) and not self.is_in_queue(item.show, item.segment):
|
||||
sickbeard.name_cache.buildNameCache()
|
||||
generic_queue.GenericQueue.add_item(self, item)
|
||||
else:
|
||||
logger.log(u"Not adding item, it's already in the queue", logger.DEBUG)
|
||||
|
||||
|
||||
class DailySearchQueueItem(generic_queue.QueueItem):
|
||||
def __init__(self, show, segment):
|
||||
generic_queue.QueueItem.__init__(self, 'Daily Search', DAILY_SEARCH)
|
||||
|
@ -37,6 +37,13 @@ class ShowUpdater():
|
||||
update_datetime = datetime.datetime.now()
|
||||
update_date = update_datetime.date()
|
||||
|
||||
# refresh network timezones
|
||||
network_timezones.update_network_dict()
|
||||
|
||||
# sure, why not?
|
||||
if sickbeard.USE_FAILED_DOWNLOADS:
|
||||
failed_history.trimHistory()
|
||||
|
||||
logger.log(u"Doing full update on all shows")
|
||||
|
||||
# clean out cache directory, remove everything > 12 hours old
|
||||
|
Loading…
Reference in New Issue
Block a user