mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-12 11:02:21 -05:00
Fixes cache issues with lookups resulting in wasted cpu cycles.
Fixes issues with scene numbered releases not properly being converted before a cache lookup is performed and not being properly converted when returned from providers as a possible match for a show requested to be snatched.
This commit is contained in:
parent
96f543aa29
commit
3fbfed7d93
@ -277,7 +277,7 @@ def makeDir(path):
|
||||
|
||||
|
||||
def searchDBForShow(regShowName, indexer_id=None):
|
||||
showNames = [re.sub('[. -]', ' ', regShowName), regShowName]
|
||||
showNames = list(set([re.sub('[. -]', ' ', regShowName), regShowName]))
|
||||
|
||||
myDB = db.DBConnection()
|
||||
|
||||
|
@ -672,14 +672,12 @@ class PostProcessor(object):
|
||||
|
||||
root_ep = None
|
||||
for cur_episode in episodes:
|
||||
# convert episode from scene numbering to Indexer numbering
|
||||
(s, e) = sickbeard.scene_numbering.get_indexer_numbering(indexer_id, season, int(cur_episode))
|
||||
|
||||
self._log(u"Retrieving episode object for " + str(s) + "x" + str(e), logger.DEBUG)
|
||||
self._log(u"Retrieving episode object for " + str(season) + "x" + str(cur_episode), logger.DEBUG)
|
||||
|
||||
# now that we've figured out which episode this file is just load it manually
|
||||
try:
|
||||
curEp = show_obj.getEpisode(s, e)
|
||||
# convert scene numbered release and load episode from database
|
||||
curEp = show_obj.getEpisode(season, cur_episode, sceneConvert=True)
|
||||
except exceptions.EpisodeNotFoundException, e:
|
||||
self._log(u"Unable to create episode: " + ex(e), logger.DEBUG)
|
||||
raise exceptions.PostProcessingFailed()
|
||||
|
@ -260,6 +260,9 @@ class GenericProvider:
|
||||
if show.sports:
|
||||
regexMethod = 1
|
||||
|
||||
# update cache
|
||||
self.cache.updateCache()
|
||||
|
||||
for ep_obj in ep_objs:
|
||||
# get scene season/episode info
|
||||
scene_season = ep_obj.scene_season
|
||||
@ -271,7 +274,6 @@ class GenericProvider:
|
||||
logger.log(u'Searching "%s" for "%s" as "%s"'
|
||||
% (self.name, ep_obj.prettyName(), ep_obj.scene_prettyName()))
|
||||
|
||||
self.cache.updateCache()
|
||||
results = self.cache.searchCache(ep_obj, manualSearch)
|
||||
logger.log(u"Cache results: " + str(results), logger.DEBUG)
|
||||
logger.log(u"manualSearch: " + str(manualSearch), logger.DEBUG)
|
||||
@ -298,7 +300,7 @@ class GenericProvider:
|
||||
# parse the file name
|
||||
try:
|
||||
myParser = NameParser(False, regexMethod)
|
||||
parse_result = myParser.parse(title, True)
|
||||
parse_result = myParser.parse(title)
|
||||
except InvalidNameException:
|
||||
logger.log(u"Unable to parse the filename " + title + " into a valid episode", logger.WARNING)
|
||||
continue
|
||||
@ -312,7 +314,7 @@ class GenericProvider:
|
||||
continue
|
||||
|
||||
# we just use the existing info for normal searches
|
||||
actual_season = season
|
||||
actual_season = parse_result.season_number
|
||||
actual_episodes = parse_result.episode_numbers
|
||||
|
||||
else:
|
||||
@ -348,10 +350,15 @@ class GenericProvider:
|
||||
# make sure we want the episode
|
||||
wantEp = True
|
||||
for epNo in actual_episodes:
|
||||
if not show.wantEpisode(actual_season, epNo, quality, manualSearch=manualSearch):
|
||||
epObj = show.getEpisode(actual_season, epNo)
|
||||
if not epObj or not show.wantEpisode(epObj.season, epObj.episode, quality, manualSearch=manualSearch):
|
||||
wantEp = False
|
||||
break
|
||||
|
||||
if not epObj:
|
||||
logger.log(u"Ignoring result " + title + " because episode scene info is invalid.")
|
||||
continue
|
||||
|
||||
if not wantEp:
|
||||
logger.log(
|
||||
u"Ignoring result " + title + " because we don't want an episode that is " + Quality.qualityStrings[
|
||||
@ -361,24 +368,23 @@ class GenericProvider:
|
||||
logger.log(u"Found result " + title + " at " + url, logger.DEBUG)
|
||||
|
||||
# make a result object
|
||||
epObj = []
|
||||
for curEp in actual_episodes:
|
||||
epObj.append(show.getEpisode(actual_season, curEp))
|
||||
epObjs = []
|
||||
epObjs.append(epObj)
|
||||
|
||||
result = self.getResult(epObj)
|
||||
result = self.getResult(epObjs)
|
||||
result.url = url
|
||||
result.name = title
|
||||
result.quality = quality
|
||||
result.provider = self
|
||||
result.content = None
|
||||
|
||||
if len(epObj) == 1:
|
||||
epNum = epObj[0].episode
|
||||
elif len(epObj) > 1:
|
||||
if len(epObjs) == 1:
|
||||
epNum = epObjs[0].episode
|
||||
elif len(epObjs) > 1:
|
||||
epNum = MULTI_EP_RESULT
|
||||
logger.log(u"Separating multi-episode result to check for later - result contains episodes: " + str(
|
||||
parse_result.episode_numbers), logger.DEBUG)
|
||||
elif len(epObj) == 0:
|
||||
elif len(epObjs) == 0:
|
||||
epNum = SEASON_RESULT
|
||||
result.extraInfo = [show]
|
||||
logger.log(u"Separating full season result to check for later", logger.DEBUG)
|
||||
|
@ -182,9 +182,16 @@ class TVShow(object):
|
||||
return ep_list
|
||||
|
||||
|
||||
def getEpisode(self, season, episode, file=None, noCreate=False):
|
||||
def getEpisode(self, season, episode, file=None, noCreate=False, sceneConvert=False):
|
||||
|
||||
#return TVEpisode(self, season, episode)
|
||||
if sceneConvert:
|
||||
for curSeason in self.episodes:
|
||||
for curEp in self.episodes[curSeason]:
|
||||
myEp = self.episodes[curSeason][curEp]
|
||||
if season == myEp.scene_season and episode == myEp.scene_episode:
|
||||
season = myEp.season
|
||||
episode = myEp.episode
|
||||
|
||||
if not season in self.episodes:
|
||||
self.episodes[season] = {}
|
||||
|
@ -192,8 +192,8 @@ class TVCache():
|
||||
# if we don't have complete info then parse the filename to get it
|
||||
for curName in [name] + extraNames:
|
||||
try:
|
||||
myParser = NameParser()
|
||||
parse_result = myParser.parse(curName, True)
|
||||
myParser = NameParser(regexMode=-1)
|
||||
parse_result = myParser.parse(curName)
|
||||
except InvalidNameException:
|
||||
logger.log(u"Unable to parse the filename " + curName + " into a valid episode", logger.DEBUG)
|
||||
continue
|
||||
@ -358,6 +358,10 @@ class TVCache():
|
||||
|
||||
# for each cache entry
|
||||
for curResult in sqlResults:
|
||||
# skip if we don't have a indexerid
|
||||
indexerid = int(curResult["indexerid"])
|
||||
if not indexerid:
|
||||
continue
|
||||
|
||||
# skip non-tv crap (but allow them for Newzbin cause we assume it's filtered well)
|
||||
if self.providerID != 'newzbin' and not show_name_helpers.filterBadReleases(curResult["name"]):
|
||||
@ -368,6 +372,7 @@ class TVCache():
|
||||
showObj = helpers.findCertainShow(sickbeard.showList, int(curResult["indexerid"]))
|
||||
except (MultipleShowObjectsException):
|
||||
showObj = None
|
||||
|
||||
if not showObj:
|
||||
continue
|
||||
|
||||
@ -381,13 +386,14 @@ class TVCache():
|
||||
curEp = int(curEp)
|
||||
curQuality = int(curResult["quality"])
|
||||
|
||||
# items stored in cache are scene numbered, convert before lookups
|
||||
epObj = showObj.getEpisode(curSeason, curEp, sceneConvert=True)
|
||||
|
||||
# if the show says we want that episode then add it to the list
|
||||
if not showObj.wantEpisode(curSeason, curEp, curQuality, manualSearch):
|
||||
if not showObj.wantEpisode(epObj.season, epObj.episode, curQuality, manualSearch):
|
||||
logger.log(u"Skipping " + curResult["name"] + " because we don't want an episode that's " +
|
||||
Quality.qualityStrings[curQuality], logger.DEBUG)
|
||||
|
||||
else:
|
||||
|
||||
if episode:
|
||||
epObj = episode
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user