From 9a8ffd971da5829bfe435038147e7e6db908ff40 Mon Sep 17 00:00:00 2001 From: Christophe Benz Date: Thu, 17 Jun 2010 17:04:13 +0200 Subject: [PATCH] constrain backend search --- weboob/frontends/videoob/videoob.py | 8 ++++---- weboob/tools/application/console.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/weboob/frontends/videoob/videoob.py b/weboob/frontends/videoob/videoob.py index d4dac755..91f70e6a 100644 --- a/weboob/frontends/videoob/videoob.py +++ b/weboob/frontends/videoob/videoob.py @@ -34,21 +34,21 @@ class Videoob(ConsoleApplication): group.add_option('--nsfw', action='store_true', help='enable non-suitable for work videos') def main(self, argv): - self.load_modules(ICapVideo) return self.process_command(*argv[1:]) @ConsoleApplication.command('Get video information (accept ID or URL)') def command_info(self, _id): - _id, backend_name = self.split_id(_id) + _id, backend_name = self.parse_id(_id) + names = (backend_name,) if backend_name is not None else None + self.load_modules(ICapVideo, names=names) for backend, video in self.weboob.do('get_video', _id): - if backend_name is not None and backend_name != backend.name: - continue if video is None: continue self.format(video, backend.name) @ConsoleApplication.command('Search videos') def command_search(self, pattern=None): + self.load_modules(ICapVideo) print (u'Search pattern: %s' % pattern if pattern else u'Last videos').encode('utf-8') for backend, video in self.weboob.do('iter_search_results', pattern=pattern, nsfw=self.options.nsfw): self.format(video, backend.name) diff --git a/weboob/tools/application/console.py b/weboob/tools/application/console.py index 6d55aa09..f6877a7d 100644 --- a/weboob/tools/application/console.py +++ b/weboob/tools/application/console.py @@ -223,9 +223,9 @@ class ConsoleApplication(BaseApplication): logging.error(u'You can configure a backends using the "weboobcfg add" command:\nweboobcfg add [options..]') sys.exit(0) - def split_id(self, _id): + def parse_id(self, _id): try: - _id, backend_name = _id.split('@') + _id, backend_name = _id.rsplit('@', 1) except ValueError: backend_name = None return _id, backend_name