]> jfr.im git - yt-dlp.git/blob - youtube_dlc/options.py
Update to ytdl-2021.01.03
[yt-dlp.git] / youtube_dlc / options.py
1 from __future__ import unicode_literals
2
3 import os.path
4 import optparse
5 import re
6 import sys
7
8 from .downloader.external import list_external_downloaders
9 from .compat import (
10 compat_expanduser,
11 compat_get_terminal_size,
12 compat_getenv,
13 compat_kwargs,
14 compat_shlex_split,
15 )
16 from .utils import (
17 preferredencoding,
18 write_string,
19 )
20 from .version import __version__
21
22
23 def _hide_login_info(opts):
24 PRIVATE_OPTS = set(['-p', '--password', '-u', '--username', '--video-password', '--ap-password', '--ap-username'])
25 eqre = re.compile('^(?P<key>' + ('|'.join(re.escape(po) for po in PRIVATE_OPTS)) + ')=.+$')
26
27 def _scrub_eq(o):
28 m = eqre.match(o)
29 if m:
30 return m.group('key') + '=PRIVATE'
31 else:
32 return o
33
34 opts = list(map(_scrub_eq, opts))
35 for idx, opt in enumerate(opts):
36 if opt in PRIVATE_OPTS and idx + 1 < len(opts):
37 opts[idx + 1] = 'PRIVATE'
38 return opts
39
40
41 def parseOpts(overrideArguments=None):
42 def _readOptions(filename_bytes, default=[]):
43 try:
44 optionf = open(filename_bytes)
45 except IOError:
46 return default # silently skip if file is not present
47 try:
48 # FIXME: https://github.com/ytdl-org/youtube-dl/commit/dfe5fa49aed02cf36ba9f743b11b0903554b5e56
49 contents = optionf.read()
50 if sys.version_info < (3,):
51 contents = contents.decode(preferredencoding())
52 res = compat_shlex_split(contents, comments=True)
53 finally:
54 optionf.close()
55 return res
56
57 def _readUserConf():
58 xdg_config_home = compat_getenv('XDG_CONFIG_HOME')
59 if xdg_config_home:
60 userConfFile = os.path.join(xdg_config_home, 'youtube-dlc', 'config')
61 if not os.path.isfile(userConfFile):
62 userConfFile = os.path.join(xdg_config_home, 'youtube-dlc.conf')
63 else:
64 userConfFile = os.path.join(compat_expanduser('~'), '.config', 'youtube-dlc', 'config')
65 if not os.path.isfile(userConfFile):
66 userConfFile = os.path.join(compat_expanduser('~'), '.config', 'youtube-dlc.conf')
67 userConf = _readOptions(userConfFile, None)
68
69 if userConf is None:
70 appdata_dir = compat_getenv('appdata')
71 if appdata_dir:
72 userConf = _readOptions(
73 os.path.join(appdata_dir, 'youtube-dlc', 'config'),
74 default=None)
75 if userConf is None:
76 userConf = _readOptions(
77 os.path.join(appdata_dir, 'youtube-dlc', 'config.txt'),
78 default=None)
79
80 if userConf is None:
81 userConf = _readOptions(
82 os.path.join(compat_expanduser('~'), 'youtube-dlc.conf'),
83 default=None)
84 if userConf is None:
85 userConf = _readOptions(
86 os.path.join(compat_expanduser('~'), 'youtube-dlc.conf.txt'),
87 default=None)
88
89 if userConf is None:
90 userConf = []
91
92 return userConf
93
94 def _format_option_string(option):
95 ''' ('-o', '--option') -> -o, --format METAVAR'''
96
97 opts = []
98
99 if option._short_opts:
100 opts.append(option._short_opts[0])
101 if option._long_opts:
102 opts.append(option._long_opts[0])
103 if len(opts) > 1:
104 opts.insert(1, ', ')
105
106 if option.takes_value():
107 opts.append(' %s' % option.metavar)
108
109 return ''.join(opts)
110
111 def _comma_separated_values_options_callback(option, opt_str, value, parser):
112 setattr(parser.values, option.dest, value.split(','))
113
114 # No need to wrap help messages if we're on a wide console
115 columns = compat_get_terminal_size().columns
116 max_width = columns if columns else 80
117 max_help_position = 80
118
119 fmt = optparse.IndentedHelpFormatter(width=max_width, max_help_position=max_help_position)
120 fmt.format_option_strings = _format_option_string
121
122 kw = {
123 'version': __version__,
124 'formatter': fmt,
125 'usage': '%prog [OPTIONS] URL [URL...]',
126 'conflict_handler': 'resolve',
127 }
128
129 parser = optparse.OptionParser(**compat_kwargs(kw))
130
131 general = optparse.OptionGroup(parser, 'General Options')
132 general.add_option(
133 '-h', '--help',
134 action='help',
135 help='Print this help text and exit')
136 general.add_option(
137 '--version',
138 action='version',
139 help='Print program version and exit')
140 general.add_option(
141 '-U', '--update',
142 action='store_true', dest='update_self',
143 help='Update this program to latest version. Make sure that you have sufficient permissions (run with sudo if needed)')
144 general.add_option(
145 '-i', '--ignore-errors', '--no-abort-on-error',
146 action='store_true', dest='ignoreerrors', default=False,
147 help='Continue on download errors, for example to skip unavailable videos in a playlist')
148 general.add_option(
149 '--abort-on-error', '--no-ignore-errors',
150 action='store_false', dest='ignoreerrors',
151 help='Abort downloading of further videos if an error occurs (default)')
152 general.add_option(
153 '--dump-user-agent',
154 action='store_true', dest='dump_user_agent', default=False,
155 help='Display the current browser identification')
156 general.add_option(
157 '--list-extractors',
158 action='store_true', dest='list_extractors', default=False,
159 help='List all supported extractors')
160 general.add_option(
161 '--extractor-descriptions',
162 action='store_true', dest='list_extractor_descriptions', default=False,
163 help='Output descriptions of all supported extractors')
164 general.add_option(
165 '--force-generic-extractor',
166 action='store_true', dest='force_generic_extractor', default=False,
167 help='Force extraction to use the generic extractor')
168 general.add_option(
169 '--default-search',
170 dest='default_search', metavar='PREFIX',
171 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.')
172 general.add_option(
173 '--ignore-config', '--no-config',
174 action='store_true',
175 help=(
176 'Do not read configuration files. '
177 'When given in the global configuration file /etc/youtube-dl.conf: '
178 'Do not read the user configuration in ~/.config/youtube-dl/config '
179 '(%APPDATA%/youtube-dl/config.txt on Windows)'))
180 general.add_option(
181 '--config-location',
182 dest='config_location', metavar='PATH',
183 help='Location of the configuration file; either the path to the config or its containing directory.')
184 general.add_option(
185 '--flat-playlist',
186 action='store_const', dest='extract_flat', const='in_playlist', default=False,
187 help='Do not extract the videos of a playlist, only list them.')
188 general.add_option(
189 '--flat-videos',
190 action='store_true', dest='extract_flat',
191 help='Do not resolve the video urls')
192 general.add_option(
193 '--no-flat-playlist',
194 action='store_false', dest='extract_flat',
195 help='Extract the videos of a playlist')
196 general.add_option(
197 '--mark-watched',
198 action='store_true', dest='mark_watched', default=False,
199 help='Mark videos watched (YouTube only)')
200 general.add_option(
201 '--no-mark-watched',
202 action='store_false', dest='mark_watched', default=False,
203 help='Do not mark videos watched')
204 general.add_option(
205 '--no-color', '--no-colors',
206 action='store_true', dest='no_color',
207 default=False,
208 help='Do not emit color codes in output')
209
210 network = optparse.OptionGroup(parser, 'Network Options')
211 network.add_option(
212 '--proxy', dest='proxy',
213 default=None, metavar='URL',
214 help=(
215 'Use the specified HTTP/HTTPS/SOCKS proxy. To enable '
216 'SOCKS proxy, specify a proper scheme. For example '
217 'socks5://127.0.0.1:1080/. Pass in an empty string (--proxy "") '
218 'for direct connection'))
219 network.add_option(
220 '--socket-timeout',
221 dest='socket_timeout', type=float, default=None, metavar='SECONDS',
222 help='Time to wait before giving up, in seconds')
223 network.add_option(
224 '--source-address',
225 metavar='IP', dest='source_address', default=None,
226 help='Client-side IP address to bind to',
227 )
228 network.add_option(
229 '-4', '--force-ipv4',
230 action='store_const', const='0.0.0.0', dest='source_address',
231 help='Make all connections via IPv4',
232 )
233 network.add_option(
234 '-6', '--force-ipv6',
235 action='store_const', const='::', dest='source_address',
236 help='Make all connections via IPv6',
237 )
238
239 geo = optparse.OptionGroup(parser, 'Geo Restriction')
240 geo.add_option(
241 '--geo-verification-proxy',
242 dest='geo_verification_proxy', default=None, metavar='URL',
243 help=(
244 'Use this proxy to verify the IP address for some geo-restricted sites. '
245 'The default proxy specified by --proxy (or none, if the option is not present) is used for the actual downloading.'))
246 geo.add_option(
247 '--cn-verification-proxy',
248 dest='cn_verification_proxy', default=None, metavar='URL',
249 help=optparse.SUPPRESS_HELP)
250 geo.add_option(
251 '--geo-bypass',
252 action='store_true', dest='geo_bypass', default=True,
253 help='Bypass geographic restriction via faking X-Forwarded-For HTTP header')
254 geo.add_option(
255 '--no-geo-bypass',
256 action='store_false', dest='geo_bypass', default=True,
257 help='Do not bypass geographic restriction via faking X-Forwarded-For HTTP header')
258 geo.add_option(
259 '--geo-bypass-country', metavar='CODE',
260 dest='geo_bypass_country', default=None,
261 help='Force bypass geographic restriction with explicitly provided two-letter ISO 3166-2 country code')
262 geo.add_option(
263 '--geo-bypass-ip-block', metavar='IP_BLOCK',
264 dest='geo_bypass_ip_block', default=None,
265 help='Force bypass geographic restriction with explicitly provided IP block in CIDR notation')
266
267 selection = optparse.OptionGroup(parser, 'Video Selection')
268 selection.add_option(
269 '--playlist-start',
270 dest='playliststart', metavar='NUMBER', default=1, type=int,
271 help='Playlist video to start at (default is %default)')
272 selection.add_option(
273 '--playlist-end',
274 dest='playlistend', metavar='NUMBER', default=None, type=int,
275 help='Playlist video to end at (default is last)')
276 selection.add_option(
277 '--playlist-items',
278 dest='playlist_items', metavar='ITEM_SPEC', default=None,
279 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.')
280 selection.add_option(
281 '--match-title',
282 dest='matchtitle', metavar='REGEX',
283 help='Download only matching titles (regex or caseless sub-string)')
284 selection.add_option(
285 '--reject-title',
286 dest='rejecttitle', metavar='REGEX',
287 help='Skip download for matching titles (regex or caseless sub-string)')
288 selection.add_option(
289 '--max-downloads',
290 dest='max_downloads', metavar='NUMBER', type=int, default=None,
291 help='Abort after downloading NUMBER files')
292 selection.add_option(
293 '--min-filesize',
294 metavar='SIZE', dest='min_filesize', default=None,
295 help='Do not download any videos smaller than SIZE (e.g. 50k or 44.6m)')
296 selection.add_option(
297 '--max-filesize',
298 metavar='SIZE', dest='max_filesize', default=None,
299 help='Do not download any videos larger than SIZE (e.g. 50k or 44.6m)')
300 selection.add_option(
301 '--date',
302 metavar='DATE', dest='date', default=None,
303 help='Download only videos uploaded in this date')
304 selection.add_option(
305 '--datebefore',
306 metavar='DATE', dest='datebefore', default=None,
307 help='Download only videos uploaded on or before this date (i.e. inclusive)')
308 selection.add_option(
309 '--dateafter',
310 metavar='DATE', dest='dateafter', default=None,
311 help='Download only videos uploaded on or after this date (i.e. inclusive)')
312 selection.add_option(
313 '--min-views',
314 metavar='COUNT', dest='min_views', default=None, type=int,
315 help='Do not download any videos with less than COUNT views')
316 selection.add_option(
317 '--max-views',
318 metavar='COUNT', dest='max_views', default=None, type=int,
319 help='Do not download any videos with more than COUNT views')
320 selection.add_option(
321 '--match-filter',
322 metavar='FILTER', dest='match_filter', default=None,
323 help=(
324 'Generic video filter. '
325 'Specify any key (see the "OUTPUT TEMPLATE" for a list of available keys) to '
326 'match if the key is present, '
327 '!key to check if the key is not present, '
328 'key > NUMBER (like "comment_count > 12", also works with '
329 '>=, <, <=, !=, =) to compare against a number, '
330 'key = \'LITERAL\' (like "uploader = \'Mike Smith\'", also works with !=) '
331 'to match against a string literal '
332 'and & to require multiple matches. '
333 'Values which are not known are excluded unless you '
334 'put a question mark (?) after the operator. '
335 'For example, to only match videos that have been liked more than '
336 '100 times and disliked less than 50 times (or the dislike '
337 'functionality is not available at the given service), but who '
338 'also have a description, use --match-filter '
339 '"like_count > 100 & dislike_count <? 50 & description" .'))
340 selection.add_option(
341 '--no-match-filter',
342 metavar='FILTER', dest='match_filter', action='store_const', const=None,
343 help='Do not use generic video filter (default)')
344 selection.add_option(
345 '--no-playlist',
346 action='store_true', dest='noplaylist', default=False,
347 help='Download only the video, if the URL refers to a video and a playlist.')
348 selection.add_option(
349 '--yes-playlist',
350 action='store_false', dest='noplaylist', default=False,
351 help='Download the playlist, if the URL refers to a video and a playlist.')
352 selection.add_option(
353 '--age-limit',
354 metavar='YEARS', dest='age_limit', default=None, type=int,
355 help='Download only videos suitable for the given age')
356 selection.add_option(
357 '--download-archive', metavar='FILE',
358 dest='download_archive',
359 help='Download only videos not listed in the archive file. Record the IDs of all downloaded videos in it.')
360 selection.add_option(
361 '--break-on-existing',
362 action='store_true', dest='break_on_existing', default=False,
363 help="Stop the download process after attempting to download a file that's in the archive.")
364 selection.add_option(
365 '--no-download-archive',
366 dest='download_archive', action="store_const", const=None,
367 help='Do not use archive file (default)')
368 selection.add_option(
369 '--include-ads',
370 dest='include_ads', action='store_true',
371 help='Download advertisements as well (experimental)')
372 selection.add_option(
373 '--no-include-ads',
374 dest='include_ads', action='store_false',
375 help='Do not download advertisements (default)')
376
377 authentication = optparse.OptionGroup(parser, 'Authentication Options')
378 authentication.add_option(
379 '-u', '--username',
380 dest='username', metavar='USERNAME',
381 help='Login with this account ID')
382 authentication.add_option(
383 '-p', '--password',
384 dest='password', metavar='PASSWORD',
385 help='Account password. If this option is left out, youtube-dlc will ask interactively.')
386 authentication.add_option(
387 '-2', '--twofactor',
388 dest='twofactor', metavar='TWOFACTOR',
389 help='Two-factor authentication code')
390 authentication.add_option(
391 '-n', '--netrc',
392 action='store_true', dest='usenetrc', default=False,
393 help='Use .netrc authentication data')
394 authentication.add_option(
395 '--video-password',
396 dest='videopassword', metavar='PASSWORD',
397 help='Video password (vimeo, youku)')
398
399 adobe_pass = optparse.OptionGroup(parser, 'Adobe Pass Options')
400 adobe_pass.add_option(
401 '--ap-mso',
402 dest='ap_mso', metavar='MSO',
403 help='Adobe Pass multiple-system operator (TV provider) identifier, use --ap-list-mso for a list of available MSOs')
404 adobe_pass.add_option(
405 '--ap-username',
406 dest='ap_username', metavar='USERNAME',
407 help='Multiple-system operator account login')
408 adobe_pass.add_option(
409 '--ap-password',
410 dest='ap_password', metavar='PASSWORD',
411 help='Multiple-system operator account password. If this option is left out, youtube-dlc will ask interactively.')
412 adobe_pass.add_option(
413 '--ap-list-mso',
414 action='store_true', dest='ap_list_mso', default=False,
415 help='List all supported multiple-system operators')
416
417 video_format = optparse.OptionGroup(parser, 'Video Format Options')
418 video_format.add_option(
419 '-f', '--format',
420 action='store', dest='format', metavar='FORMAT', default=None,
421 help='Video format code, see "FORMAT SELECTION" for more details')
422 video_format.add_option(
423 '-S', '--format-sort',
424 dest='format_sort', default=[],
425 action='callback', callback=_comma_separated_values_options_callback, type='str',
426 help='Sort the formats by the fields given, see "Sorting Formats" for more details')
427 video_format.add_option(
428 '--format-sort-force', '--S-force',
429 action='store_true', dest='format_sort_force', metavar='FORMAT', default=False,
430 help=(
431 'Force user specified sort order to have precedence over all fields, '
432 'see "Sorting Formats" for more details'))
433 video_format.add_option(
434 '--no-format-sort-force',
435 action='store_false', dest='format_sort_force', metavar='FORMAT', default=False,
436 help=(
437 'Some fields have precedence over the user specified sort order (default), '
438 'see "Sorting Formats" for more details'))
439 video_format.add_option(
440 '--video-multistreams',
441 action='store_true', dest='allow_multiple_video_streams', default=True,
442 help='Allow multiple video streams to be merged into a single file (default)')
443 video_format.add_option(
444 '--no-video-multistreams',
445 action='store_false', dest='allow_multiple_video_streams',
446 help='Only one video stream is downloaded for each output file')
447 video_format.add_option(
448 '--audio-multistreams',
449 action='store_true', dest='allow_multiple_audio_streams', default=True,
450 help='Allow multiple audio streams to be merged into a single file (default)')
451 video_format.add_option(
452 '--no-audio-multistreams',
453 action='store_false', dest='allow_multiple_audio_streams',
454 help='Only one audio stream is downloaded for each output file')
455 video_format.add_option(
456 '--all-formats',
457 action='store_const', dest='format', const='all',
458 help='Download all available video formats')
459 video_format.add_option(
460 '--prefer-free-formats',
461 action='store_true', dest='prefer_free_formats', default=False,
462 help='Prefer free video formats unless a specific one is requested')
463 video_format.add_option(
464 '-F', '--list-formats',
465 action='store_true', dest='listformats',
466 help='List all available formats of requested videos')
467 video_format.add_option(
468 '--list-formats-as-table',
469 action='store_true', dest='listformats_table', default=False,
470 help='Present the output of -F in a more tabular form')
471 video_format.add_option(
472 '--list-formats-old', '--no-list-formats-as-table',
473 action='store_false', dest='listformats_table',
474 help='Present the output of -F in the old form')
475 video_format.add_option(
476 '--youtube-include-dash-manifest', '--no-youtube-skip-dash-manifest',
477 action='store_true', dest='youtube_include_dash_manifest', default=True,
478 help='Download the DASH manifests and related data on YouTube videos (default)')
479 video_format.add_option(
480 '--youtube-skip-dash-manifest', '--no-youtube-include-dash-manifest',
481 action='store_false', dest='youtube_include_dash_manifest',
482 help='Do not download the DASH manifests and related data on YouTube videos')
483 video_format.add_option(
484 '--youtube-include-hls-manifest', '--no-youtube-skip-hls-manifest',
485 action='store_true', dest='youtube_include_hls_manifest', default=True,
486 help='Download the HLS manifests and related data on YouTube videos (default)')
487 video_format.add_option(
488 '--youtube-skip-hls-manifest', '--no-youtube-include-hls-manifest',
489 action='store_false', dest='youtube_include_hls_manifest',
490 help='Do not download the HLS manifests and related data on YouTube videos')
491 video_format.add_option(
492 '--merge-output-format',
493 action='store', dest='merge_output_format', metavar='FORMAT', default=None,
494 help=(
495 'If a merge is required (e.g. bestvideo+bestaudio), '
496 'output to given container format. One of mkv, mp4, ogg, webm, flv. '
497 'Ignored if no merge is required'))
498
499 subtitles = optparse.OptionGroup(parser, 'Subtitle Options')
500 subtitles.add_option(
501 '--write-subs', '--write-srt',
502 action='store_true', dest='writesubtitles', default=False,
503 help='Write subtitle file')
504 subtitles.add_option(
505 '--no-write-subs', '--no-write-srt',
506 action='store_false', dest='writesubtitles',
507 help='Do not write subtitle file (default)')
508 subtitles.add_option(
509 '--write-auto-subs', '--write-automatic-subs',
510 action='store_true', dest='writeautomaticsub', default=False,
511 help='Write automatically generated subtitle file (YouTube only)')
512 subtitles.add_option(
513 '--no-write-auto-subs', '--no-write-automatic-subs',
514 action='store_false', dest='writeautomaticsub', default=False,
515 help='Do not write automatically generated subtitle file (default)')
516 subtitles.add_option(
517 '--all-subs',
518 action='store_true', dest='allsubtitles', default=False,
519 help='Download all the available subtitles of the video')
520 subtitles.add_option(
521 '--list-subs',
522 action='store_true', dest='listsubtitles', default=False,
523 help='List all available subtitles for the video')
524 subtitles.add_option(
525 '--sub-format',
526 action='store', dest='subtitlesformat', metavar='FORMAT', default='best',
527 help='Subtitle format, accepts formats preference, for example: "srt" or "ass/srt/best"')
528 subtitles.add_option(
529 '--sub-lang', '--sub-langs', '--srt-lang',
530 action='callback', dest='subtitleslangs', metavar='LANGS', type='str',
531 default=[], callback=_comma_separated_values_options_callback,
532 help='Languages of the subtitles to download (optional) separated by commas, use --list-subs for available language tags')
533
534 downloader = optparse.OptionGroup(parser, 'Download Options')
535 downloader.add_option(
536 '-r', '--limit-rate', '--rate-limit',
537 dest='ratelimit', metavar='RATE',
538 help='Maximum download rate in bytes per second (e.g. 50K or 4.2M)')
539 downloader.add_option(
540 '-R', '--retries',
541 dest='retries', metavar='RETRIES', default=10,
542 help='Number of retries (default is %default), or "infinite".')
543 downloader.add_option(
544 '--fragment-retries',
545 dest='fragment_retries', metavar='RETRIES', default=10,
546 help='Number of retries for a fragment (default is %default), or "infinite" (DASH, hlsnative and ISM)')
547 downloader.add_option(
548 '--skip-unavailable-fragments','--no-abort-on-unavailable-fragment',
549 action='store_true', dest='skip_unavailable_fragments', default=True,
550 help='Skip unavailable fragments for DASH, hlsnative and ISM (default)')
551 downloader.add_option(
552 '--abort-on-unavailable-fragment', '--no-skip-unavailable-fragments',
553 action='store_false', dest='skip_unavailable_fragments',
554 help='Abort downloading when some fragment is not available')
555 downloader.add_option(
556 '--keep-fragments',
557 action='store_true', dest='keep_fragments', default=False,
558 help='Keep downloaded fragments on disk after downloading is finished')
559 downloader.add_option(
560 '--no-keep-fragments',
561 action='store_false', dest='keep_fragments',
562 help='Delete downloaded fragments after downloading is finished (default)')
563 downloader.add_option(
564 '--buffer-size',
565 dest='buffersize', metavar='SIZE', default='1024',
566 help='Size of download buffer (e.g. 1024 or 16K) (default is %default)')
567 downloader.add_option(
568 '--resize-buffer',
569 action='store_false', dest='noresizebuffer',
570 help='The buffer size is automatically resized from an initial value of --buffer-size (default)')
571 downloader.add_option(
572 '--no-resize-buffer',
573 action='store_true', dest='noresizebuffer', default=False,
574 help='Do not automatically adjust the buffer size')
575 downloader.add_option(
576 '--http-chunk-size',
577 dest='http_chunk_size', metavar='SIZE', default=None,
578 help=(
579 'Size of a chunk for chunk-based HTTP downloading (e.g. 10485760 or 10M) (default is disabled). '
580 'May be useful for bypassing bandwidth throttling imposed by a webserver (experimental)'))
581 downloader.add_option(
582 '--test',
583 action='store_true', dest='test', default=False,
584 help=optparse.SUPPRESS_HELP)
585 downloader.add_option(
586 '--playlist-reverse',
587 action='store_true',
588 help='Download playlist videos in reverse order')
589 downloader.add_option(
590 '--no-playlist-reverse',
591 action='store_false', dest='playlist_reverse',
592 help='Download playlist videos in default order (default)')
593 downloader.add_option(
594 '--playlist-random',
595 action='store_true',
596 help='Download playlist videos in random order')
597 downloader.add_option(
598 '--xattr-set-filesize',
599 dest='xattr_set_filesize', action='store_true',
600 help='Set file xattribute ytdl.filesize with expected file size')
601 downloader.add_option(
602 '--hls-prefer-native',
603 dest='hls_prefer_native', action='store_true', default=None,
604 help='Use the native HLS downloader instead of ffmpeg')
605 downloader.add_option(
606 '--hls-prefer-ffmpeg',
607 dest='hls_prefer_native', action='store_false', default=None,
608 help='Use ffmpeg instead of the native HLS downloader')
609 downloader.add_option(
610 '--hls-use-mpegts',
611 dest='hls_use_mpegts', action='store_true',
612 help=(
613 'Use the mpegts container for HLS videos, allowing to play the '
614 'video while downloading (some players may not be able to play it)'))
615 downloader.add_option(
616 '--external-downloader',
617 dest='external_downloader', metavar='COMMAND',
618 help=(
619 'Use the specified external downloader. '
620 'Currently supports %s' % ','.join(list_external_downloaders()) ))
621 downloader.add_option(
622 '--external-downloader-args',
623 dest='external_downloader_args', metavar='ARGS',
624 help='Give these arguments to the external downloader')
625
626 workarounds = optparse.OptionGroup(parser, 'Workarounds')
627 workarounds.add_option(
628 '--encoding',
629 dest='encoding', metavar='ENCODING',
630 help='Force the specified encoding (experimental)')
631 workarounds.add_option(
632 '--no-check-certificate',
633 action='store_true', dest='no_check_certificate', default=False,
634 help='Suppress HTTPS certificate validation')
635 workarounds.add_option(
636 '--prefer-insecure', '--prefer-unsecure',
637 action='store_true', dest='prefer_insecure',
638 help='Use an unencrypted connection to retrieve information about the video. (Currently supported only for YouTube)')
639 workarounds.add_option(
640 '--user-agent',
641 metavar='UA', dest='user_agent',
642 help='Specify a custom user agent')
643 workarounds.add_option(
644 '--referer',
645 metavar='URL', dest='referer', default=None,
646 help='Specify a custom referer, use if the video access is restricted to one domain',
647 )
648 workarounds.add_option(
649 '--add-header',
650 metavar='FIELD:VALUE', dest='headers', action='append',
651 help='Specify a custom HTTP header and its value, separated by a colon \':\'. You can use this option multiple times',
652 )
653 workarounds.add_option(
654 '--bidi-workaround',
655 dest='bidi_workaround', action='store_true',
656 help='Work around terminals that lack bidirectional text support. Requires bidiv or fribidi executable in PATH')
657 workarounds.add_option(
658 '--sleep-interval', '--min-sleep-interval', metavar='SECONDS',
659 dest='sleep_interval', type=float,
660 help=(
661 'Number of seconds to sleep before each download when used alone '
662 'or a lower bound of a range for randomized sleep before each download '
663 '(minimum possible number of seconds to sleep) when used along with '
664 '--max-sleep-interval.'))
665 workarounds.add_option(
666 '--max-sleep-interval', metavar='SECONDS',
667 dest='max_sleep_interval', type=float,
668 help=(
669 'Upper bound of a range for randomized sleep before each download '
670 '(maximum possible number of seconds to sleep). Must only be used '
671 'along with --min-sleep-interval.'))
672 workarounds.add_option(
673 '--sleep-subtitles',
674 dest='sleep_interval_subtitles', default=0, type=int,
675 help='Enforce sleep interval on subtitles as well')
676
677 verbosity = optparse.OptionGroup(parser, 'Verbosity / Simulation Options')
678 verbosity.add_option(
679 '-q', '--quiet',
680 action='store_true', dest='quiet', default=False,
681 help='Activate quiet mode')
682 verbosity.add_option(
683 '--no-warnings',
684 dest='no_warnings', action='store_true', default=False,
685 help='Ignore warnings')
686 verbosity.add_option(
687 '-s', '--simulate',
688 action='store_true', dest='simulate', default=False,
689 help='Do not download the video and do not write anything to disk')
690 verbosity.add_option(
691 '--skip-download', '--no-download',
692 action='store_true', dest='skip_download', default=False,
693 help='Do not download the video')
694 verbosity.add_option(
695 '-g', '--get-url',
696 action='store_true', dest='geturl', default=False,
697 help='Simulate, quiet but print URL')
698 verbosity.add_option(
699 '-e', '--get-title',
700 action='store_true', dest='gettitle', default=False,
701 help='Simulate, quiet but print title')
702 verbosity.add_option(
703 '--get-id',
704 action='store_true', dest='getid', default=False,
705 help='Simulate, quiet but print id')
706 verbosity.add_option(
707 '--get-thumbnail',
708 action='store_true', dest='getthumbnail', default=False,
709 help='Simulate, quiet but print thumbnail URL')
710 verbosity.add_option(
711 '--get-description',
712 action='store_true', dest='getdescription', default=False,
713 help='Simulate, quiet but print video description')
714 verbosity.add_option(
715 '--get-duration',
716 action='store_true', dest='getduration', default=False,
717 help='Simulate, quiet but print video length')
718 verbosity.add_option(
719 '--get-filename',
720 action='store_true', dest='getfilename', default=False,
721 help='Simulate, quiet but print output filename')
722 verbosity.add_option(
723 '--get-format',
724 action='store_true', dest='getformat', default=False,
725 help='Simulate, quiet but print output format')
726 verbosity.add_option(
727 '-j', '--dump-json',
728 action='store_true', dest='dumpjson', default=False,
729 help='Simulate, quiet but print JSON information. See the "OUTPUT TEMPLATE" for a description of available keys.')
730 verbosity.add_option(
731 '-J', '--dump-single-json',
732 action='store_true', dest='dump_single_json', default=False,
733 help=(
734 'Simulate, quiet but print JSON information for each command-line argument.'
735 'If the URL refers to a playlist, dump the whole playlist information in a single line.'))
736 verbosity.add_option(
737 '--print-json',
738 action='store_true', dest='print_json', default=False,
739 help='Be quiet and print the video information as JSON (video is still being downloaded).')
740 verbosity.add_option(
741 '--force-write-download-archive', '--force-write-archive', '--force-download-archive',
742 action='store_true', dest='force_write_download_archive', default=False,
743 help=(
744 'Force download archive entries to be written as far as no errors occur,'
745 'even if -s or another simulation switch is used.'))
746 verbosity.add_option(
747 '--newline',
748 action='store_true', dest='progress_with_newline', default=False,
749 help='Output progress bar as new lines')
750 verbosity.add_option(
751 '--no-progress',
752 action='store_true', dest='noprogress', default=False,
753 help='Do not print progress bar')
754 verbosity.add_option(
755 '--console-title',
756 action='store_true', dest='consoletitle', default=False,
757 help='Display progress in console titlebar')
758 verbosity.add_option(
759 '-v', '--verbose',
760 action='store_true', dest='verbose', default=False,
761 help='Print various debugging information')
762 verbosity.add_option(
763 '--dump-pages', '--dump-intermediate-pages',
764 action='store_true', dest='dump_intermediate_pages', default=False,
765 help='Print downloaded pages encoded using base64 to debug problems (very verbose)')
766 verbosity.add_option(
767 '--write-pages',
768 action='store_true', dest='write_pages', default=False,
769 help='Write downloaded intermediary pages to files in the current directory to debug problems')
770 verbosity.add_option(
771 '--youtube-print-sig-code',
772 action='store_true', dest='youtube_print_sig_code', default=False,
773 help=optparse.SUPPRESS_HELP)
774 verbosity.add_option(
775 '--print-traffic', '--dump-headers',
776 dest='debug_printtraffic', action='store_true', default=False,
777 help='Display sent and read HTTP traffic')
778 verbosity.add_option(
779 '-C', '--call-home',
780 dest='call_home', action='store_true', default=False,
781 help='Contact the youtube-dlc server for debugging')
782 verbosity.add_option(
783 '--no-call-home',
784 dest='call_home', action='store_false',
785 help='Do not contact the youtube-dlc server for debugging (default)')
786
787 filesystem = optparse.OptionGroup(parser, 'Filesystem Options')
788 filesystem.add_option(
789 '-a', '--batch-file',
790 dest='batchfile', metavar='FILE',
791 help="File containing URLs to download ('-' for stdin), one URL per line. "
792 "Lines starting with '#', ';' or ']' are considered as comments and ignored.")
793 filesystem.add_option(
794 '--id', default=False,
795 action='store_true', dest='useid', help=optparse.SUPPRESS_HELP)
796 filesystem.add_option(
797 '-o', '--output',
798 dest='outtmpl', metavar='TEMPLATE',
799 help='Output filename template, see the "OUTPUT TEMPLATE" for details')
800 filesystem.add_option(
801 '--autonumber-size',
802 dest='autonumber_size', metavar='NUMBER', type=int,
803 help=optparse.SUPPRESS_HELP)
804 filesystem.add_option(
805 '--autonumber-start',
806 dest='autonumber_start', metavar='NUMBER', default=1, type=int,
807 help='Specify the start value for %(autonumber)s (default is %default)')
808 filesystem.add_option(
809 '--restrict-filenames',
810 action='store_true', dest='restrictfilenames', default=False,
811 help='Restrict filenames to only ASCII characters, and avoid "&" and spaces in filenames')
812 filesystem.add_option(
813 '--no-restrict-filenames',
814 action='store_false', dest='restrictfilenames', default=False,
815 help='Allow Unicode characters, "&" and spaces in filenames (default)')
816 filesystem.add_option(
817 '-A', '--auto-number',
818 action='store_true', dest='autonumber', default=False,
819 help=optparse.SUPPRESS_HELP)
820 filesystem.add_option(
821 '-t', '--title',
822 action='store_true', dest='usetitle', default=False,
823 help=optparse.SUPPRESS_HELP)
824 filesystem.add_option(
825 '-l', '--literal', default=False,
826 action='store_true', dest='usetitle',
827 help=optparse.SUPPRESS_HELP)
828 filesystem.add_option(
829 '-w', '--no-overwrites',
830 action='store_true', dest='nooverwrites', default=False,
831 help='Do not overwrite files')
832 filesystem.add_option(
833 '-c', '--continue',
834 action='store_true', dest='continue_dl', default=True,
835 help='Resume partially downloaded files (default)')
836 filesystem.add_option(
837 '--no-continue',
838 action='store_false', dest='continue_dl',
839 help='Restart download of partially downloaded files from beginning')
840 filesystem.add_option(
841 '--part',
842 action='store_false', dest='nopart', default=False,
843 help='Use .part files instead of writing directly into output file (default)')
844 filesystem.add_option(
845 '--no-part',
846 action='store_true', dest='nopart',
847 help='Do not use .part files - write directly into output file')
848 filesystem.add_option(
849 '--mtime',
850 action='store_true', dest='updatetime', default=True,
851 help='Use the Last-modified header to set the file modification time (default)')
852 filesystem.add_option(
853 '--no-mtime',
854 action='store_false', dest='updatetime',
855 help='Do not use the Last-modified header to set the file modification time')
856 filesystem.add_option(
857 '--write-description',
858 action='store_true', dest='writedescription', default=False,
859 help='Write video description to a .description file')
860 filesystem.add_option(
861 '--no-write-description',
862 action='store_false', dest='writedescription',
863 help='Do not write video description (default)')
864 filesystem.add_option(
865 '--write-info-json',
866 action='store_true', dest='writeinfojson', default=False,
867 help='Write video metadata to a .info.json file')
868 filesystem.add_option(
869 '--no-write-info-json',
870 action='store_false', dest='writeinfojson',
871 help='Do not write video metadata (default)')
872 filesystem.add_option(
873 '--write-annotations',
874 action='store_true', dest='writeannotations', default=False,
875 help='Write video annotations to a .annotations.xml file')
876 filesystem.add_option(
877 '--no-write-annotations',
878 action='store_false', dest='writeannotations',
879 help='Do not write video annotations (default)')
880 filesystem.add_option(
881 '--load-info-json', '--load-info',
882 dest='load_info_filename', metavar='FILE',
883 help='JSON file containing the video information (created with the "--write-info-json" option)')
884 filesystem.add_option(
885 '--cookies',
886 dest='cookiefile', metavar='FILE',
887 help='File to read cookies from and dump cookie jar in')
888 filesystem.add_option(
889 '--no-cookies',
890 action='store_const', const=None, dest='cookiefile', metavar='FILE',
891 help='Do not read/dump cookies (default)')
892 filesystem.add_option(
893 '--cache-dir', dest='cachedir', default=None, metavar='DIR',
894 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.')
895 filesystem.add_option(
896 '--no-cache-dir', action='store_false', dest='cachedir',
897 help='Disable filesystem caching')
898 filesystem.add_option(
899 '--rm-cache-dir',
900 action='store_true', dest='rm_cachedir',
901 help='Delete all filesystem cache files')
902 filesystem.add_option(
903 '--trim-file-name', dest='trim_file_name', default=0, type=int,
904 help='Limit the filename length (extension excluded)')
905
906 thumbnail = optparse.OptionGroup(parser, 'Thumbnail Images')
907 thumbnail.add_option(
908 '--write-thumbnail',
909 action='store_true', dest='writethumbnail', default=False,
910 help='Write thumbnail image to disk')
911 thumbnail.add_option(
912 '--no-write-thumbnail',
913 action='store_false', dest='writethumbnail',
914 help='Do not write thumbnail image to disk (default)')
915 thumbnail.add_option(
916 '--write-all-thumbnails',
917 action='store_true', dest='write_all_thumbnails', default=False,
918 help='Write all thumbnail image formats to disk')
919 thumbnail.add_option(
920 '--list-thumbnails',
921 action='store_true', dest='list_thumbnails', default=False,
922 help='Simulate and list all available thumbnail formats')
923
924 link = optparse.OptionGroup(parser, 'Internet Shortcut Options')
925 link.add_option(
926 '--write-link',
927 action='store_true', dest='writelink', default=False,
928 help='Write an internet shortcut file, depending on the current platform (.url/.webloc/.desktop). The URL may be cached by the OS.')
929 link.add_option(
930 '--write-url-link',
931 action='store_true', dest='writeurllink', default=False,
932 help='Write a Windows internet shortcut file (.url). Note that the OS caches the URL based on the file path.')
933 link.add_option(
934 '--write-webloc-link',
935 action='store_true', dest='writewebloclink', default=False,
936 help='Write a macOS internet shortcut file (.webloc)')
937 link.add_option(
938 '--write-desktop-link',
939 action='store_true', dest='writedesktoplink', default=False,
940 help='Write a Linux internet shortcut file (.desktop)')
941
942 postproc = optparse.OptionGroup(parser, 'Post-Processing Options')
943 postproc.add_option(
944 '-x', '--extract-audio',
945 action='store_true', dest='extractaudio', default=False,
946 help='Convert video files to audio-only files (requires ffmpeg or avconv and ffprobe or avprobe)')
947 postproc.add_option(
948 '--audio-format', metavar='FORMAT', dest='audioformat', default='best',
949 help='Specify audio format: "best", "aac", "flac", "mp3", "m4a", "opus", "vorbis", or "wav"; "%default" by default; No effect without -x')
950 postproc.add_option(
951 '--audio-quality', metavar='QUALITY',
952 dest='audioquality', default='5',
953 help='Specify ffmpeg/avconv audio quality, insert a value between 0 (better) and 9 (worse) for VBR or a specific bitrate like 128K (default %default)')
954 postproc.add_option(
955 '--remux-video',
956 metavar='FORMAT', dest='remuxvideo', default=None,
957 help=(
958 'Remux the video into another container if necessary (currently supported: mp4|mkv). '
959 'If target container does not support the video/audio codec, remuxing will fail'))
960 postproc.add_option(
961 '--recode-video',
962 metavar='FORMAT', dest='recodevideo', default=None,
963 help='Re-encode the video into another format if re-encoding is necessary (currently supported: mp4|flv|ogg|webm|mkv|avi)')
964 postproc.add_option(
965 '--postprocessor-args',
966 dest='postprocessor_args', metavar='ARGS',
967 help='Give these arguments to the postprocessor')
968 postproc.add_option(
969 '-k', '--keep-video',
970 action='store_true', dest='keepvideo', default=False,
971 help='Keep the intermediate video file on disk after post-processing')
972 postproc.add_option(
973 '--no-keep-video',
974 action='store_false', dest='keepvideo',
975 help='Delete the intermediate video file after post-processing (default)')
976 postproc.add_option(
977 '--post-overwrites',
978 action='store_false', dest='nopostoverwrites',
979 help='Overwrite post-processed files (default)')
980 postproc.add_option(
981 '--no-post-overwrites',
982 action='store_true', dest='nopostoverwrites', default=False,
983 help='Do not overwrite post-processed files')
984 postproc.add_option(
985 '--embed-subs',
986 action='store_true', dest='embedsubtitles', default=False,
987 help='Embed subtitles in the video (only for mp4, webm and mkv videos)')
988 postproc.add_option(
989 '--no-embed-subs',
990 action='store_false', dest='embedsubtitles',
991 help='Do not embed subtitles (default)')
992 postproc.add_option(
993 '--embed-thumbnail',
994 action='store_true', dest='embedthumbnail', default=False,
995 help='Embed thumbnail in the audio as cover art')
996 postproc.add_option(
997 '--no-embed-thumbnail',
998 action='store_false', dest='embedthumbnail',
999 help='Do not embed thumbnail (default)')
1000 postproc.add_option(
1001 '--add-metadata',
1002 action='store_true', dest='addmetadata', default=False,
1003 help='Write metadata to the video file')
1004 postproc.add_option(
1005 '--no-add-metadata',
1006 action='store_false', dest='addmetadata',
1007 help='Do not write metadata (default)')
1008 postproc.add_option(
1009 '--metadata-from-title',
1010 metavar='FORMAT', dest='metafromtitle',
1011 help=(
1012 'Parse additional metadata like song title / artist from the video title. '
1013 'The format syntax is the same as --output. Regular expression with '
1014 'named capture groups may also be used. '
1015 'The parsed parameters replace existing values. '
1016 'Example: --metadata-from-title "%(artist)s - %(title)s" matches a title like '
1017 '"Coldplay - Paradise". '
1018 'Example (regex): --metadata-from-title "(?P<artist>.+?) - (?P<title>.+)"'))
1019 postproc.add_option(
1020 '--xattrs',
1021 action='store_true', dest='xattrs', default=False,
1022 help='Write metadata to the video file\'s xattrs (using dublin core and xdg standards)')
1023 postproc.add_option(
1024 '--fixup',
1025 metavar='POLICY', dest='fixup', default='detect_or_warn',
1026 help=(
1027 'Automatically correct known faults of the file. '
1028 'One of never (do nothing), warn (only emit a warning), '
1029 'detect_or_warn (the default; fix file if we can, warn otherwise)'))
1030 postproc.add_option(
1031 '--prefer-avconv', '--no-prefer-ffmpeg',
1032 action='store_false', dest='prefer_ffmpeg',
1033 help='Prefer avconv over ffmpeg for running the postprocessors')
1034 postproc.add_option(
1035 '--prefer-ffmpeg', '--no-prefer-avconv',
1036 action='store_true', dest='prefer_ffmpeg',
1037 help='Prefer ffmpeg over avconv for running the postprocessors (default)')
1038 postproc.add_option(
1039 '--ffmpeg-location', '--avconv-location', metavar='PATH',
1040 dest='ffmpeg_location',
1041 help='Location of the ffmpeg/avconv binary; either the path to the binary or its containing directory.')
1042 postproc.add_option(
1043 '--exec',
1044 metavar='CMD', dest='exec_cmd',
1045 help='Execute a command on the file after downloading and post-processing, similar to find\'s -exec syntax. Example: --exec \'adb push {} /sdcard/Music/ && rm {}\'')
1046 postproc.add_option(
1047 '--convert-subs', '--convert-subtitles',
1048 metavar='FORMAT', dest='convertsubtitles', default=None,
1049 help='Convert the subtitles to other format (currently supported: srt|ass|vtt|lrc)')
1050
1051 extractor = optparse.OptionGroup(parser, 'SponSkrub Options (SponsorBlock)')
1052 extractor.add_option(
1053 '--sponskrub',
1054 action='store_true', dest='sponskrub', default=None,
1055 help=(
1056 'Use sponskrub to mark sponsored sections with the data available in SponsorBlock API. '
1057 'This is enabled by default if the sponskrub binary exists (Youtube only)'))
1058 extractor.add_option(
1059 '--no-sponskrub',
1060 action='store_false', dest='sponskrub',
1061 help='Do not use sponskrub')
1062 extractor.add_option(
1063 '--sponskrub-cut', default=False,
1064 action='store_true', dest='sponskrub_cut',
1065 help='Cut out the sponsor sections instead of simply marking them')
1066 extractor.add_option(
1067 '--no-sponskrub-cut',
1068 action='store_false', dest='sponskrub_cut',
1069 help='Simply mark the sponsor sections, not cut them out (default)')
1070 extractor.add_option(
1071 '--sponskrub-force', default=False,
1072 action='store_true', dest='sponskrub_force',
1073 help='Run sponskrub even if the video was already downloaded')
1074 extractor.add_option(
1075 '--no-sponskrub-force',
1076 action='store_true', dest='sponskrub_force',
1077 help='Do not cut out the sponsor sections if the video was already downloaded (default)')
1078 extractor.add_option(
1079 '--sponskrub-location', metavar='PATH',
1080 dest='sponskrub_path', default='',
1081 help='Location of the sponskrub binary; either the path to the binary or its containing directory.')
1082 extractor.add_option(
1083 '--sponskrub-args', dest='sponskrub_args',
1084 help='Give these arguments to sponskrub')
1085
1086 extractor = optparse.OptionGroup(parser, 'Extractor Options')
1087 extractor.add_option(
1088 '--allow-dynamic-mpd', '--no-ignore-dynamic-mpd',
1089 action='store_true', dest='dynamic_mpd', default=True,
1090 help='Process dynamic DASH manifests (default)')
1091 extractor.add_option(
1092 '--ignore-dynamic-mpd', '--no-allow-dynamic-mpd',
1093 action='store_false', dest='dynamic_mpd',
1094 help='Do not process dynamic DASH manifests')
1095
1096 parser.add_option_group(general)
1097 parser.add_option_group(network)
1098 parser.add_option_group(geo)
1099 parser.add_option_group(selection)
1100 parser.add_option_group(downloader)
1101 parser.add_option_group(filesystem)
1102 parser.add_option_group(thumbnail)
1103 parser.add_option_group(link)
1104 parser.add_option_group(verbosity)
1105 parser.add_option_group(workarounds)
1106 parser.add_option_group(video_format)
1107 parser.add_option_group(subtitles)
1108 parser.add_option_group(authentication)
1109 parser.add_option_group(adobe_pass)
1110 parser.add_option_group(postproc)
1111 parser.add_option_group(extractor)
1112
1113 if overrideArguments is not None:
1114 opts, args = parser.parse_args(overrideArguments)
1115 if opts.verbose:
1116 write_string('[debug] Override config: ' + repr(overrideArguments) + '\n')
1117 else:
1118 def compat_conf(conf):
1119 if sys.version_info < (3,):
1120 return [a.decode(preferredencoding(), 'replace') for a in conf]
1121 return conf
1122
1123 command_line_conf = compat_conf(sys.argv[1:])
1124 opts, args = parser.parse_args(command_line_conf)
1125
1126 system_conf = user_conf = custom_conf = []
1127
1128 if '--config-location' in command_line_conf:
1129 location = compat_expanduser(opts.config_location)
1130 if os.path.isdir(location):
1131 location = os.path.join(location, 'youtube-dlc.conf')
1132 if not os.path.exists(location):
1133 parser.error('config-location %s does not exist.' % location)
1134 custom_conf = _readOptions(location)
1135 elif '--ignore-config' in command_line_conf:
1136 pass
1137 else:
1138 system_conf = _readOptions('/etc/youtube-dlc.conf')
1139 if '--ignore-config' not in system_conf:
1140 user_conf = _readUserConf()
1141
1142 argv = system_conf + user_conf + custom_conf + command_line_conf
1143 opts, args = parser.parse_args(argv)
1144 if opts.verbose:
1145 for conf_label, conf in (
1146 ('System config', system_conf),
1147 ('User config', user_conf),
1148 ('Custom config', custom_conf),
1149 ('Command-line args', command_line_conf)):
1150 write_string('[debug] %s: %s\n' % (conf_label, repr(_hide_login_info(conf))))
1151
1152 return parser, opts, args