diff --git a/couchpotato/core/media/_base/media/main.py b/couchpotato/core/media/_base/media/main.py index d1f2914..5a6fc79 100644 --- a/couchpotato/core/media/_base/media/main.py +++ b/couchpotato/core/media/_base/media/main.py @@ -189,7 +189,7 @@ class MediaPlugin(MediaBase): # Filter on release status if release_status and len(release_status) > 0: filter_by['release_status'] = set() - for release_status in fireEvent('media.with_status', release_status, with_doc = False, single = True): + for release_status in fireEvent('release.with_status', release_status, with_doc = False, single = True): filter_by['release_status'].add(release_status.get('media_id')) # Add search filters @@ -302,7 +302,7 @@ class MediaPlugin(MediaBase): # Filter on release status if release_status and len(release_status) > 0: filter_by['release_status'] = set() - for release_status in fireEvent('media.with_status', release_status, with_doc = False, single = True): + for release_status in fireEvent('release.with_status', release_status, with_doc = False, single = True): filter_by['release_status'].add(release_status.get('media_id')) # Filter by combining ids diff --git a/couchpotato/core/plugins/release/index.py b/couchpotato/core/plugins/release/index.py index ee76253..23c1576 100644 --- a/couchpotato/core/plugins/release/index.py +++ b/couchpotato/core/plugins/release/index.py @@ -22,14 +22,6 @@ class ReleaseIndex(TreeBasedIndex): for release in db.get_many('release', media_id, with_doc = True): yield release['doc'] - def run_with_status(self, db, status = [], with_doc = True): - - status = list(status if isinstance(status, (list, tuple)) else [status]) - - for s in status: - for ms in db.get_many('release_status', s, with_doc = with_doc): - yield ms['doc'] if with_doc else ms - class ReleaseStatusIndex(TreeBasedIndex): _version = 1 diff --git a/couchpotato/core/plugins/release/main.py b/couchpotato/core/plugins/release/main.py index 5320908..3ebb93b 100644 --- a/couchpotato/core/plugins/release/main.py +++ b/couchpotato/core/plugins/release/main.py @@ -53,6 +53,7 @@ class Release(Plugin): addEvent('release.delete', self.delete) addEvent('release.clean', self.clean) addEvent('release.update_status', self.updateStatus) + addEvent('release.with_status', self.withStatus) # Clean releases that didn't have activity in the last week addEvent('app.load', self.cleanDone) @@ -422,3 +423,13 @@ class Release(Plugin): log.error('Failed: %s', traceback.format_exc()) return False + + def withStatus(self, status, with_doc = True): + + db = get_db() + + status = list(status if isinstance(status, (list, tuple)) else [status]) + + for s in status: + for ms in db.get_many('release_status', s, with_doc = with_doc): + yield ms['doc'] if with_doc else ms diff --git a/couchpotato/core/plugins/renamer.py b/couchpotato/core/plugins/renamer.py index 4cfc987..b452648 100644 --- a/couchpotato/core/plugins/renamer.py +++ b/couchpotato/core/plugins/renamer.py @@ -834,7 +834,7 @@ Remove it if you want it to be renamed (again, or at least let it try again) try: db = get_db() - rels = list(db.run('release', 'with_status', ['snatched', 'seeding', 'missing'])) + rels = list(fireEvent('release.with_status', ['snatched', 'seeding', 'missing'], single = True)) if not rels: #No releases found that need status checking