1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-08-13 16:53:54 -04:00

Fixed manual episode searches.

Corrected a issue where SB was being searched twice for the same show wasting cpu cycles.
This commit is contained in:
echel0n 2014-04-30 18:20:53 -07:00
parent 54f769e224
commit 7e800ff524
3 changed files with 50 additions and 41 deletions

View File

@ -280,8 +280,11 @@ class ParseResult(object):
extra_info=None,
release_group=None,
air_date=None,
show=None,
):
self.show = show
self.original_name = original_name
self.series_name = series_name
@ -360,6 +363,8 @@ class ParseResult(object):
# convert scene numbered releases before storing to cache
showObj = helpers.get_show_by_name(self.series_name)
if showObj:
self.show = showObj
new_episode_numbers = []
new_season_numbers = []
for epNo in self.episode_numbers:

View File

@ -249,11 +249,15 @@ class GenericProvider:
def getSearchResults(self, show, season, ep_objs, seasonSearch=False, manualSearch=False):
self._checkAuth()
self.show = show
itemList = []
results = {}
self._checkAuth()
self.show = show
useDate = False
if self.show.air_by_date or self.show.sports:
useDate = True
regexMode = 0
if self.show.sports:
@ -283,7 +287,8 @@ class GenericProvider:
logger.log(u"Unable to parse the filename " + title + " into a valid episode", logger.WARNING)
continue
if not (self.show.air_by_date, self.show.sports):
if not useDate:
# this check is meaningless for non-season searches
if (parse_result.season_number is not None and parse_result.season_number != season) or (
parse_result.season_number is None and season != 1):
@ -291,23 +296,27 @@ class GenericProvider:
season) + ", ignoring", logger.DEBUG)
continue
if manualSearch and (parse_result.season_number != season or ep_objs[0].episode not in parse_result.episode_numbers):
logger.log(u"Episode " + title + " isn't " + str(season) + "x" + str(
ep_objs[0].episode) + ", skipping it", logger.DEBUG)
continue
# we just use the existing info for normal searches
actual_season = parse_result.season_number
actual_episodes = parse_result.episode_numbers
actual_season = season if manualSearch else parse_result.season_number
actual_episodes = [ep_objs[0].episode] if manualSearch else parse_result.episode_numbers
else:
if self.show.air_by_date and not parse_result.air_by_date:
if not (parse_result.air_by_date,parse_result.sports_event_date):
logger.log(
u"This is supposed to be an air-by-date search but the result " + title + " didn't parse as one, skipping it",
u"This is supposed to be an date search but the result " + title + " didn't parse as one, skipping it",
logger.DEBUG)
continue
if self.show.sports and not parse_result.sports_event_date:
logger.log(
u"This is supposed to be an sports-event-date search but the result " + title + " didn't parse as one, skipping it",
if manualSearch and parse_result.air_date != ep_objs[0].airdate:
logger.log(u"Episode " + title + " didn't air on " + str(ep_objs[0].airdate) + ", skipping it",
logger.DEBUG)
continue
if not manualSearch:
myDB = db.DBConnection()
if parse_result.air_by_date:
sql_results = myDB.select(
@ -324,8 +333,9 @@ class GenericProvider:
logger.WARNING)
continue
actual_season = int(sql_results[0]["season"])
actual_episodes = [int(sql_results[0]["episode"])]
actual_season = season if manualSearch else int(sql_results[0]["season"])
actual_episodes = [ep_objs[0].episode] if manualSearch else [int(sql_results[0]["episode"])]
# make sure we want the episode
wantEp = True

View File

@ -198,7 +198,7 @@ class TVCache():
# if we don't have complete info then parse the filename to get it
try:
myParser = NameParser()
myParser = NameParser(0)
parse_result = myParser.parse(name).convert()
except InvalidNameException:
logger.log(u"Unable to parse the filename " + name + " into a valid episode", logger.DEBUG)
@ -212,22 +212,16 @@ class TVCache():
logger.log(u"No series name retrieved from " + name + ", unable to cache it", logger.DEBUG)
return None
try:
showObj = helpers.get_show_by_name(parse_result.series_name)
if showObj is None:
if not parse_result.show:
logger.log(u"Couldn't find a show in our databases from " + name + ", unable to cache it", logger.DEBUG)
return None
try:
myDB = db.DBConnection()
if showObj.air_by_date:
airdate = parse_result.sports_event_date.toordinal() if showObj.sports else parse_result.air_date.toordinal()
sql_results = myDB.select("SELECT season, episode FROM tv_episodes WHERE showid = ? AND airdate = ?",
[showObj.indexerid, parse_result.air_date.toordinal()])
if sql_results > 0:
season = int(sql_results[0]["season"])
episodes = [int(sql_results[0]["episode"])]
elif showObj.sports:
sql_results = myDB.select("SELECT season, episode FROM tv_episodes WHERE showid = ? AND airdate = ?",
[showObj.indexerid, parse_result.sports_event_date.toordinal()])
[showObj.indexerid, airdate])
if sql_results > 0:
season = int(sql_results[0]["season"])
episodes = [int(sql_results[0]["episode"])]