1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-12 11:02:21 -05:00

Fix for Next Ep airdates.

Added check for hidden folders in post-processing.
Cleaned up daily search function.
This commit is contained in:
echel0n 2014-05-21 20:12:15 -07:00
parent e3da060000
commit 9cd9576232
5 changed files with 17 additions and 31 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

@ -45,27 +45,14 @@ class DailySearcher():
# remove names from cache that link back to active shows that we watch
sickbeard.name_cache.syncNameCache()
logger.log(u"Updating RSS cache ...")
origThreadName = threading.currentThread().name
providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive()]
for curProviderCount, curProvider in enumerate(providers):
threading.currentThread().name = origThreadName + " :: [" + curProvider.name + "]"
try:
curProvider.cache.updateCache()
except exceptions.AuthException, e:
logger.log(u"Authentication error: " + ex(e), logger.ERROR)
continue
logger.log(u"Checking to see if any shows have wanted episodes available for the last week ...")
logger.log(u"Searching for coming episodes and 1 weeks worth of previously WANTED episodes ...")
fromDate = datetime.date.today() - datetime.timedelta(weeks=1)
toDate = datetime.date.today() + datetime.timedelta(days=1)
curDate = datetime.date.today()
myDB = db.DBConnection()
sqlResults = myDB.select("SELECT * FROM tv_episodes WHERE status in (?,?) AND airdate >= ? AND airdate < ?",
[common.UNAIRED, common.WANTED, fromDate.toordinal(), toDate.toordinal()])
sqlResults = myDB.select("SELECT * FROM tv_episodes WHERE status in (?,?) AND airdate >= ? AND airdate <= ?",
[common.UNAIRED, common.WANTED, fromDate.toordinal(), curDate.toordinal()])
todaysEps = {}
for sqlEp in sqlResults:
@ -87,6 +74,7 @@ class DailySearcher():
ep.status = common.SKIPPED
else:
if ep.status == common.UNAIRED:
logger.log(u"New episode " + ep.prettyName() + " airs today, setting status to WANTED")
ep.status = common.WANTED
ep.saveToDB()
@ -97,13 +85,10 @@ class DailySearcher():
else:
todaysEps[show].append(ep)
# reset thread name back to original
threading.currentThread().name = origThreadName
if len(todaysEps):
for show in todaysEps:
segment = todaysEps[show]
dailysearch_queue_item = sickbeard.search_queue.DailySearchQueueItem(show, segment)
sickbeard.searchQueueScheduler.action.add_item(dailysearch_queue_item) #@UndefinedVariable
else:
logger.log(u"Could not find any wanted show episodes going back 1 week at this current time ...")
logger.log(u"Could not find any needed episodes to search for ...")

View File

@ -179,6 +179,10 @@ def validateDir(path, dirName, nzbNameOriginal, failed):
process_failed(os.path.join(path, dirName), nzbNameOriginal)
return False
if helpers.is_hidden_folder(dirName):
returnStr += logHelper(u"Ignoring hidden folder: " + dirName, logger.DEBUG)
return False
# make sure the dir isn't inside a show dir
myDB = db.DBConnection()
sqlResults = myDB.select("SELECT * FROM tv_shows")
@ -229,7 +233,6 @@ def validateDir(path, dirName, nzbNameOriginal, failed):
return False
def unRAR(path, rarFiles, force):
global process_result, returnStr

View File

@ -328,6 +328,8 @@ def searchForNeededEpisodes(episodes):
threading.currentThread().name = origThreadName + " :: [" + curProvider.name + "]"
try:
logger.log(u"Updating RSS cache ...")
curProvider.cache.updateCache()
logger.log(u"Searching RSS cache ...")
curFoundResults = curProvider.searchRSS(episodes)
except exceptions.AuthException, e:

View File

@ -18,15 +18,12 @@
from __future__ import with_statement
import time
import os.path
import datetime
import threading
import re
import glob
from time import sleep
import traceback
import shutil
import sickbeard
@ -54,7 +51,6 @@ 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=""):
@ -858,7 +854,7 @@ class TVShow(object):
#Rename dict keys without spaces for DB upsert
self.imdb_info = dict(
(k.replace(' ', '_'), f(v) if hasattr(v, 'keys') else v) for k, v in imdb_info.items())
(k.replace(' ', '_'), k(v) if hasattr(v, 'keys') else v) for k, v in imdb_info.items())
logger.log(str(self.indexerid) + u": Obtained info from IMDb ->" + str(self.imdb_info), logger.DEBUG)
def nextEpisode(self):
@ -866,10 +862,10 @@ class TVShow(object):
logger.log(str(self.indexerid) + ": Finding the episode which airs next", logger.DEBUG)
myDB = db.DBConnection()
innerQuery = "SELECT airdate FROM tv_episodes WHERE showid = ? AND airdate >= ? AND status = ? ORDER BY airdate ASC LIMIT 1"
innerParams = [self.indexerid, datetime.date.today().toordinal(), UNAIRED]
query = "SELECT * FROM tv_episodes WHERE showid = ? AND airdate >= ? AND airdate <= (" + innerQuery + ") and status = ?"
params = [self.indexerid, datetime.date.today().toordinal()] + innerParams + [UNAIRED]
innerQuery = "SELECT airdate FROM tv_episodes WHERE showid = ? AND airdate >= ? AND status in (?,?) ORDER BY airdate ASC LIMIT 1"
innerParams = [self.indexerid, datetime.date.today().toordinal(), UNAIRED, WANTED]
query = "SELECT * FROM tv_episodes WHERE showid = ? AND airdate >= ? AND airdate <= (" + innerQuery + ") and status in (?,?)"
params = [self.indexerid, datetime.date.today().toordinal()] + innerParams + [UNAIRED, WANTED]
sqlResults = myDB.select(query, params)
if sqlResults == None or len(sqlResults) == 0: