From a58088dc7c4f9d3a49ea521eeb0ba22505d79c72 Mon Sep 17 00:00:00 2001 From: Ruud Date: Mon, 30 Apr 2012 18:11:44 +0200 Subject: [PATCH] Update release information on re-search. fixes #181 --- couchpotato/core/plugins/searcher/main.py | 31 +++++++++++++---------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/couchpotato/core/plugins/searcher/main.py b/couchpotato/core/plugins/searcher/main.py index daf1aa70..663b3b65 100644 --- a/couchpotato/core/plugins/searcher/main.py +++ b/couchpotato/core/plugins/searcher/main.py @@ -65,6 +65,8 @@ class Searcher(Plugin): def single(self, movie): + db = get_session() + pre_releases = fireEvent('quality.pre_releases', single = True) release_dates = fireEvent('library.update_release_date', identifier = movie['library']['identifier'], merge = True) available_status = fireEvent('status.get', 'available', single = True) @@ -94,7 +96,6 @@ class Searcher(Plugin): # Add them to this movie releases list for nzb in sorted_results: - db = get_session() rls = db.query(Release).filter_by(identifier = md5(nzb['url'])).first() if not rls: @@ -106,20 +107,23 @@ class Searcher(Plugin): ) db.add(rls) db.commit() + else: + [db.delete(info) for info in rls.info] + db.commit() - for info in nzb: - try: - if not isinstance(nzb[info], (str, unicode, int, long)): - continue + for info in nzb: + try: + if not isinstance(nzb[info], (str, unicode, int, long)): + continue - rls_info = ReleaseInfo( - identifier = info, - value = toUnicode(nzb[info]) - ) - rls.info.append(rls_info) - db.commit() - except InterfaceError: - log.debug('Couldn\'t add %s to ReleaseInfo: %s' % (info, traceback.format_exc())) + rls_info = ReleaseInfo( + identifier = info, + value = toUnicode(nzb[info]) + ) + rls.info.append(rls_info) + db.commit() + except InterfaceError: + log.debug('Couldn\'t add %s to ReleaseInfo: %s' % (info, traceback.format_exc())) for nzb in sorted_results: @@ -137,6 +141,7 @@ class Searcher(Plugin): if self.shuttingDown(): break + db.remove() return False def download(self, data, movie, manual = False):