Provider searches for backlog, manual, and failed have been re-worked to not hammer the providers so much plus perform alot faster.

This commit is contained in:
echel0n 2014-07-20 22:07:53 -07:00
parent f6d662ca6b
commit ff5107cfe2

View file

@ -236,45 +236,44 @@ class GenericProvider:
self.show = show self.show = show
results = {} results = {}
searchItems = {} itemList = []
searched_scene_season = None searched_scene_season = None
for epObj in episodes: for epObj in episodes:
itemList = [] items = []
if search_mode == 'sponly' and searched_scene_season: # check cache for results
if searched_scene_season == epObj.scene_season:
continue
# mark season searched for season pack searches so we can skip later on
searched_scene_season = epObj.scene_season
if search_mode == 'sponly':
for curString in self._get_season_search_strings(epObj):
itemList += self._doSearch(curString, len(episodes))
else:
cacheResult = self.cache.searchCache([epObj], manualSearch) cacheResult = self.cache.searchCache([epObj], manualSearch)
if len(cacheResult): if len(cacheResult):
results.update({epObj.episode: cacheResult[epObj]}) results.update({epObj.episode: cacheResult[epObj]})
continue continue
for curString in self._get_episode_search_strings(epObj): # skip if season already searched
itemList += self._doSearch(curString, len(episodes)) if len(episodes) > 1 and searched_scene_season == epObj.scene_season:
# next episode if no search results
if not len(itemList):
continue continue
# remove duplicate items # mark season searched for season pack searches so we can skip later on
searchItems[epObj] = itemList searched_scene_season = epObj.scene_season
# if we have cached results return them. if len(episodes) > 1:
if len(results): # get season search results
for curString in self._get_season_search_strings(epObj):
items += self._doSearch(curString, len(episodes))
else:
# get single episode search results
for curString in self._get_episode_search_strings(epObj):
items += self._doSearch(curString, len(episodes))
# add items to list
if len(items):
itemList += items
# if we found what we needed already from cache then return results and exit
if len(results) == len(episodes):
return results return results
for ep_obj in searchItems: # filter results
for item in searchItems[ep_obj]: for item in itemList:
(title, url) = self._get_title_and_url(item) (title, url) = self._get_title_and_url(item)
# parse the file name # parse the file name
@ -291,8 +290,9 @@ class GenericProvider:
showObj = parse_result.show showObj = parse_result.show
quality = parse_result.quality quality = parse_result.quality
release_group = parse_result.release_group release_group = parse_result.release_group
ep_obj = showObj.getEpisode(season, parse_result.episode_numbers[0])
if not (self.show.air_by_date or self.show.sports): if not (showObj.air_by_date or showObj.sports):
if search_mode == 'sponly' and len(parse_result.episode_numbers): if search_mode == 'sponly' and len(parse_result.episode_numbers):
logger.log( logger.log(
u"This is supposed to be a season pack search but the result " + title + " is not a valid season pack, skipping it", u"This is supposed to be a season pack search but the result " + title + " is not a valid season pack, skipping it",
@ -331,7 +331,7 @@ class GenericProvider:
myDB = db.DBConnection() myDB = db.DBConnection()
sql_results = myDB.select( sql_results = myDB.select(
"SELECT season, episode FROM tv_episodes WHERE showid = ? AND airdate = ?", "SELECT season, episode FROM tv_episodes WHERE showid = ? AND airdate = ?",
[show.indexerid, airdate]) [showObj.indexerid, airdate])
if len(sql_results) != 1: if len(sql_results) != 1:
logger.log( logger.log(
@ -345,7 +345,7 @@ class GenericProvider:
# make sure we want the episode # make sure we want the episode
wantEp = True wantEp = True
for epNo in actual_episodes: for epNo in actual_episodes:
if not show.wantEpisode(actual_season, epNo, quality, manualSearch): if not showObj.wantEpisode(actual_season, epNo, quality, manualSearch):
wantEp = False wantEp = False
break break
@ -362,7 +362,7 @@ class GenericProvider:
# make a result object # make a result object
epObj = [] epObj = []
for curEp in actual_episodes: for curEp in actual_episodes:
epObj.append(show.getEpisode(actual_season, curEp)) epObj.append(showObj.getEpisode(actual_season, curEp))
result = self.getResult(epObj) result = self.getResult(epObj)
result.show = showObj result.show = showObj