]> jfr.im git - yt-dlp.git/blame - yt_dlp/options.py
[documentation] Fix typos
[yt-dlp.git] / yt_dlp / options.py
CommitLineData
2daabe49
PH
1from __future__ import unicode_literals
2
34a741a8
PH
3import os.path
4import optparse
3aa9a735 5import re
34a741a8
PH
6import sys
7
222516d9 8from .downloader.external import list_external_downloaders
8c25f81b 9from .compat import (
4644ac55 10 compat_expanduser,
003c69a8 11 compat_get_terminal_size,
4644ac55 12 compat_getenv,
c7b0add8 13 compat_kwargs,
cab792ab 14 compat_shlex_split,
8c25f81b
PH
15)
16from .utils import (
0202b52a 17 expand_path,
f74980cb 18 get_executable_path,
de6000d9 19 OUTTMPL_TYPES,
ff556f5c 20 preferredencoding,
df692c5a 21 REMUX_EXTENSIONS,
34a741a8
PH
22 write_string,
23)
24from .version import __version__
25
26
905d18a7
YCH
27def _hide_login_info(opts):
28 PRIVATE_OPTS = set(['-p', '--password', '-u', '--username', '--video-password', '--ap-password', '--ap-username'])
29 eqre = re.compile('^(?P<key>' + ('|'.join(re.escape(po) for po in PRIVATE_OPTS)) + ')=.+$')
30
31 def _scrub_eq(o):
32 m = eqre.match(o)
33 if m:
34 return m.group('key') + '=PRIVATE'
35 else:
36 return o
37
38 opts = list(map(_scrub_eq, opts))
39 for idx, opt in enumerate(opts):
40 if opt in PRIVATE_OPTS and idx + 1 < len(opts):
41 opts[idx + 1] = 'PRIVATE'
42 return opts
43
44
34a741a8
PH
45def parseOpts(overrideArguments=None):
46 def _readOptions(filename_bytes, default=[]):
47 try:
48 optionf = open(filename_bytes)
49 except IOError:
50 return default # silently skip if file is not present
51 try:
067aa17e 52 # FIXME: https://github.com/ytdl-org/youtube-dl/commit/dfe5fa49aed02cf36ba9f743b11b0903554b5e56
1251565e
S
53 contents = optionf.read()
54 if sys.version_info < (3,):
55 contents = contents.decode(preferredencoding())
56 res = compat_shlex_split(contents, comments=True)
34a741a8
PH
57 finally:
58 optionf.close()
59 return res
60
e2e43aea 61 def _readUserConf(package_name, default=[]):
62 # .config
63 xdg_config_home = compat_getenv('XDG_CONFIG_HOME') or compat_expanduser('~/.config')
64 userConfFile = os.path.join(xdg_config_home, package_name, 'config')
65 if not os.path.isfile(userConfFile):
66 userConfFile = os.path.join(xdg_config_home, '%s.conf' % package_name)
67 userConf = _readOptions(userConfFile, default=None)
68 if userConf is not None:
0202b52a 69 return userConf, userConfFile
34a741a8 70
e2e43aea 71 # appdata
72 appdata_dir = compat_getenv('appdata')
73 if appdata_dir:
74 userConfFile = os.path.join(appdata_dir, package_name, 'config')
75 userConf = _readOptions(userConfFile, default=None)
76 if userConf is None:
0202b52a 77 userConfFile += '.txt'
78 userConf = _readOptions(userConfFile, default=None)
e2e43aea 79 if userConf is not None:
0202b52a 80 return userConf, userConfFile
34a741a8 81
e2e43aea 82 # home
83 userConfFile = os.path.join(compat_expanduser('~'), '%s.conf' % package_name)
84 userConf = _readOptions(userConfFile, default=None)
34a741a8 85 if userConf is None:
0202b52a 86 userConfFile += '.txt'
87 userConf = _readOptions(userConfFile, default=None)
e2e43aea 88 if userConf is not None:
0202b52a 89 return userConf, userConfFile
34a741a8 90
0202b52a 91 return default, None
34a741a8
PH
92
93 def _format_option_string(option):
94 ''' ('-o', '--option') -> -o, --format METAVAR'''
95
96 opts = []
97
98 if option._short_opts:
99 opts.append(option._short_opts[0])
100 if option._long_opts:
101 opts.append(option._long_opts[0])
102 if len(opts) > 1:
103 opts.insert(1, ', ')
104
8450c15c
PH
105 if option.takes_value():
106 opts.append(' %s' % option.metavar)
34a741a8 107
611c1dd9 108 return ''.join(opts)
34a741a8 109
d818eb74 110 def _comma_separated_values_options_callback(option, opt_str, value, parser, prepend=True):
111 setattr(
112 parser.values, option.dest,
113 value.split(',') if not prepend
114 else value.split(',') + getattr(parser.values, option.dest))
34a741a8 115
45016689 116 def _dict_from_multiple_values_options_callback(
d818eb74 117 option, opt_str, value, parser,
118 allowed_keys=r'[\w-]+', delimiter=':', default_key=None, process=None, multiple_keys=True):
45016689 119
120 out_dict = getattr(parser.values, option.dest)
d818eb74 121 if multiple_keys:
122 allowed_keys = r'(%s)(,(%s))*' % (allowed_keys, allowed_keys)
123 mobj = re.match(r'(?i)(?P<keys>%s)%s(?P<val>.*)$' % (allowed_keys, delimiter), value)
45016689 124 if mobj is not None:
d818eb74 125 keys = [k.strip() for k in mobj.group('keys').lower().split(',')]
126 val = mobj.group('val')
45016689 127 elif default_key is not None:
d818eb74 128 keys, val = [default_key], value
45016689 129 else:
130 raise optparse.OptionValueError(
131 'wrong %s formatting; it should be %s, not "%s"' % (opt_str, option.metavar, value))
d818eb74 132 val = process(val) if callable(process) else val
133 for key in keys:
134 out_dict[key] = val
45016689 135
34a741a8 136 # No need to wrap help messages if we're on a wide console
003c69a8 137 columns = compat_get_terminal_size().columns
8450c15c
PH
138 max_width = columns if columns else 80
139 max_help_position = 80
34a741a8
PH
140
141 fmt = optparse.IndentedHelpFormatter(width=max_width, max_help_position=max_help_position)
142 fmt.format_option_strings = _format_option_string
143
144 kw = {
8450c15c
PH
145 'version': __version__,
146 'formatter': fmt,
a42419da 147 'usage': '%prog [OPTIONS] URL [URL...]',
8450c15c 148 'conflict_handler': 'resolve',
34a741a8
PH
149 }
150
c7b0add8 151 parser = optparse.OptionParser(**compat_kwargs(kw))
34a741a8 152
8450c15c
PH
153 general = optparse.OptionGroup(parser, 'General Options')
154 general.add_option(
155 '-h', '--help',
156 action='help',
17941321 157 help='Print this help text and exit')
8450c15c 158 general.add_option(
b76f0e58 159 '--version',
8450c15c 160 action='version',
17941321 161 help='Print program version and exit')
8450c15c
PH
162 general.add_option(
163 '-U', '--update',
164 action='store_true', dest='update_self',
8d801631 165 help='Update this program to latest version. Make sure that you have sufficient permissions (run with sudo if needed)')
8450c15c 166 general.add_option(
6623ac34 167 '-i', '--ignore-errors', '--no-abort-on-error',
91ebc640 168 action='store_true', dest='ignoreerrors', default=True,
8a51f564 169 help='Continue on download errors, for example to skip unavailable videos in a playlist (default) (Alias: --no-abort-on-error)')
8450c15c 170 general.add_option(
6623ac34 171 '--abort-on-error', '--no-ignore-errors',
8450c15c 172 action='store_false', dest='ignoreerrors',
8a51f564 173 help='Abort downloading of further videos if an error occurs (Alias: --no-ignore-errors)')
8450c15c
PH
174 general.add_option(
175 '--dump-user-agent',
176 action='store_true', dest='dump_user_agent', default=False,
17941321 177 help='Display the current browser identification')
34a741a8 178 general.add_option(
8450c15c
PH
179 '--list-extractors',
180 action='store_true', dest='list_extractors', default=False,
9836cfb8 181 help='List all supported extractors')
8450c15c
PH
182 general.add_option(
183 '--extractor-descriptions',
184 action='store_true', dest='list_extractor_descriptions', default=False,
185 help='Output descriptions of all supported extractors')
d22dec74
S
186 general.add_option(
187 '--force-generic-extractor',
188 action='store_true', dest='force_generic_extractor', default=False,
189 help='Force extraction to use the generic extractor')
34a741a8
PH
190 general.add_option(
191 '--default-search',
192 dest='default_search', metavar='PREFIX',
8a51f564 193 help='Use this prefix for unqualified URLs. For example "gvsearch2:" downloads two videos from google videos for youtube-dl "large apple". Use the value "auto" to let youtube-dl guess ("auto_warning" to emit a warning when guessing). "error" just throws an error. The default value "fixup_error" repairs broken URLs, but emits an error if this is not possible instead of searching')
34a741a8 194 general.add_option(
6623ac34 195 '--ignore-config', '--no-config',
34a741a8 196 action='store_true',
6623ac34 197 help=(
298f597b 198 'Disable loading any configuration files except the one provided by --config-location. '
199 'When given inside a configuration file, no further configuration files are loaded. '
200 'Additionally, (for backward compatibility) if this option is found inside the '
8a51f564 201 'system configuration file, the user configuration is not loaded'))
e66dca5e 202 general.add_option(
b6ee45e9
S
203 '--config-location',
204 dest='config_location', metavar='PATH',
0202b52a 205 help='Location of the main configuration file; either the path to the config or its containing directory')
057a5206
PH
206 general.add_option(
207 '--flat-playlist',
6623ac34 208 action='store_const', dest='extract_flat', const='in_playlist', default=False,
8a51f564 209 help='Do not extract the videos of a playlist, only list them')
6623ac34 210 general.add_option(
211 '--flat-videos',
212 action='store_true', dest='extract_flat',
a40258a2 213 # help='Do not resolve the video urls')
214 # doesn't work
215 help=optparse.SUPPRESS_HELP)
6623ac34 216 general.add_option(
217 '--no-flat-playlist',
218 action='store_false', dest='extract_flat',
219 help='Extract the videos of a playlist')
d77ab8e2
S
220 general.add_option(
221 '--mark-watched',
222 action='store_true', dest='mark_watched', default=False,
223 help='Mark videos watched (YouTube only)')
90f794c6
S
224 general.add_option(
225 '--no-mark-watched',
597c1866 226 action='store_false', dest='mark_watched',
227 help='Do not mark videos watched (default)')
7e5db8c9 228 general.add_option(
8a51f564 229 '--no-colors',
597c1866 230 action='store_true', dest='no_color', default=False,
17941321 231 help='Do not emit color codes in output')
34a741a8 232
be4a824d
PH
233 network = optparse.OptionGroup(parser, 'Network Options')
234 network.add_option(
235 '--proxy', dest='proxy',
236 default=None, metavar='URL',
6623ac34 237 help=(
238 'Use the specified HTTP/HTTPS/SOCKS proxy. To enable '
239 'SOCKS proxy, specify a proper scheme. For example '
240 'socks5://127.0.0.1:1080/. Pass in an empty string (--proxy "") '
241 'for direct connection'))
be4a824d
PH
242 network.add_option(
243 '--socket-timeout',
244 dest='socket_timeout', type=float, default=None, metavar='SECONDS',
245 help='Time to wait before giving up, in seconds')
246 network.add_option(
247 '--source-address',
248 metavar='IP', dest='source_address', default=None,
24ee6b97 249 help='Client-side IP address to bind to',
be4a824d 250 )
500b8b41
PH
251 network.add_option(
252 '-4', '--force-ipv4',
253 action='store_const', const='0.0.0.0', dest='source_address',
24ee6b97 254 help='Make all connections via IPv4',
500b8b41
PH
255 )
256 network.add_option(
257 '-6', '--force-ipv6',
258 action='store_const', const='::', dest='source_address',
24ee6b97 259 help='Make all connections via IPv6',
500b8b41 260 )
0aa10994 261
b31fdeed 262 geo = optparse.OptionGroup(parser, 'Geo-restriction')
0aa10994 263 geo.add_option(
38cce791
YCH
264 '--geo-verification-proxy',
265 dest='geo_verification_proxy', default=None, metavar='URL',
6623ac34 266 help=(
267 'Use this proxy to verify the IP address for some geo-restricted sites. '
8a51f564 268 'The default proxy specified by --proxy (or none, if the option is not present) is used for the actual downloading'))
0aa10994 269 geo.add_option(
91410c9b
PH
270 '--cn-verification-proxy',
271 dest='cn_verification_proxy', default=None, metavar='URL',
0aa10994
S
272 help=optparse.SUPPRESS_HELP)
273 geo.add_option(
274 '--geo-bypass',
275 action='store_true', dest='geo_bypass', default=True,
504f20dd 276 help='Bypass geographic restriction via faking X-Forwarded-For HTTP header')
0aa10994
S
277 geo.add_option(
278 '--no-geo-bypass',
279 action='store_false', dest='geo_bypass', default=True,
504f20dd 280 help='Do not bypass geographic restriction via faking X-Forwarded-For HTTP header')
0aa10994
S
281 geo.add_option(
282 '--geo-bypass-country', metavar='CODE',
283 dest='geo_bypass_country', default=None,
504f20dd 284 help='Force bypass geographic restriction with explicitly provided two-letter ISO 3166-2 country code')
5f95927a
S
285 geo.add_option(
286 '--geo-bypass-ip-block', metavar='IP_BLOCK',
287 dest='geo_bypass_ip_block', default=None,
504f20dd 288 help='Force bypass geographic restriction with explicitly provided IP block in CIDR notation')
be4a824d 289
8450c15c 290 selection = optparse.OptionGroup(parser, 'Video Selection')
34a741a8
PH
291 selection.add_option(
292 '--playlist-start',
293 dest='playliststart', metavar='NUMBER', default=1, type=int,
17941321 294 help='Playlist video to start at (default is %default)')
34a741a8
PH
295 selection.add_option(
296 '--playlist-end',
297 dest='playlistend', metavar='NUMBER', default=None, type=int,
17941321 298 help='Playlist video to end at (default is last)')
c14e88f0
PH
299 selection.add_option(
300 '--playlist-items',
301 dest='playlist_items', metavar='ITEM_SPEC', default=None,
8a51f564 302 help='Playlist video items to download. Specify indices of the videos in the playlist separated by commas like: "--playlist-items 1,2,5,8" if you want to download videos indexed 1, 2, 5, 8 in the playlist. You can specify range: "--playlist-items 1-3,7,10-13", it will download the videos at index 1, 2, 3, 7, 10, 11, 12 and 13')
34a741a8 303 selection.add_option(
8450c15c
PH
304 '--match-title',
305 dest='matchtitle', metavar='REGEX',
17941321 306 help='Download only matching titles (regex or caseless sub-string)')
8450c15c
PH
307 selection.add_option(
308 '--reject-title',
309 dest='rejecttitle', metavar='REGEX',
17941321 310 help='Skip download for matching titles (regex or caseless sub-string)')
8450c15c
PH
311 selection.add_option(
312 '--max-downloads',
313 dest='max_downloads', metavar='NUMBER', type=int, default=None,
314 help='Abort after downloading NUMBER files')
315 selection.add_option(
316 '--min-filesize',
317 metavar='SIZE', dest='min_filesize', default=None,
318 help='Do not download any videos smaller than SIZE (e.g. 50k or 44.6m)')
319 selection.add_option(
320 '--max-filesize',
321 metavar='SIZE', dest='max_filesize', default=None,
322 help='Do not download any videos larger than SIZE (e.g. 50k or 44.6m)')
323 selection.add_option(
324 '--date',
325 metavar='DATE', dest='date', default=None,
c76eb41b 326 help=(
8a51f564 327 'Download only videos uploaded in this date. '
328 'The date can be "YYYYMMDD" or in the format '
c76eb41b 329 '"(now|today)[+-][0-9](day|week|month|year)(s)?"'))
8450c15c
PH
330 selection.add_option(
331 '--datebefore',
332 metavar='DATE', dest='datebefore', default=None,
c76eb41b 333 help=(
334 'Download only videos uploaded on or before this date. '
335 'The date formats accepted is the same as --date'))
34a741a8 336 selection.add_option(
8450c15c
PH
337 '--dateafter',
338 metavar='DATE', dest='dateafter', default=None,
c76eb41b 339 help=(
340 'Download only videos uploaded on or after this date. '
341 'The date formats accepted is the same as --date'))
34a741a8 342 selection.add_option(
8450c15c
PH
343 '--min-views',
344 metavar='COUNT', dest='min_views', default=None, type=int,
17941321 345 help='Do not download any videos with less than COUNT views')
34a741a8 346 selection.add_option(
8450c15c
PH
347 '--max-views',
348 metavar='COUNT', dest='max_views', default=None, type=int,
349 help='Do not download any videos with more than COUNT views')
347de493
PH
350 selection.add_option(
351 '--match-filter',
352 metavar='FILTER', dest='match_filter', default=None,
353 help=(
24ee6b97 354 'Generic video filter. '
8a51f564 355 'Specify any key (see "OUTPUT TEMPLATE" for a list of available keys) to '
2c1f442c
S
356 'match if the key is present, '
357 '!key to check if the key is not present, '
277d6ff5 358 'key>NUMBER (like "view_count > 12", also works with '
ac33accd
S
359 '>=, <, <=, !=, =) to compare against a number, '
360 'key = \'LITERAL\' (like "uploader = \'Mike Smith\'", also works with !=) '
361 'to match against a string literal '
362 'and & to require multiple matches. '
2c1f442c
S
363 'Values which are not known are excluded unless you '
364 'put a question mark (?) after the operator. '
347de493
PH
365 'For example, to only match videos that have been liked more than '
366 '100 times and disliked less than 50 times (or the dislike '
367 'functionality is not available at the given service), but who '
5495937f 368 'also have a description, use --match-filter '
8a51f564 369 '"like_count > 100 & dislike_count <? 50 & description"'))
6623ac34 370 selection.add_option(
371 '--no-match-filter',
372 metavar='FILTER', dest='match_filter', action='store_const', const=None,
373 help='Do not use generic video filter (default)')
34a741a8 374 selection.add_option(
8450c15c
PH
375 '--no-playlist',
376 action='store_true', dest='noplaylist', default=False,
8a51f564 377 help='Download only the video, if the URL refers to a video and a playlist')
df4bd0d5
PH
378 selection.add_option(
379 '--yes-playlist',
f0884c8b 380 action='store_false', dest='noplaylist',
8a51f564 381 help='Download the playlist, if the URL refers to a video and a playlist')
8450c15c
PH
382 selection.add_option(
383 '--age-limit',
384 metavar='YEARS', dest='age_limit', default=None, type=int,
17941321 385 help='Download only videos suitable for the given age')
8450c15c
PH
386 selection.add_option(
387 '--download-archive', metavar='FILE',
388 dest='download_archive',
8a51f564 389 help='Download only videos not listed in the archive file. Record the IDs of all downloaded videos in it')
ea6e0c2b 390 selection.add_option(
391 '--break-on-existing',
392 action='store_true', dest='break_on_existing', default=False,
8a51f564 393 help='Stop the download process when encountering a file that is in the archive')
8b0d7497 394 selection.add_option(
395 '--break-on-reject',
396 action='store_true', dest='break_on_reject', default=False,
8a51f564 397 help='Stop the download process when encountering a file that has been filtered out')
26e2805c 398 selection.add_option(
399 '--skip-playlist-after-errors', metavar='N',
400 dest='skip_playlist_after_errors', default=None, type=int,
401 help='Number of allowed failures until the rest of the playlist is skipped')
6623ac34 402 selection.add_option(
403 '--no-download-archive',
404 dest='download_archive', action="store_const", const=None,
405 help='Do not use archive file (default)')
8450c15c
PH
406 selection.add_option(
407 '--include-ads',
408 dest='include_ads', action='store_true',
d9aa2332 409 help=optparse.SUPPRESS_HELP)
6623ac34 410 selection.add_option(
411 '--no-include-ads',
412 dest='include_ads', action='store_false',
d9aa2332 413 help=optparse.SUPPRESS_HELP)
34a741a8 414
8450c15c
PH
415 authentication = optparse.OptionGroup(parser, 'Authentication Options')
416 authentication.add_option(
417 '-u', '--username',
418 dest='username', metavar='USERNAME',
17941321 419 help='Login with this account ID')
8450c15c
PH
420 authentication.add_option(
421 '-p', '--password',
422 dest='password', metavar='PASSWORD',
7a5c1cfe 423 help='Account password. If this option is left out, yt-dlp will ask interactively')
8450c15c
PH
424 authentication.add_option(
425 '-2', '--twofactor',
426 dest='twofactor', metavar='TWOFACTOR',
3540fe26 427 help='Two-factor authentication code')
8450c15c
PH
428 authentication.add_option(
429 '-n', '--netrc',
430 action='store_true', dest='usenetrc', default=False,
17941321 431 help='Use .netrc authentication data')
8450c15c
PH
432 authentication.add_option(
433 '--video-password',
434 dest='videopassword', metavar='PASSWORD',
29f7c58a 435 help='Video password (vimeo, youku)')
b31fdeed 436 authentication.add_option(
797c636b
RA
437 '--ap-mso',
438 dest='ap_mso', metavar='MSO',
537f7533 439 help='Adobe Pass multiple-system operator (TV provider) identifier, use --ap-list-mso for a list of available MSOs')
b31fdeed 440 authentication.add_option(
1b6712ab 441 '--ap-username',
797c636b 442 dest='ap_username', metavar='USERNAME',
537f7533 443 help='Multiple-system operator account login')
b31fdeed 444 authentication.add_option(
1b6712ab 445 '--ap-password',
797c636b 446 dest='ap_password', metavar='PASSWORD',
7a5c1cfe 447 help='Multiple-system operator account password. If this option is left out, yt-dlp will ask interactively')
b31fdeed 448 authentication.add_option(
87148bb7
RA
449 '--ap-list-mso',
450 action='store_true', dest='ap_list_mso', default=False,
537f7533 451 help='List all supported multiple-system operators')
8450c15c
PH
452
453 video_format = optparse.OptionGroup(parser, 'Video Format Options')
454 video_format.add_option(
455 '-f', '--format',
456 action='store', dest='format', metavar='FORMAT', default=None,
eb8a4433 457 help='Video format code, see "FORMAT SELECTION" for more details')
458 video_format.add_option(
c76eb41b 459 '-S', '--format-sort', metavar='SORTORDER',
eb8a4433 460 dest='format_sort', default=[],
461 action='callback', callback=_comma_separated_values_options_callback, type='str',
462 help='Sort the formats by the fields given, see "Sorting Formats" for more details')
463 video_format.add_option(
464 '--format-sort-force', '--S-force',
465 action='store_true', dest='format_sort_force', metavar='FORMAT', default=False,
466 help=(
467 'Force user specified sort order to have precedence over all fields, '
468 'see "Sorting Formats" for more details'))
469 video_format.add_option(
470 '--no-format-sort-force',
471 action='store_false', dest='format_sort_force', metavar='FORMAT', default=False,
472 help=(
473 'Some fields have precedence over the user specified sort order (default), '
474 'see "Sorting Formats" for more details'))
909d24dd 475 video_format.add_option(
476 '--video-multistreams',
91ebc640 477 action='store_true', dest='allow_multiple_video_streams', default=False,
478 help='Allow multiple video streams to be merged into a single file')
909d24dd 479 video_format.add_option(
480 '--no-video-multistreams',
481 action='store_false', dest='allow_multiple_video_streams',
91ebc640 482 help='Only one video stream is downloaded for each output file (default)')
909d24dd 483 video_format.add_option(
484 '--audio-multistreams',
91ebc640 485 action='store_true', dest='allow_multiple_audio_streams', default=False,
486 help='Allow multiple audio streams to be merged into a single file')
909d24dd 487 video_format.add_option(
488 '--no-audio-multistreams',
489 action='store_false', dest='allow_multiple_audio_streams',
91ebc640 490 help='Only one audio stream is downloaded for each output file (default)')
8450c15c
PH
491 video_format.add_option(
492 '--all-formats',
493 action='store_const', dest='format', const='all',
d9aa2332 494 help=optparse.SUPPRESS_HELP)
8450c15c
PH
495 video_format.add_option(
496 '--prefer-free-formats',
497 action='store_true', dest='prefer_free_formats', default=False,
da9be05e 498 help=(
499 'Prefer video formats with free containers over non-free ones of same quality. '
500 'Use with "-S ext" to strictly prefer free containers irrespective of quality'))
501 video_format.add_option(
502 '--no-prefer-free-formats',
503 action='store_true', dest='prefer_free_formats', default=False,
504 help="Don't give any special preference to free containers (default)")
8450c15c
PH
505 video_format.add_option(
506 '-F', '--list-formats',
507 action='store_true', dest='listformats',
4b3fbafd 508 help='List all available formats of requested videos')
76d321f6 509 video_format.add_option(
510 '--list-formats-as-table',
91ebc640 511 action='store_true', dest='listformats_table', default=True,
8a51f564 512 help='Present the output of -F in tabular form (default)')
76d321f6 513 video_format.add_option(
6623ac34 514 '--list-formats-old', '--no-list-formats-as-table',
76d321f6 515 action='store_false', dest='listformats_table',
8a51f564 516 help='Present the output of -F in the old form (Alias: --no-list-formats-as-table)')
d120e901 517 video_format.add_option(
bd1a281e
PH
518 '--merge-output-format',
519 action='store', dest='merge_output_format', metavar='FORMAT', default=None,
d120e901 520 help=(
00334d0d
S
521 'If a merge is required (e.g. bestvideo+bestaudio), '
522 'output to given container format. One of mkv, mp4, ogg, webm, flv. '
d120e901 523 'Ignored if no merge is required'))
63ad4d43 524 video_format.add_option(
525 '--allow-unplayable-formats',
526 action='store_true', dest='allow_unplayable_formats', default=False,
527 help=(
528 'Allow unplayable formats to be listed and downloaded. '
e58c22a0 529 'All video post-processing will also be turned off'))
63ad4d43 530 video_format.add_option(
531 '--no-allow-unplayable-formats',
532 action='store_false', dest='allow_unplayable_formats',
533 help='Do not allow unplayable formats to be listed or downloaded (default)')
8450c15c
PH
534
535 subtitles = optparse.OptionGroup(parser, 'Subtitle Options')
536 subtitles.add_option(
6623ac34 537 '--write-subs', '--write-srt',
8450c15c 538 action='store_true', dest='writesubtitles', default=False,
17941321 539 help='Write subtitle file')
8450c15c 540 subtitles.add_option(
6623ac34 541 '--no-write-subs', '--no-write-srt',
542 action='store_false', dest='writesubtitles',
543 help='Do not write subtitle file (default)')
544 subtitles.add_option(
545 '--write-auto-subs', '--write-automatic-subs',
8450c15c 546 action='store_true', dest='writeautomaticsub', default=False,
e167860c 547 help='Write automatically generated subtitle file (Alias: --write-automatic-subs)')
6623ac34 548 subtitles.add_option(
549 '--no-write-auto-subs', '--no-write-automatic-subs',
550 action='store_false', dest='writeautomaticsub', default=False,
e167860c 551 help='Do not write auto-generated subtitles (default) (Alias: --no-write-automatic-subs)')
8450c15c
PH
552 subtitles.add_option(
553 '--all-subs',
554 action='store_true', dest='allsubtitles', default=False,
c32b0aab 555 help=optparse.SUPPRESS_HELP)
8450c15c
PH
556 subtitles.add_option(
557 '--list-subs',
558 action='store_true', dest='listsubtitles', default=False,
17941321 559 help='List all available subtitles for the video')
8450c15c
PH
560 subtitles.add_option(
561 '--sub-format',
a504ced0 562 action='store', dest='subtitlesformat', metavar='FORMAT', default='best',
4a3cdf81 563 help='Subtitle format, accepts formats preference, for example: "srt" or "ass/srt/best"')
8450c15c 564 subtitles.add_option(
e167860c 565 '--sub-langs', '--srt-langs',
8450c15c
PH
566 action='callback', dest='subtitleslangs', metavar='LANGS', type='str',
567 default=[], callback=_comma_separated_values_options_callback,
c32b0aab 568 help=(
569 'Languages of the subtitles to download (can be regex) or "all" separated by commas. (Eg: --sub-langs en.*,ja) '
570 'You can prefix the language code with a "-" to exempt it from the requested languages. (Eg: --sub-langs all,-live_chat) '
571 'Use --list-subs for a list of available language tags'))
8450c15c
PH
572
573 downloader = optparse.OptionGroup(parser, 'Download Options')
4cf1e5d2 574 downloader.add_option(
575 '-N', '--concurrent-fragments',
576 dest='concurrent_fragment_downloads', metavar='N', default=1, type=int,
b31fdeed 577 help='Number of fragments of a dash/hlsnative video that should be download concurrently (default is %default)')
8450c15c 578 downloader.add_option(
8ec2b2c4
S
579 '-r', '--limit-rate', '--rate-limit',
580 dest='ratelimit', metavar='RATE',
17941321 581 help='Maximum download rate in bytes per second (e.g. 50K or 4.2M)')
8450c15c
PH
582 downloader.add_option(
583 '-R', '--retries',
584 dest='retries', metavar='RETRIES', default=10,
8a51f564 585 help='Number of retries (default is %default), or "infinite"')
52bb437e
S
586 downloader.add_option(
587 '--fragment-retries',
588 dest='fragment_retries', metavar='RETRIES', default=10,
12ee65ea 589 help='Number of retries for a fragment (default is %default), or "infinite" (DASH, hlsnative and ISM)')
9603b660 590 downloader.add_option(
c76eb41b 591 '--skip-unavailable-fragments', '--no-abort-on-unavailable-fragment',
9603b660 592 action='store_true', dest='skip_unavailable_fragments', default=True,
8a51f564 593 help='Skip unavailable fragments for DASH, hlsnative and ISM (default) (Alias: --no-abort-on-unavailable-fragment)')
732fb3f8 594 downloader.add_option(
6623ac34 595 '--abort-on-unavailable-fragment', '--no-skip-unavailable-fragments',
9603b660 596 action='store_false', dest='skip_unavailable_fragments',
8a51f564 597 help='Abort downloading if a fragment is unavailable (Alias: --no-skip-unavailable-fragments)')
0eee52f3
S
598 downloader.add_option(
599 '--keep-fragments',
600 action='store_true', dest='keep_fragments', default=False,
6623ac34 601 help='Keep downloaded fragments on disk after downloading is finished')
602 downloader.add_option(
603 '--no-keep-fragments',
604 action='store_false', dest='keep_fragments',
605 help='Delete downloaded fragments after downloading is finished (default)')
8450c15c
PH
606 downloader.add_option(
607 '--buffer-size',
608 dest='buffersize', metavar='SIZE', default='1024',
17941321 609 help='Size of download buffer (e.g. 1024 or 16K) (default is %default)')
6623ac34 610 downloader.add_option(
611 '--resize-buffer',
612 action='store_false', dest='noresizebuffer',
613 help='The buffer size is automatically resized from an initial value of --buffer-size (default)')
8450c15c
PH
614 downloader.add_option(
615 '--no-resize-buffer',
616 action='store_true', dest='noresizebuffer', default=False,
6623ac34 617 help='Do not automatically adjust the buffer size')
ba515388
S
618 downloader.add_option(
619 '--http-chunk-size',
620 dest='http_chunk_size', metavar='SIZE', default=None,
6623ac34 621 help=(
622 'Size of a chunk for chunk-based HTTP downloading (e.g. 10485760 or 10M) (default is disabled). '
623 'May be useful for bypassing bandwidth throttling imposed by a webserver (experimental)'))
8450c15c
PH
624 downloader.add_option(
625 '--test',
626 action='store_true', dest='test', default=False,
627 help=optparse.SUPPRESS_HELP)
ff815fe6
MS
628 downloader.add_option(
629 '--playlist-reverse',
630 action='store_true',
631 help='Download playlist videos in reverse order')
6623ac34 632 downloader.add_option(
633 '--no-playlist-reverse',
c76eb41b 634 action='store_false', dest='playlist_reverse',
6623ac34 635 help='Download playlist videos in default order (default)')
75822ca7
TC
636 downloader.add_option(
637 '--playlist-random',
638 action='store_true',
639 help='Download playlist videos in random order')
881e6a1f
PH
640 downloader.add_option(
641 '--xattr-set-filesize',
642 dest='xattr_set_filesize', action='store_true',
504f20dd 643 help='Set file xattribute ytdl.filesize with expected file size')
85729c51
PH
644 downloader.add_option(
645 '--hls-prefer-native',
bf09af3a 646 dest='hls_prefer_native', action='store_true', default=None,
52a8a1e1 647 help=optparse.SUPPRESS_HELP)
bf09af3a
S
648 downloader.add_option(
649 '--hls-prefer-ffmpeg',
650 dest='hls_prefer_native', action='store_false', default=None,
52a8a1e1 651 help=optparse.SUPPRESS_HELP)
7d106a65
JMF
652 downloader.add_option(
653 '--hls-use-mpegts',
9bd20204 654 dest='hls_use_mpegts', action='store_true', default=None,
6623ac34 655 help=(
9bd20204 656 'Use the mpegts container for HLS videos; '
657 'allowing some players to play the video while downloading, '
658 'and reducing the chance of file corruption if download is interrupted. '
659 'This is enabled by default for live streams'))
660 downloader.add_option(
661 '--no-hls-use-mpegts',
662 dest='hls_use_mpegts', action='store_false',
663 help=(
664 'Do not use the mpegts container for HLS videos. '
665 'This is default when not downloading live streams'))
222516d9 666 downloader.add_option(
52a8a1e1 667 '--downloader', '--external-downloader',
668 dest='external_downloader', metavar='[PROTO:]NAME', default={}, type='str',
669 action='callback', callback=_dict_from_multiple_values_options_callback,
670 callback_kwargs={
671 'allowed_keys': 'http|ftp|m3u8|dash|rtsp|rtmp|mms',
672 'default_key': 'default', 'process': lambda x: x.strip()},
6623ac34 673 help=(
52a8a1e1 674 'Name or path of the external downloader to use (optionally) prefixed by '
675 'the protocols (http, ftp, m3u8, dash, rstp, rtmp, mms) to use it for. '
676 'Currently supports native, %s (Recommended: aria2c). '
677 'You can use this option multiple times to set different downloaders for different protocols. '
678 'For example, --downloader aria2c --downloader "dash,m3u8:native" will use '
679 'aria2c for http/ftp downloads, and the native downloader for dash/m3u8 downloads '
680 '(Alias: --external-downloader)' % ', '.join(list_external_downloaders())))
c75f0b36 681 downloader.add_option(
46ee996e 682 '--downloader-args', '--external-downloader-args',
683 metavar='NAME:ARGS', dest='external_downloader_args', default={}, type='str',
684 action='callback', callback=_dict_from_multiple_values_options_callback,
b8f6bbe6 685 callback_kwargs={
0202b52a 686 'allowed_keys': '|'.join(list_external_downloaders()),
b8f6bbe6 687 'default_key': 'default', 'process': compat_shlex_split},
46ee996e 688 help=(
689 'Give these arguments to the external downloader. '
690 'Specify the downloader name and the arguments separated by a colon ":". '
691 'You can use this option multiple times (Alias: --external-downloader-args)'))
8450c15c
PH
692
693 workarounds = optparse.OptionGroup(parser, 'Workarounds')
34a741a8 694 workarounds.add_option(
8450c15c
PH
695 '--encoding',
696 dest='encoding', metavar='ENCODING',
34a741a8
PH
697 help='Force the specified encoding (experimental)')
698 workarounds.add_option(
8450c15c
PH
699 '--no-check-certificate',
700 action='store_true', dest='no_check_certificate', default=False,
17941321 701 help='Suppress HTTPS certificate validation')
34a741a8 702 workarounds.add_option(
6623ac34 703 '--prefer-insecure', '--prefer-unsecure',
704 action='store_true', dest='prefer_insecure',
e167860c 705 help='Use an unencrypted connection to retrieve information about the video (Currently supported only for YouTube)')
34a741a8 706 workarounds.add_option(
8450c15c
PH
707 '--user-agent',
708 metavar='UA', dest='user_agent',
17941321 709 help='Specify a custom user agent')
34a741a8 710 workarounds.add_option(
8450c15c
PH
711 '--referer',
712 metavar='URL', dest='referer', default=None,
17941321 713 help='Specify a custom referer, use if the video access is restricted to one domain',
34a741a8
PH
714 )
715 workarounds.add_option(
8450c15c 716 '--add-header',
45016689 717 metavar='FIELD:VALUE', dest='headers', default={}, type='str',
718 action='callback', callback=_dict_from_multiple_values_options_callback,
d818eb74 719 callback_kwargs={'multiple_keys': False},
45016689 720 help='Specify a custom HTTP header and its value, separated by a colon ":". You can use this option multiple times',
34a741a8
PH
721 )
722 workarounds.add_option(
8450c15c
PH
723 '--bidi-workaround',
724 dest='bidi_workaround', action='store_true',
725 help='Work around terminals that lack bidirectional text support. Requires bidiv or fribidi executable in PATH')
1cf376f5 726 workarounds.add_option(
727 '--sleep-requests', metavar='SECONDS',
728 dest='sleep_interval_requests', type=float,
729 help='Number of seconds to sleep between requests during data extraction')
5f0d813d 730 workarounds.add_option(
065bc354 731 '--sleep-interval', '--min-sleep-interval', metavar='SECONDS',
649f7966 732 dest='sleep_interval', type=float,
7aa589a5 733 help=(
e167860c 734 'Number of seconds to sleep before each download. '
735 'This is the minimum time to sleep when used along with --max-sleep-interval '
736 '(Alias: --min-sleep-interval)'))
065bc354 737 workarounds.add_option(
738 '--max-sleep-interval', metavar='SECONDS',
739 dest='max_sleep_interval', type=float,
e167860c 740 help='Maximum number of seconds to sleep. Can only be used along with --min-sleep-interval')
0c9df79e 741 workarounds.add_option(
c76eb41b 742 '--sleep-subtitles', metavar='SECONDS',
31108ce9 743 dest='sleep_interval_subtitles', default=0, type=int,
1cf376f5 744 help='Number of seconds to sleep before each subtitle download')
34a741a8 745
0744a815 746 verbosity = optparse.OptionGroup(parser, 'Verbosity and Simulation Options')
8450c15c
PH
747 verbosity.add_option(
748 '-q', '--quiet',
749 action='store_true', dest='quiet', default=False,
17941321 750 help='Activate quiet mode')
34a741a8
PH
751 verbosity.add_option(
752 '--no-warnings',
753 dest='no_warnings', action='store_true', default=False,
754 help='Ignore warnings')
8450c15c
PH
755 verbosity.add_option(
756 '-s', '--simulate',
757 action='store_true', dest='simulate', default=False,
17941321 758 help='Do not download the video and do not write anything to disk')
b7da73eb 759 verbosity.add_option(
760 '--ignore-no-formats-error',
761 action='store_true', dest='ignore_no_formats_error', default=False,
762 help=(
763 'Ignore "No video formats" error. Usefull for extracting metadata '
764 'even if the video is not actually available for download (experimental)'))
765 verbosity.add_option(
766 '--no-ignore-no-formats-error',
767 action='store_false', dest='ignore_no_formats_error',
768 help='Throw error when no downloadable video formats are found (default)')
8450c15c 769 verbosity.add_option(
6623ac34 770 '--skip-download', '--no-download',
8450c15c 771 action='store_true', dest='skip_download', default=False,
e167860c 772 help='Do not download the video but write all related files (Alias: --no-download)')
8450c15c
PH
773 verbosity.add_option(
774 '-g', '--get-url',
775 action='store_true', dest='geturl', default=False,
17941321 776 help='Simulate, quiet but print URL')
8450c15c
PH
777 verbosity.add_option(
778 '-e', '--get-title',
779 action='store_true', dest='gettitle', default=False,
17941321 780 help='Simulate, quiet but print title')
8450c15c
PH
781 verbosity.add_option(
782 '--get-id',
783 action='store_true', dest='getid', default=False,
17941321 784 help='Simulate, quiet but print id')
8450c15c
PH
785 verbosity.add_option(
786 '--get-thumbnail',
787 action='store_true', dest='getthumbnail', default=False,
17941321 788 help='Simulate, quiet but print thumbnail URL')
8450c15c
PH
789 verbosity.add_option(
790 '--get-description',
791 action='store_true', dest='getdescription', default=False,
17941321 792 help='Simulate, quiet but print video description')
8450c15c
PH
793 verbosity.add_option(
794 '--get-duration',
795 action='store_true', dest='getduration', default=False,
17941321 796 help='Simulate, quiet but print video length')
8450c15c
PH
797 verbosity.add_option(
798 '--get-filename',
799 action='store_true', dest='getfilename', default=False,
17941321 800 help='Simulate, quiet but print output filename')
8450c15c
PH
801 verbosity.add_option(
802 '--get-format',
803 action='store_true', dest='getformat', default=False,
17941321 804 help='Simulate, quiet but print output format')
8450c15c
PH
805 verbosity.add_option(
806 '-j', '--dump-json',
807 action='store_true', dest='dumpjson', default=False,
8a51f564 808 help='Simulate, quiet but print JSON information. See "OUTPUT TEMPLATE" for a description of available keys')
63e0be34
PH
809 verbosity.add_option(
810 '-J', '--dump-single-json',
811 action='store_true', dest='dump_single_json', default=False,
6623ac34 812 help=(
c76eb41b 813 'Simulate, quiet but print JSON information for each command-line argument. '
8a51f564 814 'If the URL refers to a playlist, dump the whole playlist information in a single line'))
c0bdf32a
PH
815 verbosity.add_option(
816 '--print-json',
817 action='store_true', dest='print_json', default=False,
8a51f564 818 help='Be quiet and print the video information as JSON (video is still being downloaded)')
2d30509f 819 verbosity.add_option(
c76eb41b 820 '--force-write-archive', '--force-write-download-archive', '--force-download-archive',
2d30509f 821 action='store_true', dest='force_write_download_archive', default=False,
822 help=(
e58c22a0 823 'Force download archive entries to be written as far as no errors occur, '
824 'even if -s or another simulation option is used (Alias: --force-download-archive)'))
8450c15c
PH
825 verbosity.add_option(
826 '--newline',
827 action='store_true', dest='progress_with_newline', default=False,
17941321 828 help='Output progress bar as new lines')
8450c15c
PH
829 verbosity.add_option(
830 '--no-progress',
831 action='store_true', dest='noprogress', default=False,
17941321 832 help='Do not print progress bar')
8450c15c
PH
833 verbosity.add_option(
834 '--console-title',
835 action='store_true', dest='consoletitle', default=False,
17941321 836 help='Display progress in console titlebar')
8450c15c
PH
837 verbosity.add_option(
838 '-v', '--verbose',
839 action='store_true', dest='verbose', default=False,
17941321 840 help='Print various debugging information')
8450c15c 841 verbosity.add_option(
8bba753c 842 '--dump-pages', '--dump-intermediate-pages',
8450c15c 843 action='store_true', dest='dump_intermediate_pages', default=False,
79979c68 844 help='Print downloaded pages encoded using base64 to debug problems (very verbose)')
8450c15c
PH
845 verbosity.add_option(
846 '--write-pages',
847 action='store_true', dest='write_pages', default=False,
848 help='Write downloaded intermediary pages to files in the current directory to debug problems')
849 verbosity.add_option(
850 '--youtube-print-sig-code',
851 action='store_true', dest='youtube_print_sig_code', default=False,
852 help=optparse.SUPPRESS_HELP)
853 verbosity.add_option(
2f543a21 854 '--print-traffic', '--dump-headers',
8450c15c
PH
855 dest='debug_printtraffic', action='store_true', default=False,
856 help='Display sent and read HTTP traffic')
58b1f00d
PH
857 verbosity.add_option(
858 '-C', '--call-home',
859 dest='call_home', action='store_true', default=False,
7a5c1cfe 860 # help='[Broken] Contact the yt-dlp server for debugging')
8d801631 861 help=optparse.SUPPRESS_HELP)
8bfa7545
PH
862 verbosity.add_option(
863 '--no-call-home',
6623ac34 864 dest='call_home', action='store_false',
7a5c1cfe 865 # help='Do not contact the yt-dlp server for debugging (default)')
8d801631 866 help=optparse.SUPPRESS_HELP)
8450c15c
PH
867
868 filesystem = optparse.OptionGroup(parser, 'Filesystem Options')
869 filesystem.add_option(
870 '-a', '--batch-file',
871 dest='batchfile', metavar='FILE',
5d60b997 872 help="File containing URLs to download ('-' for stdin), one URL per line. "
8a51f564 873 "Lines starting with '#', ';' or ']' are considered as comments and ignored")
8450c15c
PH
874 filesystem.add_option(
875 '--id', default=False,
6623ac34 876 action='store_true', dest='useid', help=optparse.SUPPRESS_HELP)
0202b52a 877 filesystem.add_option(
878 '-P', '--paths',
d818eb74 879 metavar='TYPES:PATH', dest='paths', default={}, type='str',
0202b52a 880 action='callback', callback=_dict_from_multiple_values_options_callback,
881 callback_kwargs={
de6000d9 882 'allowed_keys': 'home|temp|%s' % '|'.join(OUTTMPL_TYPES.keys()),
0202b52a 883 'process': lambda x: x.strip()},
884 help=(
885 'The paths where the files should be downloaded. '
de6000d9 886 'Specify the type of file and the path separated by a colon ":". '
887 'All the same types as --output are supported. '
0202b52a 888 'Additionally, you can also provide "home" and "temp" paths. '
889 'All intermediary files are first downloaded to the temp path and '
890 'then the final files are moved over to the home path after download is finished. '
de6000d9 891 'This option is ignored if --output is an absolute path'))
8450c15c
PH
892 filesystem.add_option(
893 '-o', '--output',
d818eb74 894 metavar='[TYPES:]TEMPLATE', dest='outtmpl', default={}, type='str',
de6000d9 895 action='callback', callback=_dict_from_multiple_values_options_callback,
896 callback_kwargs={
897 'allowed_keys': '|'.join(OUTTMPL_TYPES.keys()),
898 'default_key': 'default', 'process': lambda x: x.strip()},
73cd218f 899 help='Output filename template; see "OUTPUT TEMPLATE" for details')
a820dc72
RA
900 filesystem.add_option(
901 '--output-na-placeholder',
0bc0a322 902 dest='outtmpl_na_placeholder', metavar='TEXT', default='NA',
903 help=('Placeholder value for unavailable meta fields in output filename template (default: "%default")'))
8450c15c
PH
904 filesystem.add_option(
905 '--autonumber-size',
be5df5ee
S
906 dest='autonumber_size', metavar='NUMBER', type=int,
907 help=optparse.SUPPRESS_HELP)
acbb2374
CP
908 filesystem.add_option(
909 '--autonumber-start',
1a241a2d 910 dest='autonumber_start', metavar='NUMBER', default=1, type=int,
a439a3a4 911 help=optparse.SUPPRESS_HELP)
8450c15c
PH
912 filesystem.add_option(
913 '--restrict-filenames',
914 action='store_true', dest='restrictfilenames', default=False,
915 help='Restrict filenames to only ASCII characters, and avoid "&" and spaces in filenames')
6623ac34 916 filesystem.add_option(
917 '--no-restrict-filenames',
c2934512 918 action='store_false', dest='restrictfilenames',
6623ac34 919 help='Allow Unicode characters, "&" and spaces in filenames (default)')
c2934512 920 filesystem.add_option(
921 '--windows-filenames',
922 action='store_true', dest='windowsfilenames', default=False,
923 help='Force filenames to be windows compatible')
924 filesystem.add_option(
925 '--no-windows-filenames',
926 action='store_false', dest='windowsfilenames',
927 help='Make filenames windows compatible only if using windows (default)')
928 filesystem.add_option(
929 '--trim-filenames', '--trim-file-names', metavar='LENGTH',
930 dest='trim_file_name', default=0, type=int,
931 help='Limit the filename length (excluding extension) to the specified number of characters')
2865cf04
PH
932 filesystem.add_option(
933 '-A', '--auto-number',
934 action='store_true', dest='autonumber', default=False,
be5df5ee 935 help=optparse.SUPPRESS_HELP)
8450c15c
PH
936 filesystem.add_option(
937 '-t', '--title',
938 action='store_true', dest='usetitle', default=False,
be5df5ee 939 help=optparse.SUPPRESS_HELP)
8450c15c
PH
940 filesystem.add_option(
941 '-l', '--literal', default=False,
942 action='store_true', dest='usetitle',
be5df5ee 943 help=optparse.SUPPRESS_HELP)
8450c15c
PH
944 filesystem.add_option(
945 '-w', '--no-overwrites',
0c3d0f51 946 action='store_false', dest='overwrites', default=None,
947 help='Do not overwrite any files')
948 filesystem.add_option(
949 '--force-overwrites', '--yes-overwrites',
950 action='store_true', dest='overwrites',
951 help='Overwrite all video and metadata files. This option includes --no-continue')
952 filesystem.add_option(
953 '--no-force-overwrites',
954 action='store_const', dest='overwrites', const=None,
955 help='Do not overwrite the video, but overwrite related files (default)')
8450c15c
PH
956 filesystem.add_option(
957 '-c', '--continue',
958 action='store_true', dest='continue_dl', default=True,
c25228e5 959 help='Resume partially downloaded files/fragments (default)')
8450c15c
PH
960 filesystem.add_option(
961 '--no-continue',
962 action='store_false', dest='continue_dl',
c25228e5 963 help=(
964 'Do not resume partially downloaded fragments. '
e58c22a0 965 'If the file is not fragmented, restart download of the entire file'))
6623ac34 966 filesystem.add_option(
967 '--part',
968 action='store_false', dest='nopart', default=False,
969 help='Use .part files instead of writing directly into output file (default)')
8450c15c
PH
970 filesystem.add_option(
971 '--no-part',
6623ac34 972 action='store_true', dest='nopart',
17941321 973 help='Do not use .part files - write directly into output file')
6623ac34 974 filesystem.add_option(
975 '--mtime',
976 action='store_true', dest='updatetime', default=True,
977 help='Use the Last-modified header to set the file modification time (default)')
8450c15c
PH
978 filesystem.add_option(
979 '--no-mtime',
6623ac34 980 action='store_false', dest='updatetime',
17941321 981 help='Do not use the Last-modified header to set the file modification time')
8450c15c
PH
982 filesystem.add_option(
983 '--write-description',
984 action='store_true', dest='writedescription', default=False,
17941321 985 help='Write video description to a .description file')
6623ac34 986 filesystem.add_option(
987 '--no-write-description',
988 action='store_false', dest='writedescription',
989 help='Do not write video description (default)')
8450c15c
PH
990 filesystem.add_option(
991 '--write-info-json',
992 action='store_true', dest='writeinfojson', default=False,
c25228e5 993 help='Write video metadata to a .info.json file (this may contain personal information)')
6623ac34 994 filesystem.add_option(
995 '--no-write-info-json',
996 action='store_false', dest='writeinfojson',
997 help='Do not write video metadata (default)')
8450c15c
PH
998 filesystem.add_option(
999 '--write-annotations',
1000 action='store_true', dest='writeannotations', default=False,
0669c89c 1001 help='Write video annotations to a .annotations.xml file')
6623ac34 1002 filesystem.add_option(
1003 '--no-write-annotations',
1004 action='store_false', dest='writeannotations',
1005 help='Do not write video annotations (default)')
cac96421 1006 filesystem.add_option(
1007 '--write-playlist-metafiles',
1008 action='store_true', dest='allow_playlist_files', default=True,
1009 help=(
1010 'Write playlist metadata in addition to the video metadata '
1011 'when using --write-info-json, --write-description etc. (default)'))
1012 filesystem.add_option(
1013 '--no-write-playlist-metafiles',
1014 action='store_false', dest='allow_playlist_files',
e167860c 1015 help='Do not write playlist metadata when using --write-info-json, --write-description etc.')
75d43ca0 1016 filesystem.add_option(
1017 '--clean-infojson',
1018 action='store_true', dest='clean_infojson', default=True,
1019 help=(
1020 'Remove some private fields such as filenames from the infojson. '
1021 'Note that it could still contain some personal information (default)'))
1022 filesystem.add_option(
1023 '--no-clean-infojson',
1024 action='store_false', dest='clean_infojson',
1025 help='Write all fields to the infojson')
06167fbb 1026 filesystem.add_option(
1027 '--get-comments',
1028 action='store_true', dest='getcomments', default=False,
277d6ff5 1029 help=(
1030 'Retrieve video comments to be placed in the .info.json file. '
1031 'The comments are fetched even without this option if the extraction is known to be quick'))
8450c15c 1032 filesystem.add_option(
244fe977 1033 '--load-info-json', '--load-info',
8450c15c 1034 dest='load_info_filename', metavar='FILE',
1a48181a 1035 help='JSON file containing the video information (created with the "--write-info-json" option)')
8450c15c
PH
1036 filesystem.add_option(
1037 '--cookies',
1038 dest='cookiefile', metavar='FILE',
17941321 1039 help='File to read cookies from and dump cookie jar in')
6623ac34 1040 filesystem.add_option(
1041 '--no-cookies',
1042 action='store_const', const=None, dest='cookiefile', metavar='FILE',
1043 help='Do not read/dump cookies (default)')
34a741a8
PH
1044 filesystem.add_option(
1045 '--cache-dir', dest='cachedir', default=None, metavar='DIR',
8a51f564 1046 help='Location in the filesystem where youtube-dl can store some downloaded information permanently. By default $XDG_CACHE_HOME/youtube-dl or ~/.cache/youtube-dl . At the moment, only YouTube player files (for videos with obfuscated signatures) are cached, but that may change')
34a741a8 1047 filesystem.add_option(
6623ac34 1048 '--no-cache-dir', action='store_false', dest='cachedir',
34a741a8
PH
1049 help='Disable filesystem caching')
1050 filesystem.add_option(
8450c15c
PH
1051 '--rm-cache-dir',
1052 action='store_true', dest='rm_cachedir',
34a741a8
PH
1053 help='Delete all filesystem cache files')
1054
b31fdeed 1055 thumbnail = optparse.OptionGroup(parser, 'Thumbnail Options')
cfb56d1a
PH
1056 thumbnail.add_option(
1057 '--write-thumbnail',
1058 action='store_true', dest='writethumbnail', default=False,
17941321 1059 help='Write thumbnail image to disk')
6623ac34 1060 thumbnail.add_option(
1061 '--no-write-thumbnail',
1062 action='store_false', dest='writethumbnail',
1063 help='Do not write thumbnail image to disk (default)')
ec82d85a
PH
1064 thumbnail.add_option(
1065 '--write-all-thumbnails',
1066 action='store_true', dest='write_all_thumbnails', default=False,
17941321 1067 help='Write all thumbnail image formats to disk')
cfb56d1a
PH
1068 thumbnail.add_option(
1069 '--list-thumbnails',
1070 action='store_true', dest='list_thumbnails', default=False,
1071 help='Simulate and list all available thumbnail formats')
1072
732044af 1073 link = optparse.OptionGroup(parser, 'Internet Shortcut Options')
1074 link.add_option(
1075 '--write-link',
1076 action='store_true', dest='writelink', default=False,
8a51f564 1077 help='Write an internet shortcut file, depending on the current platform (.url, .webloc or .desktop). The URL may be cached by the OS')
732044af 1078 link.add_option(
1079 '--write-url-link',
1080 action='store_true', dest='writeurllink', default=False,
8a51f564 1081 help='Write a .url Windows internet shortcut. The OS caches the URL based on the file path')
732044af 1082 link.add_option(
1083 '--write-webloc-link',
1084 action='store_true', dest='writewebloclink', default=False,
8a51f564 1085 help='Write a .webloc macOS internet shortcut')
732044af 1086 link.add_option(
1087 '--write-desktop-link',
1088 action='store_true', dest='writedesktoplink', default=False,
8a51f564 1089 help='Write a .desktop Linux internet shortcut')
732044af 1090
1091 postproc = optparse.OptionGroup(parser, 'Post-Processing Options')
8450c15c
PH
1092 postproc.add_option(
1093 '-x', '--extract-audio',
1094 action='store_true', dest='extractaudio', default=False,
e4172ac9 1095 help='Convert video files to audio-only files (requires ffmpeg and ffprobe)')
8450c15c
PH
1096 postproc.add_option(
1097 '--audio-format', metavar='FORMAT', dest='audioformat', default='best',
0efbc6b5 1098 help='Specify audio format: "best", "aac", "flac", "mp3", "m4a", "opus", "vorbis", or "wav"; "%default" by default; No effect without -x')
8450c15c
PH
1099 postproc.add_option(
1100 '--audio-quality', metavar='QUALITY',
1101 dest='audioquality', default='5',
e4172ac9 1102 help='Specify ffmpeg audio quality, insert a value between 0 (better) and 9 (worse) for VBR or a specific bitrate like 128K (default %default)')
efe87a10
FS
1103 postproc.add_option(
1104 '--remux-video',
1105 metavar='FORMAT', dest='remuxvideo', default=None,
6623ac34 1106 help=(
17912249 1107 'Remux the video into another container if necessary (currently supported: %s). '
06167fbb 1108 'If target container does not support the video/audio codec, remuxing will fail. '
1109 'You can specify multiple rules; eg. "aac>m4a/mov>mp4/mkv" will remux aac to m4a, mov to mp4 '
df692c5a 1110 'and anything else to mkv.' % '|'.join(REMUX_EXTENSIONS)))
8450c15c
PH
1111 postproc.add_option(
1112 '--recode-video',
1113 metavar='FORMAT', dest='recodevideo', default=None,
17912249 1114 help=(
1115 'Re-encode the video into another format if re-encoding is necessary. '
1116 'The supported formats are the same as --remux-video'))
d84f1d14 1117 postproc.add_option(
45016689 1118 '--postprocessor-args', '--ppa',
1119 metavar='NAME:ARGS', dest='postprocessor_args', default={}, type='str',
1120 action='callback', callback=_dict_from_multiple_values_options_callback,
d818eb74 1121 callback_kwargs={
1122 'allowed_keys': r'\w+(?:\+\w+)?', 'default_key': 'default-compat',
1123 'process': compat_shlex_split, 'multiple_keys': False},
1b77b347 1124 help=(
1125 'Give these arguments to the postprocessors. '
43820c03 1126 'Specify the postprocessor/executable name and the arguments separated by a colon ":" '
8fa43c73 1127 'to give the argument to the specified postprocessor/executable. Supported PP are: '
1128 'Merger, ExtractAudio, SplitChapters, Metadata, EmbedSubtitle, EmbedThumbnail, '
1129 'SubtitlesConvertor, ThumbnailsConvertor, VideoRemuxer, VideoConvertor, '
1130 'SponSkrub, FixupStretched, FixupM4a and FixupM3u8. '
1131 'The supported executables are: AtomicParsley, FFmpeg, FFprobe, and SponSkrub. '
43820c03 1132 'You can also specify "PP+EXE:ARGS" to give the arguments to the specified executable '
5b1ecbb3 1133 'only when being used by the specified postprocessor. Additionally, for ffmpeg/ffprobe, '
597c1866 1134 '"_i"/"_o" can be appended to the prefix optionally followed by a number to pass the argument '
1135 'before the specified input/output file. Eg: --ppa "Merger+ffmpeg_i1:-v quiet". '
5b1ecbb3 1136 'You can use this option multiple times to give different arguments to different '
1137 'postprocessors. (Alias: --ppa)'))
8450c15c
PH
1138 postproc.add_option(
1139 '-k', '--keep-video',
1140 action='store_true', dest='keepvideo', default=False,
6623ac34 1141 help='Keep the intermediate video file on disk after post-processing')
1142 postproc.add_option(
1143 '--no-keep-video',
1144 action='store_false', dest='keepvideo',
1145 help='Delete the intermediate video file after post-processing (default)')
1146 postproc.add_option(
1147 '--post-overwrites',
1148 action='store_false', dest='nopostoverwrites',
1149 help='Overwrite post-processed files (default)')
8450c15c
PH
1150 postproc.add_option(
1151 '--no-post-overwrites',
1152 action='store_true', dest='nopostoverwrites', default=False,
6623ac34 1153 help='Do not overwrite post-processed files')
8450c15c
PH
1154 postproc.add_option(
1155 '--embed-subs',
1156 action='store_true', dest='embedsubtitles', default=False,
40025ee2 1157 help='Embed subtitles in the video (only for mp4, webm and mkv videos)')
6623ac34 1158 postproc.add_option(
1159 '--no-embed-subs',
1160 action='store_false', dest='embedsubtitles',
1161 help='Do not embed subtitles (default)')
8450c15c
PH
1162 postproc.add_option(
1163 '--embed-thumbnail',
1164 action='store_true', dest='embedthumbnail', default=False,
17941321 1165 help='Embed thumbnail in the audio as cover art')
6623ac34 1166 postproc.add_option(
1167 '--no-embed-thumbnail',
1168 action='store_false', dest='embedthumbnail',
1169 help='Do not embed thumbnail (default)')
8450c15c
PH
1170 postproc.add_option(
1171 '--add-metadata',
1172 action='store_true', dest='addmetadata', default=False,
17941321 1173 help='Write metadata to the video file')
6623ac34 1174 postproc.add_option(
1175 '--no-add-metadata',
1176 action='store_false', dest='addmetadata',
1177 help='Do not write metadata (default)')
e7db87f7 1178 postproc.add_option(
1179 '--metadata-from-title',
1180 metavar='FORMAT', dest='metafromtitle',
5bfa4862 1181 help=optparse.SUPPRESS_HELP)
1182 postproc.add_option(
1183 '--parse-metadata',
73cd218f 1184 metavar='FROM:TO', dest='metafromfield', action='append',
6623ac34 1185 help=(
73cd218f 1186 'Parse additional metadata like title/artist from other fields; '
1187 'see "MODIFYING METADATA" for details'))
8450c15c
PH
1188 postproc.add_option(
1189 '--xattrs',
1190 action='store_true', dest='xattrs', default=False,
17941321 1191 help='Write metadata to the video file\'s xattrs (using dublin core and xdg standards)')
6271f1ca
PH
1192 postproc.add_option(
1193 '--fixup',
99594a11 1194 metavar='POLICY', dest='fixup', default=None,
6623ac34 1195 help=(
1196 'Automatically correct known faults of the file. '
1197 'One of never (do nothing), warn (only emit a warning), '
1198 'detect_or_warn (the default; fix file if we can, warn otherwise)'))
8450c15c 1199 postproc.add_option(
6623ac34 1200 '--prefer-avconv', '--no-prefer-ffmpeg',
8450c15c 1201 action='store_false', dest='prefer_ffmpeg',
e4172ac9 1202 help=optparse.SUPPRESS_HELP)
8450c15c 1203 postproc.add_option(
6623ac34 1204 '--prefer-ffmpeg', '--no-prefer-avconv',
e4172ac9 1205 action='store_true', dest='prefer_ffmpeg', default=True,
1206 help=optparse.SUPPRESS_HELP)
73fac4e9
PH
1207 postproc.add_option(
1208 '--ffmpeg-location', '--avconv-location', metavar='PATH',
1209 dest='ffmpeg_location',
e4172ac9 1210 help='Location of the ffmpeg binary; either the path to the binary or its containing directory')
34a741a8 1211 postproc.add_option(
8450c15c
PH
1212 '--exec',
1213 metavar='CMD', dest='exec_cmd',
9de3ea31 1214 help=(
1215 'Execute a command on the file after downloading and post-processing. '
1216 'Similar syntax to the output template can be used to pass any field as arguments to the command. '
1217 'An additional field "filepath" that contains the final path of the downloaded file is also available. '
1218 'If no fields are passed, "%(filepath)s" is appended to the end of the command'))
e9fade72 1219 postproc.add_option(
e167860c 1220 '--convert-subs', '--convert-sub', '--convert-subtitles',
e9fade72 1221 metavar='FORMAT', dest='convertsubtitles', default=None,
e167860c 1222 help='Convert the subtitles to another format (currently supported: srt|ass|vtt|lrc) (Alias: --convert-subtitles)')
8fa43c73 1223 postproc.add_option(
1224 '--convert-thumbnails',
1225 metavar='FORMAT', dest='convertthumbnails', default=None,
1226 help='Convert the thumbnails to another format (currently supported: jpg)')
72755351 1227 postproc.add_option(
1228 '--split-chapters', '--split-tracks',
1229 dest='split_chapters', action='store_true', default=False,
1230 help=(
1231 'Split video into multiple files based on internal chapters. '
1232 'The "chapter:" prefix can be used with "--paths" and "--output" to '
1233 'set the output filename for the split files. See "OUTPUT TEMPLATE" for details'))
1234 postproc.add_option(
1235 '--no-split-chapters', '--no-split-tracks',
1236 dest='split_chapters', action='store_false',
1237 help='Do not split video based on chapters (default)')
34a741a8 1238
8a51f564 1239 sponskrub = optparse.OptionGroup(parser, 'SponSkrub (SponsorBlock) Options', description=(
7a5c1cfe 1240 'SponSkrub (https://github.com/yt-dlp/SponSkrub) is a utility to mark/remove sponsor segments '
8a51f564 1241 'from downloaded YouTube videos using SponsorBlock API (https://sponsor.ajay.app)'))
c76eb41b 1242 sponskrub.add_option(
a9e7f546 1243 '--sponskrub',
1244 action='store_true', dest='sponskrub', default=None,
6623ac34 1245 help=(
8a51f564 1246 'Use sponskrub to mark sponsored sections. '
6623ac34 1247 'This is enabled by default if the sponskrub binary exists (Youtube only)'))
c76eb41b 1248 sponskrub.add_option(
a9e7f546 1249 '--no-sponskrub',
1250 action='store_false', dest='sponskrub',
6623ac34 1251 help='Do not use sponskrub')
c76eb41b 1252 sponskrub.add_option(
a9e7f546 1253 '--sponskrub-cut', default=False,
1254 action='store_true', dest='sponskrub_cut',
1255 help='Cut out the sponsor sections instead of simply marking them')
c76eb41b 1256 sponskrub.add_option(
6623ac34 1257 '--no-sponskrub-cut',
1258 action='store_false', dest='sponskrub_cut',
1259 help='Simply mark the sponsor sections, not cut them out (default)')
c76eb41b 1260 sponskrub.add_option(
a9e7f546 1261 '--sponskrub-force', default=False,
1262 action='store_true', dest='sponskrub_force',
1263 help='Run sponskrub even if the video was already downloaded')
c76eb41b 1264 sponskrub.add_option(
6623ac34 1265 '--no-sponskrub-force',
1266 action='store_true', dest='sponskrub_force',
1267 help='Do not cut out the sponsor sections if the video was already downloaded (default)')
c76eb41b 1268 sponskrub.add_option(
a9e7f546 1269 '--sponskrub-location', metavar='PATH',
1270 dest='sponskrub_path', default='',
8a51f564 1271 help='Location of the sponskrub binary; either the path to the binary or its containing directory')
c76eb41b 1272 sponskrub.add_option(
1273 '--sponskrub-args', dest='sponskrub_args', metavar='ARGS',
1b77b347 1274 help=optparse.SUPPRESS_HELP)
a9e7f546 1275
78895bd3 1276 extractor = optparse.OptionGroup(parser, 'Extractor Options')
62bff2c1 1277 extractor.add_option(
1278 '--extractor-retries',
d6e51845 1279 dest='extractor_retries', metavar='RETRIES', default=3,
62bff2c1 1280 help='Number of retries for known extractor errors (default is %default), or "infinite"')
78895bd3 1281 extractor.add_option(
6623ac34 1282 '--allow-dynamic-mpd', '--no-ignore-dynamic-mpd',
78895bd3 1283 action='store_true', dest='dynamic_mpd', default=True,
8a51f564 1284 help='Process dynamic DASH manifests (default) (Alias: --no-ignore-dynamic-mpd)')
78895bd3 1285 extractor.add_option(
6623ac34 1286 '--ignore-dynamic-mpd', '--no-allow-dynamic-mpd',
78895bd3 1287 action='store_false', dest='dynamic_mpd',
8a51f564 1288 help='Do not process dynamic DASH manifests (Alias: --no-allow-dynamic-mpd)')
310c2ed2 1289 extractor.add_option(
1290 '--hls-split-discontinuity',
1291 dest='hls_split_discontinuity', action='store_true', default=False,
1292 help='Split HLS playlists to different formats at discontinuities such as ad breaks'
1293 )
1294 extractor.add_option(
1295 '--no-hls-split-discontinuity',
1296 dest='hls_split_discontinuity', action='store_false',
1297 help='Do not split HLS playlists to different formats at discontinuities such as ad breaks (default)')
e409895f 1298 extractor.add_option(
1299 '--youtube-include-dash-manifest', '--no-youtube-skip-dash-manifest',
1300 action='store_true', dest='youtube_include_dash_manifest', default=True,
1301 help='Download the DASH manifests and related data on YouTube videos (default) (Alias: --no-youtube-skip-dash-manifest)')
1302 extractor.add_option(
1303 '--youtube-skip-dash-manifest', '--no-youtube-include-dash-manifest',
1304 action='store_false', dest='youtube_include_dash_manifest',
1305 help='Do not download the DASH manifests and related data on YouTube videos (Alias: --no-youtube-include-dash-manifest)')
1306 extractor.add_option(
1307 '--youtube-include-hls-manifest', '--no-youtube-skip-hls-manifest',
1308 action='store_true', dest='youtube_include_hls_manifest', default=True,
1309 help='Download the HLS manifests and related data on YouTube videos (default) (Alias: --no-youtube-skip-hls-manifest)')
1310 extractor.add_option(
1311 '--youtube-skip-hls-manifest', '--no-youtube-include-hls-manifest',
1312 action='store_false', dest='youtube_include_hls_manifest',
1313 help='Do not download the HLS manifests and related data on YouTube videos (Alias: --no-youtube-include-hls-manifest)')
78895bd3 1314
34a741a8 1315 parser.add_option_group(general)
be4a824d 1316 parser.add_option_group(network)
0aa10994 1317 parser.add_option_group(geo)
34a741a8
PH
1318 parser.add_option_group(selection)
1319 parser.add_option_group(downloader)
1320 parser.add_option_group(filesystem)
cfb56d1a 1321 parser.add_option_group(thumbnail)
732044af 1322 parser.add_option_group(link)
34a741a8
PH
1323 parser.add_option_group(verbosity)
1324 parser.add_option_group(workarounds)
1325 parser.add_option_group(video_format)
1326 parser.add_option_group(subtitles)
1327 parser.add_option_group(authentication)
1328 parser.add_option_group(postproc)
c76eb41b 1329 parser.add_option_group(sponskrub)
78895bd3 1330 parser.add_option_group(extractor)
34a741a8
PH
1331
1332 if overrideArguments is not None:
1333 opts, args = parser.parse_args(overrideArguments)
1334 if opts.verbose:
8450c15c 1335 write_string('[debug] Override config: ' + repr(overrideArguments) + '\n')
34a741a8 1336 else:
b04b94da
S
1337 def compat_conf(conf):
1338 if sys.version_info < (3,):
1339 return [a.decode(preferredencoding(), 'replace') for a in conf]
1340 return conf
1341
e2e43aea 1342 configs = {
0202b52a 1343 'command-line': compat_conf(sys.argv[1:]),
1344 'custom': [], 'home': [], 'portable': [], 'user': [], 'system': []}
1345 paths = {'command-line': False}
1346 opts, args = parser.parse_args(configs['command-line'])
f5e2efbb 1347
e2e43aea 1348 def get_configs():
0202b52a 1349 if '--config-location' in configs['command-line']:
e2e43aea 1350 location = compat_expanduser(opts.config_location)
1351 if os.path.isdir(location):
7a5c1cfe 1352 location = os.path.join(location, 'yt-dlp.conf')
e2e43aea 1353 if not os.path.exists(location):
1354 parser.error('config-location %s does not exist.' % location)
0202b52a 1355 configs['custom'] = _readOptions(location, default=None)
1356 if configs['custom'] is None:
1357 configs['custom'] = []
1358 else:
1359 paths['custom'] = location
1360 if '--ignore-config' in configs['command-line']:
e2e43aea 1361 return
1362 if '--ignore-config' in configs['custom']:
1363 return
1364
0202b52a 1365 def read_options(path, user=False):
7a5c1cfe
P
1366 # Multiple package names can be given here
1367 # Eg: ('yt-dlp', 'youtube-dlc', 'youtube-dl') will look for
1368 # the configuration file of any of these three packages
1369 for package in ('yt-dlp',):
0202b52a 1370 if user:
b5d26563 1371 config, current_path = _readUserConf(package, default=None)
1372 else:
1373 current_path = os.path.join(path, '%s.conf' % package)
1374 config = _readOptions(current_path, default=None)
1375 if config is not None:
1376 return config, current_path
1377 return [], None
0202b52a 1378
f74980cb 1379 configs['portable'], paths['portable'] = read_options(get_executable_path())
e2e43aea 1380 if '--ignore-config' in configs['portable']:
1381 return
e2e43aea 1382
0202b52a 1383 def get_home_path():
1384 opts = parser.parse_args(configs['portable'] + configs['custom'] + configs['command-line'])[0]
1385 return expand_path(opts.paths.get('home', '')).strip()
1386
1387 configs['home'], paths['home'] = read_options(get_home_path())
1388 if '--ignore-config' in configs['home']:
1389 return
1390
1391 configs['system'], paths['system'] = read_options('/etc')
e2e43aea 1392 if '--ignore-config' in configs['system']:
1393 return
0202b52a 1394
1395 configs['user'], paths['user'] = read_options('', True)
e2e43aea 1396 if '--ignore-config' in configs['user']:
0202b52a 1397 configs['system'], paths['system'] = [], None
e66dca5e 1398
e2e43aea 1399 get_configs()
0202b52a 1400 argv = configs['system'] + configs['user'] + configs['home'] + configs['portable'] + configs['custom'] + configs['command-line']
34a741a8
PH
1401 opts, args = parser.parse_args(argv)
1402 if opts.verbose:
0202b52a 1403 for label in ('System', 'User', 'Portable', 'Home', 'Custom', 'Command-line'):
1404 key = label.lower()
1405 if paths.get(key) is None:
1406 continue
1407 if paths[key]:
1408 write_string('[debug] %s config file: %s\n' % (label, paths[key]))
1409 write_string('[debug] %s config: %s\n' % (label, repr(_hide_login_info(configs[key]))))
34a741a8
PH
1410
1411 return parser, opts, args