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