implement max_results option and infinite search for youtube
This commit is contained in:
parent
6ecf722f66
commit
53f6571fee
7 changed files with 82 additions and 31 deletions
|
|
@ -29,6 +29,7 @@ import sys
|
|||
|
||||
from weboob.core import CallErrors
|
||||
from weboob.core.backends import BackendsConfig
|
||||
from weboob.tools.backend import ObjectNotSupported
|
||||
|
||||
from .base import BackendNotFound, BaseApplication
|
||||
from .formatters.load import formatters, load_formatter
|
||||
|
|
@ -69,12 +70,14 @@ class ConsoleApplication(BaseApplication):
|
|||
|
||||
results_options = OptionGroup(self._parser, 'Results Options')
|
||||
results_options.add_option('-c', '--condition', help='filter result items to display given a boolean condition')
|
||||
results_options.add_option('-n', '--count', type='int', help='get a maximum number of results (all backends merged)')
|
||||
results_options.add_option('-n', '--count', default='10', type='int',
|
||||
help='get a maximum number of results (all backends merged)')
|
||||
results_options.add_option('-s', '--select', help='select result item keys to display (comma separated)')
|
||||
self._parser.add_option_group(results_options)
|
||||
|
||||
formatting_options = OptionGroup(self._parser, 'Formatting Options')
|
||||
formatting_options.add_option('-f', '--formatter', choices=formatters, help='select output formatter (%s)' % u','.join(formatters))
|
||||
formatting_options.add_option('-f', '--formatter', choices=formatters,
|
||||
help='select output formatter (%s)' % u','.join(formatters))
|
||||
formatting_options.add_option('--no-header', dest='no_header', action='store_true', help='do not display header')
|
||||
formatting_options.add_option('--no-keys', dest='no_keys', action='store_true', help='do not display item keys')
|
||||
self._parser.add_option_group(formatting_options)
|
||||
|
|
@ -106,6 +109,11 @@ class ConsoleApplication(BaseApplication):
|
|||
else:
|
||||
self.condition = None
|
||||
|
||||
if self.options.count == 0:
|
||||
self._parser.error('Count must be at least 1, or negative for infinite')
|
||||
elif self.options.count < 0:
|
||||
self.options.count = None
|
||||
|
||||
def _get_completions(self):
|
||||
return set(name for name, arguments, doc_string in self._commands)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue