2014-05-15 04:16:46 +00:00
|
|
|
# Author: Nic Wolfe <nic@wolfeden.ca>
|
|
|
|
# URL: http://code.google.com/p/sickbeard/
|
|
|
|
#
|
2014-05-23 12:37:22 +00:00
|
|
|
# This file is part of SickRage.
|
2014-05-15 04:16:46 +00:00
|
|
|
#
|
2014-05-23 12:37:22 +00:00
|
|
|
# SickRage is free software: you can redistribute it and/or modify
|
2014-05-15 04:16:46 +00:00
|
|
|
# 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.
|
|
|
|
#
|
2014-05-23 12:37:22 +00:00
|
|
|
# SickRage is distributed in the hope that it will be useful,
|
2014-05-15 04:16:46 +00:00
|
|
|
# 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
|
2014-05-23 12:37:22 +00:00
|
|
|
# along with SickRage. If not, see <http://www.gnu.org/licenses/>.
|
2014-05-15 04:16:46 +00:00
|
|
|
|
|
|
|
from __future__ import with_statement
|
2014-05-26 20:16:07 +00:00
|
|
|
|
2014-05-15 04:16:46 +00:00
|
|
|
import datetime
|
|
|
|
import threading
|
2014-07-24 16:12:29 +00:00
|
|
|
import traceback
|
2014-05-15 04:16:46 +00:00
|
|
|
|
|
|
|
import sickbeard
|
|
|
|
from sickbeard import logger
|
|
|
|
from sickbeard import db
|
|
|
|
from sickbeard import common
|
|
|
|
from sickbeard import helpers
|
|
|
|
from sickbeard import exceptions
|
2014-06-27 00:13:41 +00:00
|
|
|
from sickbeard.exceptions import ex
|
|
|
|
|
2014-05-15 04:16:46 +00:00
|
|
|
|
|
|
|
class DailySearcher():
|
|
|
|
def __init__(self):
|
|
|
|
self.lock = threading.Lock()
|
|
|
|
self.amActive = False
|
|
|
|
|
2014-05-19 17:40:25 +00:00
|
|
|
def run(self, force=False):
|
|
|
|
|
|
|
|
self.amActive = True
|
2014-05-18 15:33:31 +00:00
|
|
|
|
2014-08-30 08:47:00 +00:00
|
|
|
logger.log(u"Searching for coming episodes and 1 weeks worth of previously WANTED episodes ...")
|
2014-07-24 19:05:49 +00:00
|
|
|
|
2014-08-30 08:47:00 +00:00
|
|
|
curDate = datetime.date.today().toordinal()
|
2014-06-27 00:13:41 +00:00
|
|
|
|
2014-08-30 08:47:00 +00:00
|
|
|
myDB = db.DBConnection()
|
|
|
|
sqlResults = myDB.select("SELECT * FROM tv_episodes WHERE status = ? AND season > 0 AND airdate <= ?",
|
|
|
|
[common.UNAIRED, curDate])
|
2014-07-24 16:12:29 +00:00
|
|
|
|
2014-08-30 08:47:00 +00:00
|
|
|
sql_l = []
|
|
|
|
for sqlEp in sqlResults:
|
2014-06-27 00:13:41 +00:00
|
|
|
try:
|
2014-08-30 08:47:00 +00:00
|
|
|
show = helpers.findCertainShow(sickbeard.showList, int(sqlEp["showid"]))
|
|
|
|
except exceptions.MultipleShowObjectsException:
|
|
|
|
logger.log(u"ERROR: expected to find a single show matching " + sqlEp["showid"])
|
2014-07-24 16:12:29 +00:00
|
|
|
continue
|
2014-05-15 04:16:46 +00:00
|
|
|
|
2014-08-30 08:47:00 +00:00
|
|
|
ep = show.getEpisode(int(sqlEp["season"]), int(sqlEp["episode"]))
|
|
|
|
with ep.lock:
|
|
|
|
if ep.show.paused:
|
|
|
|
ep.status = common.SKIPPED
|
|
|
|
else:
|
|
|
|
ep.status = common.WANTED
|
2014-05-15 04:16:46 +00:00
|
|
|
|
2014-08-30 08:47:00 +00:00
|
|
|
sql_l.append(ep.get_sql())
|
2014-06-30 15:57:32 +00:00
|
|
|
|
2014-08-30 08:47:00 +00:00
|
|
|
if len(sql_l) > 0:
|
2014-07-24 19:05:49 +00:00
|
|
|
myDB = db.DBConnection()
|
2014-08-30 08:47:00 +00:00
|
|
|
myDB.mass_action(sql_l)
|
|
|
|
|
|
|
|
# queue episode for daily search
|
|
|
|
dailysearch_queue_item = sickbeard.search_queue.DailySearchQueueItem()
|
|
|
|
sickbeard.searchQueueScheduler.action.add_item(dailysearch_queue_item)
|
2014-06-30 15:57:32 +00:00
|
|
|
|
2014-05-26 21:20:31 +00:00
|
|
|
self.amActive = False
|