diff --git a/scripts/monboob b/scripts/monboob index 50d142bcb0a54007fc90e2fd9fddd345d614a222..da4ef50c3a682fc80a1fa3989ebd8bc910553659 100755 --- a/scripts/monboob +++ b/scripts/monboob @@ -106,9 +106,8 @@ class Monboob(ConsoleApplication): self.weboob.loop() def process(self): - for backend in self.weboob.iter_backends(): - for message in backend.iter_new_messages(): - self.send_email(backend, message) + for backend, message in self.weboob.do('iter_new_messages'): + self.send_email(backend, message) def send_email(self, backend, mail): domain = self.config.get('domain') diff --git a/weboob/frontends/videoob/application.py b/weboob/frontends/videoob/application.py index a08590616bbe15824c855223cf3b14cce4f2c9f5..9da770878eacccd6349b9972386ea22899e4b347 100644 --- a/weboob/frontends/videoob/application.py +++ b/weboob/frontends/videoob/application.py @@ -66,22 +66,17 @@ def command_search(self, pattern=None): else: results['BEFORE'] = u'Last videos' results['HEADER'] = ('ID', 'Title', 'Duration') - for backend in self.weboob.iter_backends(): + for backend, video in self.weboob.do('iter_search_results', pattern): + row = (video.id, video.title, '%d:%02d:%02d' % (video.duration/3600, (video.duration%3600/60), video.duration%60)) try: - iterator = backend.iter_search_results(pattern) - except NotImplementedError: - continue - else: - rows = [] - for video in iterator: - rows.append((video.id, video.title, '%d:%02d:%02d' % (video.duration/3600, (video.duration%3600/60), video.duration%60))) - results[backend.name] = rows + results[backend.name].append(row) + except KeyError: + results[backend.name] = [row] return results @ConsoleApplication.command('Get video file URL from page URL') def command_file_url(self, url): - for backend in self.weboob.iter_backends(): - video = backend.get_video(url) + for backend, video in self.weboob.do('get_video', url): if video: print video.url break diff --git a/weboob/tools/application/base.py b/weboob/tools/application/base.py index 843138bc2d4086e7884b590325c265d3edcca78b..ca89d58e00f072bdc26512a483ae966bd9477676 100644 --- a/weboob/tools/application/base.py +++ b/weboob/tools/application/base.py @@ -162,3 +162,4 @@ def run(klass, args=sys.argv): print 'Program killed by SIGINT' except ConfigError, e: print 'Configuration error: %s' % e + sys.exit(1)