mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-12 11:02:21 -05:00
Fixed backlog issues and improved cache and provider searches, this resolves issue #298
This commit is contained in:
parent
eabd0d092f
commit
1c6b0807b0
@ -254,9 +254,6 @@ class NameParser(object):
|
||||
# if the dirname has a release group/show name I believe it over the filename
|
||||
final_result.series_name = self._combine_results(dir_name_result, file_name_result, 'series_name')
|
||||
|
||||
# if final_result.sports:
|
||||
# final_result.series_name = str(final_result.series_name).partition(" ")[0]
|
||||
|
||||
final_result.extra_info = self._combine_results(dir_name_result, file_name_result, 'extra_info')
|
||||
final_result.release_group = self._combine_results(dir_name_result, file_name_result, 'release_group')
|
||||
|
||||
|
@ -339,8 +339,7 @@ class GenericProvider:
|
||||
wantEp = True
|
||||
for epNo in actual_episodes:
|
||||
epObj = self.show.getEpisode(actual_season, epNo)
|
||||
if not epObj or not self.show.wantEpisode(epObj.season, epObj.episode, quality,
|
||||
manualSearch=manualSearch):
|
||||
if not epObj or not self.show.wantEpisode(epObj.season, epObj.episode, quality,manualSearch=manualSearch):
|
||||
wantEp = False
|
||||
break
|
||||
|
||||
|
@ -348,9 +348,25 @@ def isFirstBestMatch(result):
|
||||
|
||||
return False
|
||||
|
||||
def filterSearchResults(show, results):
|
||||
foundResults = {}
|
||||
|
||||
# make a list of all the results for this provider
|
||||
for curEp in results:
|
||||
# skip non-tv crap
|
||||
results[curEp] = filter(
|
||||
lambda x: show_name_helpers.filterBadReleases(x.name) and show_name_helpers.isGoodResult(x.name, show),
|
||||
results[curEp])
|
||||
|
||||
if curEp in foundResults:
|
||||
foundResults[curEp] += results[curEp]
|
||||
else:
|
||||
foundResults[curEp] = results[curEp]
|
||||
|
||||
return foundResults
|
||||
|
||||
def searchProviders(show, season, episode=None, manualSearch=False):
|
||||
logger.log(u"Searching for stuff we need from " + show.name + " season " + str(season))
|
||||
curResults = {}
|
||||
foundResults = {}
|
||||
|
||||
didSearch = False
|
||||
@ -366,8 +382,6 @@ def searchProviders(show, season, episode=None, manualSearch=False):
|
||||
ep_obj = show.getEpisode(season, episode)
|
||||
wantedEps = [ep_obj]
|
||||
|
||||
|
||||
|
||||
for curProvider in providers.sortedProviderList():
|
||||
if not curProvider.isActive():
|
||||
continue
|
||||
@ -378,23 +392,21 @@ def searchProviders(show, season, episode=None, manualSearch=False):
|
||||
|
||||
# search cache first for wanted episodes
|
||||
for ep_obj in wantedEps:
|
||||
results = curProvider.cache.searchCache(ep_obj, manualSearch)
|
||||
if results:
|
||||
curResults.update(results)
|
||||
curResults = curProvider.cache.searchCache(ep_obj, manualSearch)
|
||||
foundResults = filterSearchResults(show, curResults)
|
||||
|
||||
# did we find our results ?
|
||||
if len(curResults):
|
||||
logger.log(u"Cache results: " + repr(curResults), logger.DEBUG)
|
||||
if len(foundResults):
|
||||
logger.log(u"Cache results: " + repr(foundResults), logger.DEBUG)
|
||||
didSearch = True
|
||||
break
|
||||
|
||||
if not len(curResults):
|
||||
if not len(foundResults):
|
||||
for curProvider in providers.sortedProviderList():
|
||||
if not curProvider.isActive():
|
||||
continue
|
||||
|
||||
try:
|
||||
curResults.update(curProvider.getSearchResults(show, season, wantedEps, seasonSearch, manualSearch))
|
||||
curResults = curProvider.getSearchResults(show, season, wantedEps, seasonSearch, manualSearch)
|
||||
except exceptions.AuthException, e:
|
||||
logger.log(u"Authentication error: " + ex(e), logger.ERROR)
|
||||
continue
|
||||
@ -403,18 +415,13 @@ def searchProviders(show, season, episode=None, manualSearch=False):
|
||||
logger.log(traceback.format_exc(), logger.DEBUG)
|
||||
continue
|
||||
|
||||
# finished searching this provider successfully
|
||||
didSearch = True
|
||||
|
||||
# make a list of all the results for this provider
|
||||
for curEp in curResults:
|
||||
# skip non-tv crap
|
||||
curResults[curEp] = filter(
|
||||
lambda x: show_name_helpers.filterBadReleases(x.name) and show_name_helpers.isGoodResult(x.name,show),curResults[curEp])
|
||||
|
||||
if curEp in foundResults:
|
||||
foundResults[curEp] += curResults[curEp]
|
||||
else:
|
||||
foundResults[curEp] = curResults[curEp]
|
||||
foundResults = filterSearchResults(show, curResults)
|
||||
if len(foundResults):
|
||||
logger.log(u"Provider search results: " + str(foundResults), logger.DEBUG)
|
||||
break
|
||||
|
||||
if not didSearch:
|
||||
logger.log(u"No NZB/Torrent providers found or enabled in the sickbeard config. Please check your settings.",
|
||||
|
@ -123,7 +123,7 @@ class BacklogSearcher:
|
||||
if curShow.air_by_date:
|
||||
segments = [x[1] for x in self._get_air_by_date_segments(curShow.indexerid, fromDate)]
|
||||
elif curShow.sports:
|
||||
segments = [x[1] for x in self._get_sports_segments(curShow.indexerid, fromDate)]
|
||||
segments = self._get_sports_segments(curShow.indexerid, fromDate)
|
||||
else:
|
||||
segments = self._get_season_segments(curShow.indexerid, fromDate)
|
||||
|
||||
@ -195,24 +195,11 @@ class BacklogSearcher:
|
||||
return air_by_date_segments
|
||||
|
||||
def _get_sports_segments(self, indexer_id, fromDate):
|
||||
# query the DB for all dates for this show
|
||||
myDB = db.DBConnection()
|
||||
num_sports_results = myDB.select(
|
||||
"SELECT airdate, showid FROM tv_episodes ep, tv_shows show WHERE season != 0 AND ep.showid = show.indexer_id AND show.paused = 0 ANd ep.airdate > ? AND ep.showid = ? AND show.sports = 1",
|
||||
[fromDate.toordinal(), indexer_id])
|
||||
|
||||
# break them apart into month/year strings
|
||||
sports_segments = []
|
||||
for cur_result in num_sports_results:
|
||||
cur_date = datetime.date.fromordinal(int(cur_result["airdate"]))
|
||||
cur_date_str = str(cur_date)[:7]
|
||||
cur_indexer_id = int(cur_result["showid"])
|
||||
|
||||
cur_result_tuple = (cur_indexer_id, cur_date_str)
|
||||
if cur_result_tuple not in sports_segments:
|
||||
sports_segments.append(cur_result_tuple)
|
||||
|
||||
return sports_segments
|
||||
sqlResults = myDB.select(
|
||||
"SELECT DISTINCT(season) as season FROM tv_episodes WHERE showid = ? AND season > 0 and airdate > ?",
|
||||
[indexer_id, fromDate.toordinal()])
|
||||
return [int(x["season"]) for x in sqlResults]
|
||||
|
||||
def _set_lastBacklog(self, when):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user