Fix for no providers found error during searches.

This commit is contained in:
echel0n 2014-07-24 12:05:49 -07:00
parent f47734446d
commit 012baeda0c
2 changed files with 51 additions and 36 deletions

View file

@ -40,6 +40,8 @@ class DailySearcher():
self.amActive = True self.amActive = True
didSearch = False
providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive() and not x.backlog_only] providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive() and not x.backlog_only]
for curProviderCount, curProvider in enumerate(providers): for curProviderCount, curProvider in enumerate(providers):
@ -55,42 +57,50 @@ class DailySearcher():
logger.log(traceback.format_exc(), logger.DEBUG) logger.log(traceback.format_exc(), logger.DEBUG)
continue continue
logger.log(u"Searching for coming episodes and 1 weeks worth of previously WANTED episodes ...") didSearch = True
fromDate = datetime.date.today() - datetime.timedelta(weeks=1) if didSearch:
curDate = datetime.date.today() logger.log(u"Searching for coming episodes and 1 weeks worth of previously WANTED episodes ...")
myDB = db.DBConnection() fromDate = datetime.date.today() - datetime.timedelta(weeks=1)
sqlResults = myDB.select("SELECT * FROM tv_episodes WHERE status in (?,?) AND airdate >= ? AND airdate <= ?", curDate = datetime.date.today()
[common.UNAIRED, common.WANTED, fromDate.toordinal(), curDate.toordinal()])
sql_l = []
for sqlEp in sqlResults:
try:
show = helpers.findCertainShow(sickbeard.showList, int(sqlEp["showid"]))
except exceptions.MultipleShowObjectsException:
logger.log(u"ERROR: expected to find a single show matching " + sqlEp["showid"])
continue
ep = show.getEpisode(int(sqlEp["season"]), int(sqlEp["episode"]))
with ep.lock:
if ep.show.paused:
ep.status = common.SKIPPED
if ep.status == common.UNAIRED:
logger.log(u"New episode " + ep.prettyName() + " airs today, setting status to WANTED")
ep.status = common.WANTED
sql_l.append(ep.get_sql())
if ep.status == common.WANTED:
dailysearch_queue_item = sickbeard.search_queue.DailySearchQueueItem(show, [ep])
sickbeard.searchQueueScheduler.action.add_item(dailysearch_queue_item)
else:
logger.log(u"Could not find any wanted episodes for the last 7 days to search for")
if len(sql_l) > 0:
myDB = db.DBConnection() myDB = db.DBConnection()
myDB.mass_action(sql_l) sqlResults = myDB.select("SELECT * FROM tv_episodes WHERE status in (?,?) AND airdate >= ? AND airdate <= ?",
[common.UNAIRED, common.WANTED, fromDate.toordinal(), curDate.toordinal()])
sql_l = []
for sqlEp in sqlResults:
try:
show = helpers.findCertainShow(sickbeard.showList, int(sqlEp["showid"]))
except exceptions.MultipleShowObjectsException:
logger.log(u"ERROR: expected to find a single show matching " + sqlEp["showid"])
continue
ep = show.getEpisode(int(sqlEp["season"]), int(sqlEp["episode"]))
with ep.lock:
if ep.show.paused:
ep.status = common.SKIPPED
if ep.status == common.UNAIRED:
logger.log(u"New episode " + ep.prettyName() + " airs today, setting status to WANTED")
ep.status = common.WANTED
sql_l.append(ep.get_sql())
if ep.status == common.WANTED:
dailysearch_queue_item = sickbeard.search_queue.DailySearchQueueItem(show, [ep])
sickbeard.searchQueueScheduler.action.add_item(dailysearch_queue_item)
else:
logger.log(u"Could not find any wanted episodes for the last 7 days to search for")
if len(sql_l) > 0:
myDB = db.DBConnection()
myDB.mass_action(sql_l)
else:
logger.log(
u"No NZB/Torrent providers found or enabled in the sickrage config. Please check your settings.",
logger.ERROR)
self.amActive = False self.amActive = False

View file

@ -340,6 +340,7 @@ def filterSearchResults(show, season, results):
def searchForNeededEpisodes(show, episodes): def searchForNeededEpisodes(show, episodes):
foundResults = {} foundResults = {}
didSearch = False didSearch = False
origThreadName = threading.currentThread().name origThreadName = threading.currentThread().name
@ -390,7 +391,7 @@ def searchForNeededEpisodes(show, episodes):
if not didSearch: if not didSearch:
logger.log( logger.log(
u"No NZB/Torrent providers found or enabled in the sickrage config. Please check your settings.", u"No NZB/Torrent providers found or enabled in the sickrage config for daily searches. Please check your settings.",
logger.ERROR) logger.ERROR)
return foundResults.values() if len(foundResults) else {} return foundResults.values() if len(foundResults) else {}
@ -400,6 +401,8 @@ def searchProviders(show, season, episodes, manualSearch=False):
foundResults = {} foundResults = {}
finalResults = [] finalResults = []
didSearch = False
# check if we want to search for season packs instead of just season/episode # check if we want to search for season packs instead of just season/episode
seasonSearch = False seasonSearch = False
if not manualSearch: if not manualSearch:
@ -444,6 +447,8 @@ def searchProviders(show, season, episodes, manualSearch=False):
finally: finally:
threading.currentThread().name = origThreadName threading.currentThread().name = origThreadName
didSearch = True
if len(searchResults): if len(searchResults):
# make a list of all the results for this provider # make a list of all the results for this provider
for curEp in searchResults: for curEp in searchResults:
@ -668,8 +673,8 @@ def searchProviders(show, season, episodes, manualSearch=False):
if wantedEpCount == len(episodes): if wantedEpCount == len(episodes):
break break
else: if not didSearch:
logger.log(u"No NZB/Torrent providers found or enabled in the sickrage config. Please check your settings.", logger.log(u"No NZB/Torrent providers found or enabled in the sickrage config for backlog searches. Please check your settings.",
logger.ERROR) logger.ERROR)
return finalResults return finalResults