mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-13 03:22:22 -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
|
# 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')
|
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.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')
|
final_result.release_group = self._combine_results(dir_name_result, file_name_result, 'release_group')
|
||||||
|
|
||||||
|
@ -339,8 +339,7 @@ class GenericProvider:
|
|||||||
wantEp = True
|
wantEp = True
|
||||||
for epNo in actual_episodes:
|
for epNo in actual_episodes:
|
||||||
epObj = self.show.getEpisode(actual_season, epNo)
|
epObj = self.show.getEpisode(actual_season, epNo)
|
||||||
if not epObj or not self.show.wantEpisode(epObj.season, epObj.episode, quality,
|
if not epObj or not self.show.wantEpisode(epObj.season, epObj.episode, quality,manualSearch=manualSearch):
|
||||||
manualSearch=manualSearch):
|
|
||||||
wantEp = False
|
wantEp = False
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -348,9 +348,25 @@ def isFirstBestMatch(result):
|
|||||||
|
|
||||||
return False
|
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):
|
def searchProviders(show, season, episode=None, manualSearch=False):
|
||||||
logger.log(u"Searching for stuff we need from " + show.name + " season " + str(season))
|
logger.log(u"Searching for stuff we need from " + show.name + " season " + str(season))
|
||||||
curResults = {}
|
|
||||||
foundResults = {}
|
foundResults = {}
|
||||||
|
|
||||||
didSearch = False
|
didSearch = False
|
||||||
@ -366,8 +382,6 @@ def searchProviders(show, season, episode=None, manualSearch=False):
|
|||||||
ep_obj = show.getEpisode(season, episode)
|
ep_obj = show.getEpisode(season, episode)
|
||||||
wantedEps = [ep_obj]
|
wantedEps = [ep_obj]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for curProvider in providers.sortedProviderList():
|
for curProvider in providers.sortedProviderList():
|
||||||
if not curProvider.isActive():
|
if not curProvider.isActive():
|
||||||
continue
|
continue
|
||||||
@ -378,23 +392,21 @@ def searchProviders(show, season, episode=None, manualSearch=False):
|
|||||||
|
|
||||||
# search cache first for wanted episodes
|
# search cache first for wanted episodes
|
||||||
for ep_obj in wantedEps:
|
for ep_obj in wantedEps:
|
||||||
results = curProvider.cache.searchCache(ep_obj, manualSearch)
|
curResults = curProvider.cache.searchCache(ep_obj, manualSearch)
|
||||||
if results:
|
foundResults = filterSearchResults(show, curResults)
|
||||||
curResults.update(results)
|
|
||||||
|
|
||||||
# did we find our results ?
|
if len(foundResults):
|
||||||
if len(curResults):
|
logger.log(u"Cache results: " + repr(foundResults), logger.DEBUG)
|
||||||
logger.log(u"Cache results: " + repr(curResults), logger.DEBUG)
|
|
||||||
didSearch = True
|
didSearch = True
|
||||||
break
|
break
|
||||||
|
|
||||||
if not len(curResults):
|
if not len(foundResults):
|
||||||
for curProvider in providers.sortedProviderList():
|
for curProvider in providers.sortedProviderList():
|
||||||
if not curProvider.isActive():
|
if not curProvider.isActive():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
curResults.update(curProvider.getSearchResults(show, season, wantedEps, seasonSearch, manualSearch))
|
curResults = curProvider.getSearchResults(show, season, wantedEps, seasonSearch, manualSearch)
|
||||||
except exceptions.AuthException, e:
|
except exceptions.AuthException, e:
|
||||||
logger.log(u"Authentication error: " + ex(e), logger.ERROR)
|
logger.log(u"Authentication error: " + ex(e), logger.ERROR)
|
||||||
continue
|
continue
|
||||||
@ -403,18 +415,13 @@ def searchProviders(show, season, episode=None, manualSearch=False):
|
|||||||
logger.log(traceback.format_exc(), logger.DEBUG)
|
logger.log(traceback.format_exc(), logger.DEBUG)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# finished searching this provider successfully
|
||||||
didSearch = True
|
didSearch = True
|
||||||
|
|
||||||
# make a list of all the results for this provider
|
foundResults = filterSearchResults(show, curResults)
|
||||||
for curEp in curResults:
|
if len(foundResults):
|
||||||
# skip non-tv crap
|
logger.log(u"Provider search results: " + str(foundResults), logger.DEBUG)
|
||||||
curResults[curEp] = filter(
|
break
|
||||||
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]
|
|
||||||
|
|
||||||
if not didSearch:
|
if not didSearch:
|
||||||
logger.log(u"No NZB/Torrent providers found or enabled in the sickbeard config. Please check your settings.",
|
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:
|
if curShow.air_by_date:
|
||||||
segments = [x[1] for x in self._get_air_by_date_segments(curShow.indexerid, fromDate)]
|
segments = [x[1] for x in self._get_air_by_date_segments(curShow.indexerid, fromDate)]
|
||||||
elif curShow.sports:
|
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:
|
else:
|
||||||
segments = self._get_season_segments(curShow.indexerid, fromDate)
|
segments = self._get_season_segments(curShow.indexerid, fromDate)
|
||||||
|
|
||||||
@ -195,24 +195,11 @@ class BacklogSearcher:
|
|||||||
return air_by_date_segments
|
return air_by_date_segments
|
||||||
|
|
||||||
def _get_sports_segments(self, indexer_id, fromDate):
|
def _get_sports_segments(self, indexer_id, fromDate):
|
||||||
# query the DB for all dates for this show
|
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
num_sports_results = myDB.select(
|
sqlResults = 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",
|
"SELECT DISTINCT(season) as season FROM tv_episodes WHERE showid = ? AND season > 0 and airdate > ?",
|
||||||
[fromDate.toordinal(), indexer_id])
|
[indexer_id, fromDate.toordinal()])
|
||||||
|
return [int(x["season"]) for x in sqlResults]
|
||||||
# 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
|
|
||||||
|
|
||||||
def _set_lastBacklog(self, when):
|
def _set_lastBacklog(self, when):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user