mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-23 01:43:43 +00: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:
parent
54f769e224
commit
7e800ff524
3 changed files with 50 additions and 41 deletions
|
@ -280,8 +280,11 @@ class ParseResult(object):
|
||||||
extra_info=None,
|
extra_info=None,
|
||||||
release_group=None,
|
release_group=None,
|
||||||
air_date=None,
|
air_date=None,
|
||||||
|
show=None,
|
||||||
):
|
):
|
||||||
|
|
||||||
|
self.show = show
|
||||||
|
|
||||||
self.original_name = original_name
|
self.original_name = original_name
|
||||||
|
|
||||||
self.series_name = series_name
|
self.series_name = series_name
|
||||||
|
@ -360,6 +363,8 @@ class ParseResult(object):
|
||||||
# convert scene numbered releases before storing to cache
|
# convert scene numbered releases before storing to cache
|
||||||
showObj = helpers.get_show_by_name(self.series_name)
|
showObj = helpers.get_show_by_name(self.series_name)
|
||||||
if showObj:
|
if showObj:
|
||||||
|
self.show = showObj
|
||||||
|
|
||||||
new_episode_numbers = []
|
new_episode_numbers = []
|
||||||
new_season_numbers = []
|
new_season_numbers = []
|
||||||
for epNo in self.episode_numbers:
|
for epNo in self.episode_numbers:
|
||||||
|
|
|
@ -249,11 +249,15 @@ class GenericProvider:
|
||||||
|
|
||||||
def getSearchResults(self, show, season, ep_objs, seasonSearch=False, manualSearch=False):
|
def getSearchResults(self, show, season, ep_objs, seasonSearch=False, manualSearch=False):
|
||||||
|
|
||||||
|
self._checkAuth()
|
||||||
|
self.show = show
|
||||||
|
|
||||||
itemList = []
|
itemList = []
|
||||||
results = {}
|
results = {}
|
||||||
|
|
||||||
self._checkAuth()
|
useDate = False
|
||||||
self.show = show
|
if self.show.air_by_date or self.show.sports:
|
||||||
|
useDate = True
|
||||||
|
|
||||||
regexMode = 0
|
regexMode = 0
|
||||||
if self.show.sports:
|
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)
|
logger.log(u"Unable to parse the filename " + title + " into a valid episode", logger.WARNING)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not (self.show.air_by_date, self.show.sports):
|
|
||||||
|
if not useDate:
|
||||||
# this check is meaningless for non-season searches
|
# this check is meaningless for non-season searches
|
||||||
if (parse_result.season_number is not None and parse_result.season_number != season) or (
|
if (parse_result.season_number is not None and parse_result.season_number != season) or (
|
||||||
parse_result.season_number is None and season != 1):
|
parse_result.season_number is None and season != 1):
|
||||||
|
@ -291,23 +296,27 @@ class GenericProvider:
|
||||||
season) + ", ignoring", logger.DEBUG)
|
season) + ", ignoring", logger.DEBUG)
|
||||||
continue
|
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
|
# we just use the existing info for normal searches
|
||||||
actual_season = parse_result.season_number
|
actual_season = season if manualSearch else parse_result.season_number
|
||||||
actual_episodes = parse_result.episode_numbers
|
actual_episodes = [ep_objs[0].episode] if manualSearch else parse_result.episode_numbers
|
||||||
|
|
||||||
else:
|
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(
|
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)
|
logger.DEBUG)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if self.show.sports and not parse_result.sports_event_date:
|
if manualSearch and parse_result.air_date != ep_objs[0].airdate:
|
||||||
logger.log(
|
logger.log(u"Episode " + title + " didn't air on " + str(ep_objs[0].airdate) + ", skipping it",
|
||||||
u"This is supposed to be an sports-event-date search but the result " + title + " didn't parse as one, skipping it",
|
|
||||||
logger.DEBUG)
|
logger.DEBUG)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if not manualSearch:
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
if parse_result.air_by_date:
|
if parse_result.air_by_date:
|
||||||
sql_results = myDB.select(
|
sql_results = myDB.select(
|
||||||
|
@ -324,8 +333,9 @@ class GenericProvider:
|
||||||
logger.WARNING)
|
logger.WARNING)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
actual_season = int(sql_results[0]["season"])
|
actual_season = season if manualSearch else int(sql_results[0]["season"])
|
||||||
actual_episodes = [int(sql_results[0]["episode"])]
|
actual_episodes = [ep_objs[0].episode] if manualSearch else [int(sql_results[0]["episode"])]
|
||||||
|
|
||||||
|
|
||||||
# make sure we want the episode
|
# make sure we want the episode
|
||||||
wantEp = True
|
wantEp = True
|
||||||
|
|
|
@ -198,7 +198,7 @@ class TVCache():
|
||||||
|
|
||||||
# if we don't have complete info then parse the filename to get it
|
# if we don't have complete info then parse the filename to get it
|
||||||
try:
|
try:
|
||||||
myParser = NameParser()
|
myParser = NameParser(0)
|
||||||
parse_result = myParser.parse(name).convert()
|
parse_result = myParser.parse(name).convert()
|
||||||
except InvalidNameException:
|
except InvalidNameException:
|
||||||
logger.log(u"Unable to parse the filename " + name + " into a valid episode", logger.DEBUG)
|
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)
|
logger.log(u"No series name retrieved from " + name + ", unable to cache it", logger.DEBUG)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
if not parse_result.show:
|
||||||
showObj = helpers.get_show_by_name(parse_result.series_name)
|
logger.log(u"Couldn't find a show in our databases from " + name + ", unable to cache it", logger.DEBUG)
|
||||||
if showObj is None:
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
if showObj.air_by_date:
|
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 = ?",
|
sql_results = myDB.select("SELECT season, episode FROM tv_episodes WHERE showid = ? AND airdate = ?",
|
||||||
[showObj.indexerid, parse_result.air_date.toordinal()])
|
[showObj.indexerid, airdate])
|
||||||
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()])
|
|
||||||
|
|
||||||
if sql_results > 0:
|
if sql_results > 0:
|
||||||
season = int(sql_results[0]["season"])
|
season = int(sql_results[0]["season"])
|
||||||
episodes = [int(sql_results[0]["episode"])]
|
episodes = [int(sql_results[0]["episode"])]
|
||||||
|
|
Loading…
Reference in a new issue