Created 'searcher.try_download_result' event from section in MovieSearcher.single
This commit is contained in:
@@ -25,6 +25,7 @@ class Searcher(SearcherBase):
|
|||||||
addEvent('searcher.correct_year', self.correctYear)
|
addEvent('searcher.correct_year', self.correctYear)
|
||||||
addEvent('searcher.correct_name', self.correctName)
|
addEvent('searcher.correct_name', self.correctName)
|
||||||
addEvent('searcher.correct_words', self.correctWords)
|
addEvent('searcher.correct_words', self.correctWords)
|
||||||
|
addEvent('searcher.try_download_result', self.tryDownloadResult)
|
||||||
addEvent('searcher.download', self.download)
|
addEvent('searcher.download', self.download)
|
||||||
addEvent('searcher.search', self.search)
|
addEvent('searcher.search', self.search)
|
||||||
addEvent('searcher.create_releases', self.createReleases)
|
addEvent('searcher.create_releases', self.createReleases)
|
||||||
@@ -53,6 +54,30 @@ class Searcher(SearcherBase):
|
|||||||
progress = fireEvent('searcher.progress', merge = True)
|
progress = fireEvent('searcher.progress', merge = True)
|
||||||
return progress
|
return progress
|
||||||
|
|
||||||
|
def tryDownloadResult(self, results, media, quality_type, manual = False):
|
||||||
|
available_status, ignored_status, failed_status = fireEvent('status.get', ['available', 'ignored', 'failed'], single = True)
|
||||||
|
|
||||||
|
for rel in results:
|
||||||
|
if not quality_type.get('finish', False) and quality_type.get('wait_for', 0) > 0 and rel.get('age') <= quality_type.get('wait_for', 0):
|
||||||
|
log.info('Ignored, waiting %s days: %s', (quality_type.get('wait_for'), rel['name']))
|
||||||
|
continue
|
||||||
|
|
||||||
|
if rel['status_id'] in [ignored_status.get('id'), failed_status.get('id')]:
|
||||||
|
log.info('Ignored: %s', rel['name'])
|
||||||
|
continue
|
||||||
|
|
||||||
|
if rel['score'] <= 0:
|
||||||
|
log.info('Ignored, score to low: %s', rel['name'])
|
||||||
|
continue
|
||||||
|
|
||||||
|
downloaded = fireEvent('searcher.download', data = rel, movie = media, manual = manual, single = True)
|
||||||
|
if downloaded is True:
|
||||||
|
return True
|
||||||
|
elif downloaded != 'try_next':
|
||||||
|
break
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def download(self, data, movie, manual = False):
|
def download(self, data, movie, manual = False):
|
||||||
|
|
||||||
if not data.get('protocol'):
|
if not data.get('protocol'):
|
||||||
|
|||||||
@@ -181,25 +181,9 @@ class MovieSearcher(SearcherBase, MovieTypeBase):
|
|||||||
# Add them to this movie releases list
|
# Add them to this movie releases list
|
||||||
found_releases += fireEvent('searcher.create_releases', results, movie, quality_type, single = True)
|
found_releases += fireEvent('searcher.create_releases', results, movie, quality_type, single = True)
|
||||||
|
|
||||||
for nzb in results:
|
# Try find a valid result and download it
|
||||||
if not quality_type.get('finish', False) and quality_type.get('wait_for', 0) > 0 and nzb.get('age') <= quality_type.get('wait_for', 0):
|
if fireEvent('searcher.try_download_result', results, movie, quality_type, manual, single = True):
|
||||||
log.info('Ignored, waiting %s days: %s', (quality_type.get('wait_for'), nzb['name']))
|
ret = True
|
||||||
continue
|
|
||||||
|
|
||||||
if nzb['status_id'] in [ignored_status.get('id'), failed_status.get('id')]:
|
|
||||||
log.info('Ignored: %s', nzb['name'])
|
|
||||||
continue
|
|
||||||
|
|
||||||
if nzb['score'] <= 0:
|
|
||||||
log.info('Ignored, score to low: %s', nzb['name'])
|
|
||||||
continue
|
|
||||||
|
|
||||||
downloaded = fireEvent('searcher.download', data = nzb, movie = movie, manual = manual, single = True)
|
|
||||||
if downloaded is True:
|
|
||||||
ret = True
|
|
||||||
break
|
|
||||||
elif downloaded != 'try_next':
|
|
||||||
break
|
|
||||||
|
|
||||||
# Remove releases that aren't found anymore
|
# Remove releases that aren't found anymore
|
||||||
for release in movie.get('releases', []):
|
for release in movie.get('releases', []):
|
||||||
|
|||||||
Reference in New Issue
Block a user