constrain backend search
This commit is contained in:
parent
a0f8137fc5
commit
9a8ffd971d
2 changed files with 6 additions and 6 deletions
|
|
@ -34,21 +34,21 @@ class Videoob(ConsoleApplication):
|
||||||
group.add_option('--nsfw', action='store_true', help='enable non-suitable for work videos')
|
group.add_option('--nsfw', action='store_true', help='enable non-suitable for work videos')
|
||||||
|
|
||||||
def main(self, argv):
|
def main(self, argv):
|
||||||
self.load_modules(ICapVideo)
|
|
||||||
return self.process_command(*argv[1:])
|
return self.process_command(*argv[1:])
|
||||||
|
|
||||||
@ConsoleApplication.command('Get video information (accept ID or URL)')
|
@ConsoleApplication.command('Get video information (accept ID or URL)')
|
||||||
def command_info(self, _id):
|
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):
|
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:
|
if video is None:
|
||||||
continue
|
continue
|
||||||
self.format(video, backend.name)
|
self.format(video, backend.name)
|
||||||
|
|
||||||
@ConsoleApplication.command('Search videos')
|
@ConsoleApplication.command('Search videos')
|
||||||
def command_search(self, pattern=None):
|
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')
|
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):
|
for backend, video in self.weboob.do('iter_search_results', pattern=pattern, nsfw=self.options.nsfw):
|
||||||
self.format(video, backend.name)
|
self.format(video, backend.name)
|
||||||
|
|
|
||||||
|
|
@ -223,9 +223,9 @@ class ConsoleApplication(BaseApplication):
|
||||||
logging.error(u'You can configure a backends using the "weboobcfg add" command:\nweboobcfg add <name> [options..]')
|
logging.error(u'You can configure a backends using the "weboobcfg add" command:\nweboobcfg add <name> [options..]')
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
def split_id(self, _id):
|
def parse_id(self, _id):
|
||||||
try:
|
try:
|
||||||
_id, backend_name = _id.split('@')
|
_id, backend_name = _id.rsplit('@', 1)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
backend_name = None
|
backend_name = None
|
||||||
return _id, backend_name
|
return _id, backend_name
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue