From 7c502ca236a13f351f8abe6786458bc943f00ad7 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Tue, 27 Apr 2010 01:17:14 +0200 Subject: [PATCH] use Weboob.do insteal of deprecated iter_backends in some frontends --- scripts/monboob | 5 ++--- weboob/frontends/videoob/application.py | 17 ++++++----------- weboob/tools/application/base.py | 1 + 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/scripts/monboob b/scripts/monboob index 50d142bc..da4ef50c 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 a0859061..9da77087 100644 --- a/weboob/frontends/videoob/application.py +++ b/weboob/frontends/videoob/application.py @@ -66,22 +66,17 @@ class Videoob(ConsoleApplication): 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 843138bc..ca89d58e 100644 --- a/weboob/tools/application/base.py +++ b/weboob/tools/application/base.py @@ -162,3 +162,4 @@ class BaseApplication(object): print 'Program killed by SIGINT' except ConfigError, e: print 'Configuration error: %s' % e + sys.exit(1)