mirror of https://github.com/yt-dlp/yt-dlp.git
[options] Strip spaces in list-like switches
This commit is contained in:
parent
a8cb7eca61
commit
d21bba7853
|
@ -116,19 +116,19 @@ def parseOpts(overrideArguments=None):
|
||||||
|
|
||||||
return ''.join(opts)
|
return ''.join(opts)
|
||||||
|
|
||||||
def _list_from_options_callback(option, opt_str, value, parser, append=True, delim=','):
|
def _list_from_options_callback(option, opt_str, value, parser, append=True, delim=',', process=str.strip):
|
||||||
# append can be True, False or -1 (prepend)
|
# append can be True, False or -1 (prepend)
|
||||||
current = getattr(parser.values, option.dest) if append else []
|
current = getattr(parser.values, option.dest) if append else []
|
||||||
value = [value] if delim is None else value.split(delim)
|
value = [process(value)] if delim is None else list(map(process, value.split(delim)))
|
||||||
setattr(
|
setattr(
|
||||||
parser.values, option.dest,
|
parser.values, option.dest,
|
||||||
current + value if append is True else value + current)
|
current + value if append is True else value + current)
|
||||||
|
|
||||||
def _set_from_options_callback(
|
def _set_from_options_callback(
|
||||||
option, opt_str, value, parser,
|
option, opt_str, value, parser, delim=',', allowed_values=None, aliases={},
|
||||||
delim=',', allowed_values=None, process=str.lower, aliases={}):
|
process=lambda x: x.lower().strip()):
|
||||||
current = getattr(parser.values, option.dest)
|
current = getattr(parser.values, option.dest)
|
||||||
values = [process(value)] if delim is None else process(value).split(delim)[::-1]
|
values = [process(value)] if delim is None else list(map(process, value.split(delim)[::-1]))
|
||||||
while values:
|
while values:
|
||||||
actual_val = val = values.pop()
|
actual_val = val = values.pop()
|
||||||
if val == 'all':
|
if val == 'all':
|
||||||
|
@ -275,8 +275,7 @@ def parseOpts(overrideArguments=None):
|
||||||
'multistreams', 'no-live-chat', 'playlist-index', 'list-formats', 'no-direct-merge',
|
'multistreams', 'no-live-chat', 'playlist-index', 'list-formats', 'no-direct-merge',
|
||||||
'no-youtube-channel-redirect', 'no-youtube-unavailable-videos', 'no-attach-info-json',
|
'no-youtube-channel-redirect', 'no-youtube-unavailable-videos', 'no-attach-info-json',
|
||||||
'embed-thumbnail-atomicparsley', 'seperate-video-versions', 'no-clean-infojson', 'no-keep-subs',
|
'embed-thumbnail-atomicparsley', 'seperate-video-versions', 'no-clean-infojson', 'no-keep-subs',
|
||||||
},
|
}, 'aliases': {
|
||||||
'aliases': {
|
|
||||||
'youtube-dl': ['-multistreams', 'all'],
|
'youtube-dl': ['-multistreams', 'all'],
|
||||||
'youtube-dlc': ['-no-youtube-channel-redirect', '-no-live-chat', 'all'],
|
'youtube-dlc': ['-no-youtube-channel-redirect', '-no-live-chat', 'all'],
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue