Browse Source

Remove releases that aren't found in latest search

pull/1298/head
Ruud 12 years ago
parent
commit
a264c75f8c
  1. 14
      couchpotato/core/plugins/searcher/main.py

14
couchpotato/core/plugins/searcher/main.py

@ -130,6 +130,8 @@ class Searcher(Plugin):
available_status = fireEvent('status.get', 'available', single = True) available_status = fireEvent('status.get', 'available', single = True)
ignored_status = fireEvent('status.get', 'ignored', single = True) ignored_status = fireEvent('status.get', 'ignored', single = True)
found_releases = []
default_title = getTitle(movie['library']) default_title = getTitle(movie['library'])
if not default_title: if not default_title:
log.error('No proper info found for movie, removing it from library to cause it from having more issues.') log.error('No proper info found for movie, removing it from library to cause it from having more issues.')
@ -174,10 +176,13 @@ class Searcher(Plugin):
# Add them to this movie releases list # Add them to this movie releases list
for nzb in sorted_results: for nzb in sorted_results:
rls = db.query(Release).filter_by(identifier = md5(nzb['url'])).first() nzb_identifier = md5(nzb['url'])
found_releases.append(nzb_identifier)
rls = db.query(Release).filter_by(identifier = nzb_identifier).first()
if not rls: if not rls:
rls = Release( rls = Release(
identifier = md5(nzb['url']), identifier = nzb_identifier,
movie_id = movie.get('id'), movie_id = movie.get('id'),
quality_id = quality_type.get('quality_id'), quality_id = quality_type.get('quality_id'),
status_id = available_status.get('id') status_id = available_status.get('id')
@ -234,6 +239,11 @@ class Searcher(Plugin):
if self.shuttingDown() or ret: if self.shuttingDown() or ret:
break break
# Remove releases that aren't found anymore
for release in movie.get('releases', []):
if release.get('identifier') not in found_releases:
fireEvent('release.delete', release.get('id'), single = True)
fireEvent('notify.frontend', type = 'searcher.ended.%s' % movie['id'], data = True) fireEvent('notify.frontend', type = 'searcher.ended.%s' % movie['id'], data = True)
return ret return ret

Loading…
Cancel
Save