From 72cc3576d39decf370fa7408ab1cf5bce46fcf10 Mon Sep 17 00:00:00 2001 From: Ruud Date: Mon, 1 Apr 2013 22:51:34 +0200 Subject: [PATCH] Use @mano3m code to check download_info --- couchpotato/core/plugins/renamer/main.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/couchpotato/core/plugins/renamer/main.py b/couchpotato/core/plugins/renamer/main.py index e3291f6..a6260d7 100644 --- a/couchpotato/core/plugins/renamer/main.py +++ b/couchpotato/core/plugins/renamer/main.py @@ -118,13 +118,23 @@ class Renamer(Plugin): # Get the release with the downloader ID that was downloded by the downloader download_info = None - if download_id: - rls_info = db.query(ReleaseInfo).filter_by(identifier = 'download_id', value = download_id).first() + if download_id and downloader: + rls = None - if rls_info: + rlsnfo_dwnlds = db.query(ReleaseInfo).filter_by(identifier = 'download_downloader', value = downloader).all() + rlsnfo_ids = db.query(ReleaseInfo).filter_by(identifier = 'download_id', value = download_id).all() + + for rlsnfo_dwnld in rlsnfo_dwnlds: + for rlsnfo_id in rlsnfo_ids: + if rlsnfo_id.release == rlsnfo_dwnld.release: + rls = rlsnfo_id.release + break + if rls: break + + if rls: download_info = { - 'imdb_id': rls_info.release.movie.library.identifier, - 'quality': rls_info.release.quality.identifier, + 'imdb_id': rls.movie.library.identifier, + 'quality': rls.quality.identifier, } else: log.error('Download ID %s from downloader %s not found in releases', (download_id, downloader)) @@ -582,6 +592,7 @@ class Renamer(Plugin): loge('Couldn\'t remove empty directory %s: %s', (folder, traceback.format_exc())) def checkSnatched(self): + if self.checking_snatched: log.debug('Already checking snatched')