From d857f05a3ba4789a7d6bcaaeb3efa1f338a39514 Mon Sep 17 00:00:00 2001 From: Christophe Benz Date: Wed, 16 Jun 2010 22:13:16 +0200 Subject: [PATCH] handle ids and providers frontend-side using helper --- weboob/bcall.py | 1 - weboob/frontends/videoob/videoob.py | 37 ++++++++++++++++------------- weboob/tools/application/console.py | 7 ++++++ 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/weboob/bcall.py b/weboob/bcall.py index 2c209b8c..66b24f1b 100644 --- a/weboob/bcall.py +++ b/weboob/bcall.py @@ -78,7 +78,6 @@ class BackendsCall(object): def _store_result(self, backend, result): with self.mutex: - result.id = unicode(result.id) + '@' + backend.name self.responses.append((backend, result)) self.response_event.set() diff --git a/weboob/frontends/videoob/videoob.py b/weboob/frontends/videoob/videoob.py index 49856c50..589e3aab 100644 --- a/weboob/frontends/videoob/videoob.py +++ b/weboob/frontends/videoob/videoob.py @@ -1,22 +1,21 @@ # -*- coding: utf-8 -*- -""" -Copyright(C) 2010 Christophe Benz, Romain Bignon -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, version 3 of the License. +# Copyright(C) 2010 Christophe Benz, Romain Bignon +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -""" from weboob.capabilities.video import ICapVideo from weboob.tools.application import ConsoleApplication @@ -39,8 +38,11 @@ class Videoob(ConsoleApplication): return self.process_command(*argv[1:]) @ConsoleApplication.command('Get video information (accept ID or URL)') - def command_info(self, id): - for backend, video in self.weboob.do('get_video', id): + def command_info(self, _id): + _id, backend_name = self.split_id(_id) + 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) @@ -49,4 +51,5 @@ class Videoob(ConsoleApplication): def command_search(self, pattern=None): 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): + video.id = u'%s@%s' % (video.id, backend.name) self.format(video) diff --git a/weboob/tools/application/console.py b/weboob/tools/application/console.py index 653493f5..2275d030 100644 --- a/weboob/tools/application/console.py +++ b/weboob/tools/application/console.py @@ -222,3 +222,10 @@ class ConsoleApplication(BaseApplication): weboobcfg.command_modules(*caps) logging.error(u'You can configure a backends using the "weboobcfg add" command:\nweboobcfg add [options..]') sys.exit(0) + + def split_id(self, _id): + try: + _id, backend_name = _id.split('@') + except ValueError: + backend_name = None + return _id, backend_name