diff --git a/sickbeard/dailysearcher.py b/sickbeard/dailysearcher.py index ebf305ac020a8ab691023c7f0c3cc6aac5de1ff9..bd72ab250f5fc0360b3137154496ce01bc5f68fc 100644 --- a/sickbeard/dailysearcher.py +++ b/sickbeard/dailysearcher.py @@ -40,6 +40,8 @@ class DailySearcher(): self.amActive = False def run(self, force=False): + if self.amActive: + return self.amActive = True diff --git a/sickbeard/search.py b/sickbeard/search.py index 5c3b8e8f7325a22c7a6a10f8daecc5821a8f1027..d56bfab67dc6d3ccf8ad88b90fdf40c8b7a64a03 100644 --- a/sickbeard/search.py +++ b/sickbeard/search.py @@ -321,19 +321,14 @@ def isFirstBestMatch(result): return False def wantedEpisodes(show, fromDate): + anyQualities, bestQualities = common.Quality.splitQuality(show.quality) # @UnusedVariable allQualities = list(set(anyQualities + bestQualities)) logger.log(u"Seeing if we need anything from " + show.name, logger.DEBUG) myDB = db.DBConnection() - if show.air_by_date: - sqlResults = myDB.select( - "SELECT ep.status, ep.season, ep.episode FROM tv_episodes ep, tv_shows show WHERE season != 0 AND ep.showid = show.indexer_id AND show.paused = 0 AND ep.airdate > ? AND ep.showid = ? AND show.air_by_date = 1", - [fromDate.toordinal(), show.indexerid]) - else: - sqlResults = myDB.select( - "SELECT status, season, episode FROM tv_episodes WHERE showid = ? AND season > 0 and airdate > ?", + sqlResults = myDB.select("SELECT status, season, episode FROM tv_episodes WHERE showid = ? AND season > 0 and airdate > ?", [show.indexerid, fromDate.toordinal()]) # check through the list of statuses to see if we want any diff --git a/sickbeard/searchBacklog.py b/sickbeard/searchBacklog.py index fc50b66bfc517327f096a2d5306ed3f99a1ba023..4f1c870d110a421b6688513ffa16b66801851f90 100644 --- a/sickbeard/searchBacklog.py +++ b/sickbeard/searchBacklog.py @@ -74,6 +74,9 @@ class BacklogSearcher: logger.log(u"Backlog is still running, not starting it again", logger.DEBUG) return + self.amActive = True + self.amPaused = False + if which_shows: show_list = which_shows else: @@ -84,13 +87,10 @@ class BacklogSearcher: curDate = datetime.date.today().toordinal() fromDate = datetime.date.fromordinal(1) - if not which_shows and not curDate - self._lastBacklog >= self.cycleTime: + if not which_shows and not ((curDate - self._lastBacklog) >= self.cycleTime): logger.log(u"Running limited backlog on missed episodes " + str(sickbeard.BACKLOG_DAYS) + " day(s) and older only") fromDate = datetime.date.today() - datetime.timedelta(days=sickbeard.BACKLOG_DAYS) - self.amActive = True - self.amPaused = False - # go through non air-by-date shows and see if they need any episodes for curShow in show_list: @@ -135,19 +135,17 @@ class BacklogSearcher: return self._lastBacklog def _get_segments(self, show, fromDate): + if show.paused: + logger.log(u"Skipping backlog for {show_name} because the show is paused".format(show_name=show.name), logger.DEBUG) + return {} + anyQualities, bestQualities = common.Quality.splitQuality(show.quality) # @UnusedVariable logger.log(u"Seeing if we need anything from {show_name}".format(show_name=show.name), logger.DEBUG) myDB = db.DBConnection() - if show.air_by_date: - sqlResults = myDB.select( - "SELECT ep.status, ep.season, ep.episode FROM tv_episodes ep, tv_shows show WHERE season != 0 AND ep.showid = show.indexer_id AND show.paused = 0 AND ep.airdate > ? AND ep.showid = ? AND show.air_by_date = 1", + sqlResults = myDB.select("SELECT status, season, episode FROM tv_episodes WHERE season > 0 AND airdate > ? AND showid = ?", [fromDate.toordinal(), show.indexerid]) - else: - sqlResults = myDB.select( - "SELECT status, season, episode FROM tv_episodes WHERE showid = ? AND season > 0 and airdate > ?", - [show.indexerid, fromDate.toordinal()]) # check through the list of statuses to see if we want any wanted = {}