mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-01 08:53:37 +00:00
Merge branch 'origin/dev'
This commit is contained in:
commit
10321a5b2b
2 changed files with 45 additions and 38 deletions
|
@ -523,30 +523,46 @@ def searchProviders(queueItem, show, season, episodes, seasonSearch=False, manua
|
|||
|
||||
finalResults.append(bestResult)
|
||||
|
||||
if manualSearch:
|
||||
logger.log(u"Checking if we should snatch " + bestResult.name, logger.DEBUG)
|
||||
any_qualities, best_qualities = Quality.splitQuality(show.quality)
|
||||
logger.log(u"Checking if we should snatch " + bestResult.name, logger.DEBUG)
|
||||
any_qualities, best_qualities = Quality.splitQuality(show.quality)
|
||||
|
||||
# if there is a redownload that's higher than this then we definitely need to keep looking
|
||||
if best_qualities and bestResult.quality == max(best_qualities):
|
||||
logger.log(u"Found a highest quality archive match to snatch [" + bestResult.name + "]", logger.DEBUG)
|
||||
queueItem.results = [bestResult]
|
||||
# if there is a redownload that's higher than this then we definitely need to keep looking
|
||||
if best_qualities and bestResult.quality == max(best_qualities):
|
||||
logger.log(u"Found a highest quality archive match to snatch [" + bestResult.name + "]", logger.DEBUG)
|
||||
queueItem.results += [bestResult]
|
||||
|
||||
# check that we got all the episodes we wanted first before doing a match and snatch
|
||||
wantedEpCount = 0
|
||||
for wantedEp in episodes:
|
||||
for result in queueItem.results:
|
||||
if wantedEp in result.episodes:
|
||||
wantedEpCount += 1
|
||||
if wantedEpCount == len(episodes):
|
||||
return queueItem
|
||||
|
||||
# if there's no redownload that's higher (above) and this is the highest initial download then we're good
|
||||
elif any_qualities and bestResult.quality in any_qualities:
|
||||
logger.log(u"Found a initial quality match to snatch [" + bestResult.name + "]", logger.DEBUG)
|
||||
queueItem.results = [bestResult]
|
||||
# if there's no redownload that's higher (above) and this is the highest initial download then we're good
|
||||
elif any_qualities and bestResult.quality in any_qualities:
|
||||
logger.log(u"Found a initial quality match to snatch [" + bestResult.name + "]", logger.DEBUG)
|
||||
queueItem.results += [bestResult]
|
||||
|
||||
# check that we got all the episodes we wanted first before doing a match and snatch
|
||||
wantedEpCount = 0
|
||||
for wantedEp in episodes:
|
||||
for result in queueItem.results:
|
||||
if wantedEp in result.episodes:
|
||||
wantedEpCount += 1
|
||||
if wantedEpCount == len(episodes):
|
||||
return queueItem
|
||||
|
||||
|
||||
# make sure we search every provider for results
|
||||
if providerNum < len(providers):
|
||||
if providerNum != len(providers):
|
||||
continue
|
||||
|
||||
# remove duplicates and insures snatch of highest quality from results
|
||||
for i1, result1 in enumerate(finalResults):
|
||||
for i2, result2 in enumerate(finalResults):
|
||||
if result2.provider.show == show and result2.episodes.sort() == episodes.sort() and len(finalResults) > 1:
|
||||
if result1.provider.show == result2.provider.show and result1.episodes.sort() == result2.episodes.sort():
|
||||
if result1.quality >= result2.quality:
|
||||
finalResults.pop(i2)
|
||||
|
||||
|
|
|
@ -90,7 +90,6 @@ class SearchQueue(generic_queue.GenericQueue):
|
|||
status = search.snatchEpisode(result)
|
||||
item.success = status
|
||||
generic_queue.QueueItem.finish(item)
|
||||
return status
|
||||
|
||||
class ManualSearchQueueItem(generic_queue.QueueItem):
|
||||
def __init__(self, ep_obj):
|
||||
|
@ -100,6 +99,7 @@ class ManualSearchQueueItem(generic_queue.QueueItem):
|
|||
self.success = None
|
||||
self.show = ep_obj.show
|
||||
self.ep_obj = ep_obj
|
||||
self.results = []
|
||||
|
||||
def execute(self):
|
||||
generic_queue.QueueItem.execute(self)
|
||||
|
@ -109,25 +109,18 @@ class ManualSearchQueueItem(generic_queue.QueueItem):
|
|||
searchResult = search.searchProviders(self, self.show, self.ep_obj.season, [self.ep_obj],False,True)
|
||||
|
||||
if searchResult:
|
||||
self.success = SearchQueue().snatch_item(searchResult)
|
||||
SearchQueue().snatch_item(searchResult)
|
||||
else:
|
||||
ui.notifications.message('No downloads were found',
|
||||
"Couldn't find a download for <i>%s</i>" % self.ep_obj.prettyName())
|
||||
|
||||
logger.log(u"Unable to find a download for " + self.ep_obj.prettyName())
|
||||
|
||||
except Exception:
|
||||
logger.log(traceback.format_exc(), logger.DEBUG)
|
||||
|
||||
if not self.success:
|
||||
ui.notifications.message('No downloads were found',
|
||||
"Couldn't find a download for <i>%s</i>" % self.ep_obj.prettyName())
|
||||
logger.log(u"Unable to find a download for " + self.ep_obj.prettyName())
|
||||
|
||||
self.finish()
|
||||
|
||||
def finish(self):
|
||||
# don't let this linger if something goes wrong
|
||||
if self.success == None:
|
||||
self.success = False
|
||||
generic_queue.QueueItem.finish(self)
|
||||
|
||||
|
||||
class BacklogQueueItem(generic_queue.QueueItem):
|
||||
def __init__(self, show, segment):
|
||||
generic_queue.QueueItem.__init__(self, 'Backlog', BACKLOG_SEARCH)
|
||||
|
@ -137,6 +130,7 @@ class BacklogQueueItem(generic_queue.QueueItem):
|
|||
self.show = show
|
||||
self.segment = segment
|
||||
self.wantedEpisodes = []
|
||||
self.results = []
|
||||
|
||||
self._changeMissingEpisodes()
|
||||
|
||||
|
@ -174,21 +168,18 @@ class BacklogQueueItem(generic_queue.QueueItem):
|
|||
if len(seasonEps) == len(self.wantedEpisodes):
|
||||
seasonSearch = True
|
||||
|
||||
providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive() and x]
|
||||
|
||||
try:
|
||||
logger.log("Beginning backlog search for episodes from [" + self.show.name + "] - Season[" + str(self.segment) + "]")
|
||||
searchResult = search.searchProviders(self, self.show, self.segment, self.wantedEpisodes, seasonSearch, False)
|
||||
|
||||
if searchResult:
|
||||
self.success = SearchQueue().snatch_item(searchResult)
|
||||
SearchQueue().snatch_item(searchResult)
|
||||
else:
|
||||
logger.log(u"No needed episodes found during backlog search")
|
||||
|
||||
except Exception:
|
||||
logger.log(traceback.format_exc(), logger.DEBUG)
|
||||
|
||||
if not self.success:
|
||||
logger.log(u"No needed episodes found during backlog search")
|
||||
|
||||
self.finish()
|
||||
|
||||
def _need_any_episodes(self, statusResults, bestQualities):
|
||||
|
@ -253,6 +244,7 @@ class FailedQueueItem(generic_queue.QueueItem):
|
|||
self.show = show
|
||||
self.episodes = episodes
|
||||
self.success = None
|
||||
self.results = []
|
||||
|
||||
def execute(self):
|
||||
generic_queue.QueueItem.execute(self)
|
||||
|
@ -274,13 +266,12 @@ class FailedQueueItem(generic_queue.QueueItem):
|
|||
"Beginning failed download search for episodes from Season [" + str(self.episodes[0].season) + "]")
|
||||
|
||||
searchResult = search.searchProviders(self, self.show, failed_episodes[0].season, failed_episodes, False, True)
|
||||
if searchResult:
|
||||
self.success = SearchQueue().snatch_item(searchResult)
|
||||
|
||||
if searchResult:
|
||||
SearchQueue().snatch_item(searchResult)
|
||||
else:
|
||||
logger.log(u"No episodes found to retry for failed downloads return from providers!")
|
||||
except Exception, e:
|
||||
logger.log(traceback.format_exc(), logger.DEBUG)
|
||||
|
||||
if not self.success:
|
||||
logger.log(u"No episodes found to retry for failed downloads return from providers!")
|
||||
|
||||
self.finish()
|
Loading…
Reference in a new issue