mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-07 10:33:38 +00:00
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:
parent
f6d662ca6b
commit
ff5107cfe2
1 changed files with 131 additions and 131 deletions
|
@ -236,45 +236,44 @@ class GenericProvider:
|
|||
self.show = show
|
||||
|
||||
results = {}
|
||||
searchItems = {}
|
||||
itemList = []
|
||||
|
||||
searched_scene_season = None
|
||||
for epObj in episodes:
|
||||
itemList = []
|
||||
items = []
|
||||
|
||||
if search_mode == 'sponly' and searched_scene_season:
|
||||
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:
|
||||
# check cache for results
|
||||
cacheResult = self.cache.searchCache([epObj], manualSearch)
|
||||
if len(cacheResult):
|
||||
results.update({epObj.episode: cacheResult[epObj]})
|
||||
continue
|
||||
|
||||
for curString in self._get_episode_search_strings(epObj):
|
||||
itemList += self._doSearch(curString, len(episodes))
|
||||
|
||||
# next episode if no search results
|
||||
if not len(itemList):
|
||||
# skip if season already searched
|
||||
if len(episodes) > 1 and searched_scene_season == epObj.scene_season:
|
||||
continue
|
||||
|
||||
# remove duplicate items
|
||||
searchItems[epObj] = itemList
|
||||
# mark season searched for season pack searches so we can skip later on
|
||||
searched_scene_season = epObj.scene_season
|
||||
|
||||
# if we have cached results return them.
|
||||
if len(results):
|
||||
if len(episodes) > 1:
|
||||
# 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
|
||||
|
||||
for ep_obj in searchItems:
|
||||
for item in searchItems[ep_obj]:
|
||||
|
||||
# filter results
|
||||
for item in itemList:
|
||||
(title, url) = self._get_title_and_url(item)
|
||||
|
||||
# parse the file name
|
||||
|
@ -291,8 +290,9 @@ class GenericProvider:
|
|||
showObj = parse_result.show
|
||||
quality = parse_result.quality
|
||||
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):
|
||||
logger.log(
|
||||
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()
|
||||
sql_results = myDB.select(
|
||||
"SELECT season, episode FROM tv_episodes WHERE showid = ? AND airdate = ?",
|
||||
[show.indexerid, airdate])
|
||||
[showObj.indexerid, airdate])
|
||||
|
||||
if len(sql_results) != 1:
|
||||
logger.log(
|
||||
|
@ -345,7 +345,7 @@ class GenericProvider:
|
|||
# make sure we want the episode
|
||||
wantEp = True
|
||||
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
|
||||
break
|
||||
|
||||
|
@ -362,7 +362,7 @@ class GenericProvider:
|
|||
# make a result object
|
||||
epObj = []
|
||||
for curEp in actual_episodes:
|
||||
epObj.append(show.getEpisode(actual_season, curEp))
|
||||
epObj.append(showObj.getEpisode(actual_season, curEp))
|
||||
|
||||
result = self.getResult(epObj)
|
||||
result.show = showObj
|
||||
|
|
Loading…
Reference in a new issue