mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-11 05:33: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)
|
finalResults.append(bestResult)
|
||||||
|
|
||||||
if manualSearch:
|
|
||||||
logger.log(u"Checking if we should snatch " + bestResult.name, logger.DEBUG)
|
logger.log(u"Checking if we should snatch " + bestResult.name, logger.DEBUG)
|
||||||
any_qualities, best_qualities = Quality.splitQuality(show.quality)
|
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 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):
|
if best_qualities and bestResult.quality == max(best_qualities):
|
||||||
logger.log(u"Found a highest quality archive match to snatch [" + bestResult.name + "]", logger.DEBUG)
|
logger.log(u"Found a highest quality archive match to snatch [" + bestResult.name + "]", logger.DEBUG)
|
||||||
queueItem.results = [bestResult]
|
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
|
return queueItem
|
||||||
|
|
||||||
# if there's no redownload that's higher (above) and this is the highest initial download then we're good
|
# 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:
|
elif any_qualities and bestResult.quality in any_qualities:
|
||||||
logger.log(u"Found a initial quality match to snatch [" + bestResult.name + "]", logger.DEBUG)
|
logger.log(u"Found a initial quality match to snatch [" + bestResult.name + "]", logger.DEBUG)
|
||||||
queueItem.results = [bestResult]
|
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
|
return queueItem
|
||||||
|
|
||||||
|
|
||||||
# make sure we search every provider for results
|
# make sure we search every provider for results
|
||||||
if providerNum < len(providers):
|
if providerNum != len(providers):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# remove duplicates and insures snatch of highest quality from results
|
# remove duplicates and insures snatch of highest quality from results
|
||||||
for i1, result1 in enumerate(finalResults):
|
for i1, result1 in enumerate(finalResults):
|
||||||
for i2, result2 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:
|
if result1.quality >= result2.quality:
|
||||||
finalResults.pop(i2)
|
finalResults.pop(i2)
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,6 @@ class SearchQueue(generic_queue.GenericQueue):
|
||||||
status = search.snatchEpisode(result)
|
status = search.snatchEpisode(result)
|
||||||
item.success = status
|
item.success = status
|
||||||
generic_queue.QueueItem.finish(item)
|
generic_queue.QueueItem.finish(item)
|
||||||
return status
|
|
||||||
|
|
||||||
class ManualSearchQueueItem(generic_queue.QueueItem):
|
class ManualSearchQueueItem(generic_queue.QueueItem):
|
||||||
def __init__(self, ep_obj):
|
def __init__(self, ep_obj):
|
||||||
|
@ -100,6 +99,7 @@ class ManualSearchQueueItem(generic_queue.QueueItem):
|
||||||
self.success = None
|
self.success = None
|
||||||
self.show = ep_obj.show
|
self.show = ep_obj.show
|
||||||
self.ep_obj = ep_obj
|
self.ep_obj = ep_obj
|
||||||
|
self.results = []
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
generic_queue.QueueItem.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)
|
searchResult = search.searchProviders(self, self.show, self.ep_obj.season, [self.ep_obj],False,True)
|
||||||
|
|
||||||
if searchResult:
|
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:
|
except Exception:
|
||||||
logger.log(traceback.format_exc(), logger.DEBUG)
|
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()
|
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):
|
class BacklogQueueItem(generic_queue.QueueItem):
|
||||||
def __init__(self, show, segment):
|
def __init__(self, show, segment):
|
||||||
generic_queue.QueueItem.__init__(self, 'Backlog', BACKLOG_SEARCH)
|
generic_queue.QueueItem.__init__(self, 'Backlog', BACKLOG_SEARCH)
|
||||||
|
@ -137,6 +130,7 @@ class BacklogQueueItem(generic_queue.QueueItem):
|
||||||
self.show = show
|
self.show = show
|
||||||
self.segment = segment
|
self.segment = segment
|
||||||
self.wantedEpisodes = []
|
self.wantedEpisodes = []
|
||||||
|
self.results = []
|
||||||
|
|
||||||
self._changeMissingEpisodes()
|
self._changeMissingEpisodes()
|
||||||
|
|
||||||
|
@ -174,21 +168,18 @@ class BacklogQueueItem(generic_queue.QueueItem):
|
||||||
if len(seasonEps) == len(self.wantedEpisodes):
|
if len(seasonEps) == len(self.wantedEpisodes):
|
||||||
seasonSearch = True
|
seasonSearch = True
|
||||||
|
|
||||||
providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive() and x]
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logger.log("Beginning backlog search for episodes from [" + self.show.name + "] - Season[" + str(self.segment) + "]")
|
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)
|
searchResult = search.searchProviders(self, self.show, self.segment, self.wantedEpisodes, seasonSearch, False)
|
||||||
|
|
||||||
if searchResult:
|
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:
|
except Exception:
|
||||||
logger.log(traceback.format_exc(), logger.DEBUG)
|
logger.log(traceback.format_exc(), logger.DEBUG)
|
||||||
|
|
||||||
if not self.success:
|
|
||||||
logger.log(u"No needed episodes found during backlog search")
|
|
||||||
|
|
||||||
self.finish()
|
self.finish()
|
||||||
|
|
||||||
def _need_any_episodes(self, statusResults, bestQualities):
|
def _need_any_episodes(self, statusResults, bestQualities):
|
||||||
|
@ -253,6 +244,7 @@ class FailedQueueItem(generic_queue.QueueItem):
|
||||||
self.show = show
|
self.show = show
|
||||||
self.episodes = episodes
|
self.episodes = episodes
|
||||||
self.success = None
|
self.success = None
|
||||||
|
self.results = []
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
generic_queue.QueueItem.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) + "]")
|
"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)
|
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:
|
except Exception, e:
|
||||||
logger.log(traceback.format_exc(), logger.DEBUG)
|
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()
|
self.finish()
|
Loading…
Reference in a new issue