From c70489fddb55aabb6ae327df0dcb3445a0cd1ff0 Mon Sep 17 00:00:00 2001 From: Ruud Date: Tue, 31 Jan 2012 01:37:08 +0100 Subject: [PATCH] Speeding up search --- couchpotato/core/plugins/searcher/main.py | 14 +++++++------- couchpotato/core/providers/nzb/moovee/main.py | 2 ++ couchpotato/core/providers/nzb/newzbin/main.py | 2 ++ couchpotato/core/providers/nzb/newznab/main.py | 2 +- couchpotato/core/providers/nzb/nzbindex/main.py | 2 +- couchpotato/core/providers/nzb/nzbs/main.py | 2 +- couchpotato/core/providers/nzb/x264/main.py | 2 ++ 7 files changed, 16 insertions(+), 10 deletions(-) diff --git a/couchpotato/core/plugins/searcher/main.py b/couchpotato/core/plugins/searcher/main.py index 36a2f6c0..e928e847 100644 --- a/couchpotato/core/plugins/searcher/main.py +++ b/couchpotato/core/plugins/searcher/main.py @@ -52,21 +52,21 @@ class Searcher(Plugin): available_status = fireEvent('status.get', 'available', single = True) - for type in movie['profile']['types']: + default_title = movie['library']['titles'][0]['title'] + for quality_type in movie['profile']['types']: has_better_quality = 0 - default_title = movie['library']['titles'][0]['title'] # See if beter quality is available for release in movie['releases']: - if release['quality']['order'] <= type['quality']['order'] and release['status_id'] is not available_status.get('id'): + if release['quality']['order'] <= quality_type['quality']['order'] and release['status_id'] is not available_status.get('id'): has_better_quality += 1 # Don't search for quality lower then already available. if has_better_quality is 0: - log.info('Search for %s in %s' % (default_title, type['quality']['label'])) - quality = fireEvent('quality.single', identifier = type['quality']['identifier'], single = True) + log.info('Search for %s in %s' % (default_title, quality_type['quality']['label'])) + quality = fireEvent('quality.single', identifier = quality_type['quality']['identifier'], single = True) results = fireEvent('yarr.search', movie, quality, merge = True) sorted_results = sorted(results, key = lambda k: k['score'], reverse = True) @@ -79,7 +79,7 @@ class Searcher(Plugin): rls = Release( identifier = md5(nzb['url']), movie_id = movie.get('id'), - quality_id = type.get('quality_id'), + quality_id = quality_type.get('quality_id'), status_id = available_status.get('id') ) db.add(rls) @@ -103,7 +103,7 @@ class Searcher(Plugin): for nzb in sorted_results: return self.download(data = nzb, movie = movie) else: - log.info('Better quality (%s) already available or snatched for %s' % (type['quality']['label'], default_title)) + log.info('Better quality (%s) already available or snatched for %s' % (quality_type['quality']['label'], default_title)) fireEvent('movie.restatus', movie['id']) break diff --git a/couchpotato/core/providers/nzb/moovee/main.py b/couchpotato/core/providers/nzb/moovee/main.py index 7d9520ea..a6353bc9 100644 --- a/couchpotato/core/providers/nzb/moovee/main.py +++ b/couchpotato/core/providers/nzb/moovee/main.py @@ -18,6 +18,8 @@ class Moovee(NZBProvider): regex = '(?P.*?).+?(?P.*?)</td>.+?<td class="cell_statuschange">(?P<age>.*?)</td>' + http_time_between_calls = 2 # Seconds + def search(self, movie, quality): results = [] diff --git a/couchpotato/core/providers/nzb/newzbin/main.py b/couchpotato/core/providers/nzb/newzbin/main.py index afd5a80a..81672d2d 100644 --- a/couchpotato/core/providers/nzb/newzbin/main.py +++ b/couchpotato/core/providers/nzb/newzbin/main.py @@ -33,6 +33,8 @@ class Newzbin(NZBProvider, RSS): ] cat_backup_id = -1 + http_time_between_calls = 3 # Seconds + def search(self, movie, quality): results = [] diff --git a/couchpotato/core/providers/nzb/newznab/main.py b/couchpotato/core/providers/nzb/newznab/main.py index 29a8c5e2..9a7943e5 100644 --- a/couchpotato/core/providers/nzb/newznab/main.py +++ b/couchpotato/core/providers/nzb/newznab/main.py @@ -25,7 +25,7 @@ class Newznab(NZBProvider, RSS): ] cat_backup_id = 2000 - time_between_searches = 1 # Seconds + http_time_between_calls = 1 # Seconds def feed(self): diff --git a/couchpotato/core/providers/nzb/nzbindex/main.py b/couchpotato/core/providers/nzb/nzbindex/main.py index af2043e9..d3c0ed9c 100644 --- a/couchpotato/core/providers/nzb/nzbindex/main.py +++ b/couchpotato/core/providers/nzb/nzbindex/main.py @@ -18,7 +18,7 @@ class NzbIndex(NZBProvider, RSS): 'api': 'http://www.nzbindex.nl/rss/', #http://www.nzbindex.nl/rss/?q=due+date+720p&age=1000&sort=agedesc&minsize=3500&maxsize=10000 } - time_between_searches = 1 # Seconds + http_time_between_calls = 1 # Seconds def search(self, movie, quality): diff --git a/couchpotato/core/providers/nzb/nzbs/main.py b/couchpotato/core/providers/nzb/nzbs/main.py index 04d8cf14..a7e8fc66 100644 --- a/couchpotato/core/providers/nzb/nzbs/main.py +++ b/couchpotato/core/providers/nzb/nzbs/main.py @@ -27,7 +27,7 @@ class Nzbs(NZBProvider, RSS): ] cat_backup_id = 't2' - time_between_searches = 3 # Seconds + http_time_between_calls = 3 # Seconds def search(self, movie, quality): diff --git a/couchpotato/core/providers/nzb/x264/main.py b/couchpotato/core/providers/nzb/x264/main.py index a3daa375..0db9eabc 100644 --- a/couchpotato/core/providers/nzb/x264/main.py +++ b/couchpotato/core/providers/nzb/x264/main.py @@ -17,6 +17,8 @@ class X264(NZBProvider): regex = '<tr class="req_filled"><td class="reqid">(?P<id>.*?)</td><td class="release">(?P<title>.*?)</td>.+?<td class="age">(?P<age>.*?)</td>' + http_time_between_calls = 2 # Seconds + def search(self, movie, quality): results = []