11 from .compat
import compat_expanduser
12 from .cookies
import SUPPORTED_BROWSERS
, SUPPORTED_KEYRINGS
13 from .downloader
.external
import list_external_downloaders
14 from .postprocessor
import (
17 FFmpegSubtitlesConvertorPP
,
18 FFmpegThumbnailsConvertorPP
,
22 from .postprocessor
.modify_chapters
import DEFAULT_SPONSORBLOCK_CHAPTER_TITLE
23 from .update
import detect_variant
, is_non_updateable
33 orderedSet_from_options
,
37 from .version
import __version__
40 def parseOpts(overrideArguments
=None, ignore_config_files
='if_override'):
41 root
= Config(create_parser())
42 if ignore_config_files
== 'if_override':
43 ignore_config_files
= overrideArguments
is not None
45 def _readUserConf(package_name
, default
=[]):
47 xdg_config_home
= os
.getenv('XDG_CONFIG_HOME') or compat_expanduser('~/.config')
48 userConfFile
= os
.path
.join(xdg_config_home
, package_name
, 'config')
49 if not os
.path
.isfile(userConfFile
):
50 userConfFile
= os
.path
.join(xdg_config_home
, '%s.conf' % package_name
)
51 userConf
= Config
.read_file(userConfFile
, default
=None)
52 if userConf
is not None:
53 return userConf
, userConfFile
56 appdata_dir
= os
.getenv('appdata')
58 userConfFile
= os
.path
.join(appdata_dir
, package_name
, 'config')
59 userConf
= Config
.read_file(userConfFile
, default
=None)
61 userConfFile
+= '.txt'
62 userConf
= Config
.read_file(userConfFile
, default
=None)
63 if userConf
is not None:
64 return userConf
, userConfFile
67 userConfFile
= os
.path
.join(compat_expanduser('~'), '%s.conf' % package_name
)
68 userConf
= Config
.read_file(userConfFile
, default
=None)
70 userConfFile
+= '.txt'
71 userConf
= Config
.read_file(userConfFile
, default
=None)
72 if userConf
is not None:
73 return userConf
, userConfFile
77 def add_config(label
, path
, user
=False):
78 """ Adds config and returns whether to continue """
79 if root
.parse_known_args()[0].ignoreconfig
:
81 # Multiple package names can be given here
82 # E.g. ('yt-dlp', 'youtube-dlc', 'youtube-dl') will look for
83 # the configuration file of any of these three packages
84 for package
in ('yt-dlp',):
86 args
, current_path
= _readUserConf(package
, default
=None)
88 current_path
= os
.path
.join(path
, '%s.conf' % package
)
89 args
= Config
.read_file(current_path
, default
=None)
91 root
.append_config(args
, current_path
, label
=label
)
96 yield not ignore_config_files
97 yield add_config('Portable', get_executable_path())
98 yield add_config('Home', expand_path(root
.parse_known_args()[0].paths
.get('home', '')).strip())
99 yield add_config('User', None, user
=True)
100 yield add_config('System', '/etc')
102 opts
= optparse
.Values({'verbose': True, 'print_help': False}
)
105 if overrideArguments
:
106 root
.append_config(overrideArguments
, label
='Override')
108 root
.append_config(sys
.argv
[1:], label
='Command-line')
109 loaded_all_configs
= all(load_configs())
110 except ValueError as err
:
111 raise root
.parser
.error(err
)
113 if loaded_all_configs
:
114 # If ignoreconfig is found inside the system configuration file,
115 # the user configuration is removed
116 if root
.parse_known_args()[0].ignoreconfig
:
117 user_conf
= next((i
for i
, conf
in enumerate(root
.configs
) if conf
.label
== 'User'), None)
118 if user_conf
is not None:
119 root
.configs
.pop(user_conf
)
122 root
.configs
[0].load_configs() # Resolve any aliases using --config-location
123 except ValueError as err
:
124 raise root
.parser
.error(err
)
126 opts
, args
= root
.parse_args()
127 except optparse
.OptParseError
:
128 with contextlib
.suppress(optparse
.OptParseError
):
129 opts
, _
= root
.parse_known_args(strict
=False)
131 except (SystemExit, KeyboardInterrupt):
135 verbose
= opts
.verbose
and f
'\n{root}'.replace('\n| ', '\n[debug] ')[1:]
137 write_string(f
'{verbose}\n')
141 root
.parser
.print_help()
144 return root
.parser
, opts
, args
147 class _YoutubeDLHelpFormatter(optparse
.IndentedHelpFormatter
):
149 # No need to wrap help messages if we're on a wide console
150 max_width
= shutil
.get_terminal_size().columns
or 80
151 # The % is chosen to get a pretty output in README.md
152 super().__init
__(width
=max_width
, max_help_position
=int(0.45 * max_width
))
155 def format_option_strings(option
):
156 """ ('-o', '--option') -> -o, --format METAVAR """
157 opts
= join_nonempty(
158 option
._short
_opts
and option
._short
_opts
[0],
159 option
._long
_opts
and option
._long
_opts
[0],
161 if option
.takes_value():
162 opts
+= f
' {option.metavar}'
166 class _YoutubeDLOptionParser(optparse
.OptionParser
):
167 # optparse is deprecated since python 3.2. So assume a stable interface even for private methods
168 ALIAS_DEST
= '_triggered_aliases'
169 ALIAS_TRIGGER_LIMIT
= 100
173 prog
='yt-dlp' if detect_variant() == 'source' else None,
175 usage
='%prog [OPTIONS] URL [URL...]',
176 epilog
='See full documentation at https://github.com/yt-dlp/yt-dlp#readme',
177 formatter
=_YoutubeDLHelpFormatter(),
178 conflict_handler
='resolve',
180 self
.set_default(self
.ALIAS_DEST
, collections
.defaultdict(int))
182 _UNKNOWN_OPTION
= (optparse
.BadOptionError
, optparse
.AmbiguousOptionError
)
183 _BAD_OPTION
= optparse
.OptionValueError
185 def parse_known_args(self
, args
=None, values
=None, strict
=True):
186 """Same as parse_args, but ignore unknown switches. Similar to argparse.parse_known_args"""
187 self
.rargs
, self
.largs
= self
._get
_args
(args
), []
188 self
.values
= values
or self
.get_default_values()
195 elif arg
.startswith('--'):
196 self
._process
_long
_opt
(self
.rargs
, self
.values
)
197 elif arg
.startswith('-') and arg
!= '-':
198 self
._process
_short
_opts
(self
.rargs
, self
.values
)
199 elif self
.allow_interspersed_args
:
200 self
.largs
.append(self
.rargs
.pop(0))
203 except optparse
.OptParseError
as err
:
204 if isinstance(err
, self
._UNKNOWN
_OPTION
):
205 self
.largs
.append(err
.opt_str
)
207 if isinstance(err
, self
._BAD
_OPTION
):
210 return self
.check_values(self
.values
, self
.largs
)
212 def error(self
, msg
):
213 msg
= f
'{self.get_prog_name()}: error: {str(msg).strip()}\n'
214 raise optparse
.OptParseError(f
'{self.get_usage()}\n{msg}' if self
.usage
else msg
)
216 def _get_args(self
, args
):
217 return sys
.argv
[1:] if args
is None else list(args
)
219 def _match_long_opt(self
, opt
):
220 """Improve ambiguous argument resolution by comparing option objects instead of argument strings"""
222 return super()._match
_long
_opt
(opt
)
223 except optparse
.AmbiguousOptionError
as e
:
224 if len({self._long_opt[p] for p in e.possibilities}
) == 1:
225 return e
.possibilities
[0]
230 def _list_from_options_callback(option
, opt_str
, value
, parser
, append
=True, delim
=',', process
=str.strip
):
231 # append can be True, False or -1 (prepend)
232 current
= list(getattr(parser
.values
, option
.dest
)) if append
else []
233 value
= list(filter(None, [process(value
)] if delim
is None else map(process
, value
.split(delim
))))
235 parser
.values
, option
.dest
,
236 current
+ value
if append
is True else value
+ current
)
238 def _set_from_options_callback(
239 option
, opt_str
, value
, parser
, allowed_values
, delim
=',', aliases
={},
240 process
=lambda x
: x
.lower().strip()):
241 values
= [process(value
)] if delim
is None else map(process
, value
.split(delim
))
243 requested
= orderedSet_from_options(values
, collections
.ChainMap(aliases
, {'all': allowed_values}
),
244 start
=getattr(parser
.values
, option
.dest
))
245 except ValueError as e
:
246 raise optparse
.OptionValueError(f
'wrong {option.metavar} for {opt_str}: {e.args[0]}')
248 setattr(parser
.values
, option
.dest
, set(requested
))
250 def _dict_from_options_callback(
251 option
, opt_str
, value
, parser
,
252 allowed_keys
=r
'[\w-]+', delimiter
=':', default_key
=None, process
=None, multiple_keys
=True,
253 process_key
=str.lower
, append
=False):
255 out_dict
= dict(getattr(parser
.values
, option
.dest
))
256 multiple_args
= not isinstance(value
, str)
258 allowed_keys
= fr
'({allowed_keys})(,({allowed_keys}))*'
260 fr
'(?i)(?P<keys>{allowed_keys}){delimiter}(?P<val>.*)$',
261 value
[0] if multiple_args
else value
)
263 keys
, val
= mobj
.group('keys').split(','), mobj
.group('val')
265 val
= [val
, *value
[1:]]
266 elif default_key
is not None:
267 keys
, val
= [default_key
], value
269 raise optparse
.OptionValueError(
270 f
'wrong {opt_str} formatting; it should be {option.metavar}, not "{value}"')
272 keys
= map(process_key
, keys
) if process_key
else keys
273 val
= process(val
) if process
else val
274 except Exception as err
:
275 raise optparse
.OptionValueError(f
'wrong {opt_str} formatting; {err}')
277 out_dict
[key
] = out_dict
.get(key
, []) + [val
] if append
else val
278 setattr(parser
.values
, option
.dest
, out_dict
)
280 def when_prefix(default
):
284 'action': 'callback',
285 'callback': _dict_from_options_callback
,
287 'allowed_keys': '|'.join(map(re
.escape
, POSTPROCESS_WHEN
)),
288 'default_key': default
,
289 'multiple_keys': False,
294 parser
= _YoutubeDLOptionParser()
295 alias_group
= optparse
.OptionGroup(parser
, 'Aliases')
296 Formatter
= string
.Formatter()
298 def _create_alias(option
, opt_str
, value
, parser
):
299 aliases
, opts
= value
301 nargs
= len({i
if f
== '' else f
302 for i
, (_
, f
, _
, _
) in enumerate(Formatter
.parse(opts
)) if f
is not None})
303 opts
.format(*map(str, range(nargs
))) # validate
304 except Exception as err
:
305 raise optparse
.OptionValueError(f
'wrong {opt_str} OPTIONS formatting; {err}')
306 if alias_group
not in parser
.option_groups
:
307 parser
.add_option_group(alias_group
)
309 aliases
= (x
if x
.startswith('-') else f
'--{x}' for x
in map(str.strip
, aliases
.split(',')))
311 args
= [f
'ARG{i}' for i
in range(nargs
)]
312 alias_group
.add_option(
313 *aliases
, nargs
=nargs
, dest
=parser
.ALIAS_DEST
, type='str' if nargs
else None,
314 metavar
=' '.join(args
), help=opts
.format(*args
), action
='callback',
315 callback
=_alias_callback
, callback_kwargs
={'opts': opts, 'nargs': nargs}
)
316 except Exception as err
:
317 raise optparse
.OptionValueError(f
'wrong {opt_str} formatting; {err}')
319 def _alias_callback(option
, opt_str
, value
, parser
, opts
, nargs
):
320 counter
= getattr(parser
.values
, option
.dest
)
321 counter
[opt_str
] += 1
322 if counter
[opt_str
] > parser
.ALIAS_TRIGGER_LIMIT
:
323 raise optparse
.OptionValueError(f
'Alias {opt_str} exceeded invocation limit')
326 assert (nargs
== 0 and value
is None) or len(value
) == nargs
327 parser
.rargs
[:0] = shlex
.split(
328 opts
if value
is None else opts
.format(*map(shlex
.quote
, value
)))
330 general
= optparse
.OptionGroup(parser
, 'General Options')
332 '-h', '--help', dest
='print_help', action
='store_true',
333 help='Print this help text and exit')
337 help='Print program version and exit')
340 action
='store_true', dest
='update_self',
342 is_non_updateable(), None, 'Check if updates are available. %s',
343 default
='Update this program to the latest version'))
346 action
='store_false', dest
='update_self',
347 help='Do not check for updates (default)')
349 '-i', '--ignore-errors',
350 action
='store_true', dest
='ignoreerrors',
351 help='Ignore download and postprocessing errors. The download will be considered successful even if the postprocessing fails')
353 '--no-abort-on-error',
354 action
='store_const', dest
='ignoreerrors', const
='only_download',
355 help='Continue with next video on download errors; e.g. to skip unavailable videos in a playlist (default)')
357 '--abort-on-error', '--no-ignore-errors',
358 action
='store_false', dest
='ignoreerrors',
359 help='Abort downloading of further videos if an error occurs (Alias: --no-ignore-errors)')
362 action
='store_true', dest
='dump_user_agent', default
=False,
363 help='Display the current user-agent and exit')
366 action
='store_true', dest
='list_extractors', default
=False,
367 help='List all supported extractors and exit')
369 '--extractor-descriptions',
370 action
='store_true', dest
='list_extractor_descriptions', default
=False,
371 help='Output descriptions of all supported extractors and exit')
373 '--use-extractors', '--ies',
374 action
='callback', dest
='allowed_extractors', metavar
='NAMES', type='str',
375 default
=[], callback
=_list_from_options_callback
,
377 'Extractor names to use separated by commas. '
378 'You can also use regexes, "all", "default" and "end" (end URL matching); '
379 'e.g. --ies "holodex.*,end,youtube". '
380 'Prefix the name with a "-" to exclude it, e.g. --ies default,-generic. '
381 'Use --list-extractors for a list of extractor names. (Alias: --ies)'))
383 '--force-generic-extractor',
384 action
='store_true', dest
='force_generic_extractor', default
=False,
385 help=optparse
.SUPPRESS_HELP
)
388 dest
='default_search', metavar
='PREFIX',
390 'Use this prefix for unqualified URLs. '
391 'E.g. "gvsearch2:python" downloads two videos from google videos for the search term "python". '
392 'Use the value "auto" to let yt-dlp guess ("auto_warning" to emit a warning when guessing). '
393 '"error" just throws an error. The default value "fixup_error" repairs broken URLs, '
394 'but emits an error if this is not possible instead of searching'))
396 '--ignore-config', '--no-config',
397 action
='store_true', dest
='ignoreconfig',
399 'Don\'t load any more configuration files except those given by --config-locations. '
400 'For backward compatibility, if this option is found inside the system configuration file, the user configuration is not loaded. '
401 '(Alias: --no-config)'))
403 '--no-config-locations',
404 action
='store_const', dest
='config_locations', const
=[],
406 'Do not load any custom configuration files (default). When given inside a '
407 'configuration file, ignore all previous --config-locations defined in the current file'))
409 '--config-locations',
410 dest
='config_locations', metavar
='PATH', action
='append',
412 'Location of the main configuration file; either the path to the config or its containing directory '
413 '("-" for stdin). Can be used multiple times and inside other configuration files'))
416 action
='store_const', dest
='extract_flat', const
='in_playlist', default
=False,
417 help='Do not extract the videos of a playlist, only list them')
419 '--no-flat-playlist',
420 action
='store_false', dest
='extract_flat',
421 help='Extract the videos of a playlist')
424 action
='store_true', dest
='live_from_start',
425 help='Download livestreams from the start. Currently only supported for YouTube (Experimental)')
427 '--no-live-from-start',
428 action
='store_false', dest
='live_from_start',
429 help='Download livestreams from the current time (default)')
432 dest
='wait_for_video', metavar
='MIN[-MAX]', default
=None,
434 'Wait for scheduled streams to become available. '
435 'Pass the minimum number of seconds (or range) to wait between retries'))
437 '--no-wait-for-video',
438 dest
='wait_for_video', action
='store_const', const
=None,
439 help='Do not wait for scheduled streams (default)')
442 action
='store_true', dest
='mark_watched', default
=False,
443 help='Mark videos watched (even with --simulate)')
446 action
='store_false', dest
='mark_watched',
447 help='Do not mark videos watched (default)')
449 '--no-colors', '--no-colours',
450 action
='store_true', dest
='no_color', default
=False,
451 help='Do not emit color codes in output (Alias: --no-colours)')
454 metavar
='OPTS', dest
='compat_opts', default
=set(), type='str',
455 action
='callback', callback
=_set_from_options_callback
,
458 'filename', 'filename-sanitization', 'format-sort', 'abort-on-error', 'format-spec', 'no-playlist-metafiles',
459 'multistreams', 'no-live-chat', 'playlist-index', 'list-formats', 'no-direct-merge',
460 'no-attach-info-json', 'embed-metadata', 'embed-thumbnail-atomicparsley',
461 'seperate-video-versions', 'no-clean-infojson', 'no-keep-subs', 'no-certifi',
462 'no-youtube-channel-redirect', 'no-youtube-unavailable-videos', 'no-youtube-prefer-utc-upload-date',
464 'youtube-dl': ['all', '-multistreams'],
465 'youtube-dlc': ['all', '-no-youtube-channel-redirect', '-no-live-chat'],
468 'Options that can help keep compatibility with youtube-dl or youtube-dlc '
469 'configurations by reverting some of the changes made in yt-dlp. '
470 'See "Differences in default behavior" for details'))
472 '--alias', metavar
='ALIASES OPTIONS', dest
='_', type='str', nargs
=2,
473 action
='callback', callback
=_create_alias
,
475 'Create aliases for an option string. Unless an alias starts with a dash "-", it is prefixed with "--". '
476 'Arguments are parsed according to the Python string formatting mini-language. '
477 'E.g. --alias get-audio,-X "-S=aext:{0},abr -x --audio-format {0}" creates options '
478 '"--get-audio" and "-X" that takes an argument (ARG0) and expands to '
479 '"-S=aext:ARG0,abr -x --audio-format ARG0". All defined aliases are listed in the --help output. '
480 'Alias options can trigger more aliases; so be careful to avoid defining recursive options. '
481 f
'As a safety measure, each alias may be triggered a maximum of {_YoutubeDLOptionParser.ALIAS_TRIGGER_LIMIT} times. '
482 'This option can be used multiple times'))
484 network
= optparse
.OptionGroup(parser
, 'Network Options')
486 '--proxy', dest
='proxy',
487 default
=None, metavar
='URL',
489 'Use the specified HTTP/HTTPS/SOCKS proxy. To enable SOCKS proxy, specify a proper scheme, '
490 'e.g. socks5://user:pass@127.0.0.1:1080/. Pass in an empty string (--proxy "") for direct connection'))
493 dest
='socket_timeout', type=float, default
=None, metavar
='SECONDS',
494 help='Time to wait before giving up, in seconds')
497 metavar
='IP', dest
='source_address', default
=None,
498 help='Client-side IP address to bind to',
501 '-4', '--force-ipv4',
502 action
='store_const', const
='0.0.0.0', dest
='source_address',
503 help='Make all connections via IPv4',
506 '-6', '--force-ipv6',
507 action
='store_const', const
='::', dest
='source_address',
508 help='Make all connections via IPv6',
511 geo
= optparse
.OptionGroup(parser
, 'Geo-restriction')
513 '--geo-verification-proxy',
514 dest
='geo_verification_proxy', default
=None, metavar
='URL',
516 'Use this proxy to verify the IP address for some geo-restricted sites. '
517 'The default proxy specified by --proxy (or none, if the option is not present) is used for the actual downloading'))
519 '--cn-verification-proxy',
520 dest
='cn_verification_proxy', default
=None, metavar
='URL',
521 help=optparse
.SUPPRESS_HELP
)
524 action
='store_true', dest
='geo_bypass', default
=True,
525 help='Bypass geographic restriction via faking X-Forwarded-For HTTP header (default)')
528 action
='store_false', dest
='geo_bypass',
529 help='Do not bypass geographic restriction via faking X-Forwarded-For HTTP header')
531 '--geo-bypass-country', metavar
='CODE',
532 dest
='geo_bypass_country', default
=None,
533 help='Force bypass geographic restriction with explicitly provided two-letter ISO 3166-2 country code')
535 '--geo-bypass-ip-block', metavar
='IP_BLOCK',
536 dest
='geo_bypass_ip_block', default
=None,
537 help='Force bypass geographic restriction with explicitly provided IP block in CIDR notation')
539 selection
= optparse
.OptionGroup(parser
, 'Video Selection')
540 selection
.add_option(
542 dest
='playliststart', metavar
='NUMBER', default
=1, type=int,
543 help=optparse
.SUPPRESS_HELP
)
544 selection
.add_option(
546 dest
='playlistend', metavar
='NUMBER', default
=None, type=int,
547 help=optparse
.SUPPRESS_HELP
)
548 selection
.add_option(
549 '-I', '--playlist-items',
550 dest
='playlist_items', metavar
='ITEM_SPEC', default
=None,
552 'Comma separated playlist_index of the items to download. '
553 'You can specify a range using "[START]:[STOP][:STEP]". For backward compatibility, START-STOP is also supported. '
554 'Use negative indices to count from the right and negative STEP to download in reverse order. '
555 'E.g. "-I 1:3,7,-5::2" used on a playlist of size 15 will download the items at index 1,2,3,7,11,13,15'))
556 selection
.add_option(
558 dest
='matchtitle', metavar
='REGEX',
559 help=optparse
.SUPPRESS_HELP
)
560 selection
.add_option(
562 dest
='rejecttitle', metavar
='REGEX',
563 help=optparse
.SUPPRESS_HELP
)
564 selection
.add_option(
566 metavar
='SIZE', dest
='min_filesize', default
=None,
567 help='Abort download if filesize is smaller than SIZE, e.g. 50k or 44.6M')
568 selection
.add_option(
570 metavar
='SIZE', dest
='max_filesize', default
=None,
571 help='Abort download if filesize is larger than SIZE, e.g. 50k or 44.6M')
572 selection
.add_option(
574 metavar
='DATE', dest
='date', default
=None,
576 'Download only videos uploaded on this date. The date can be "YYYYMMDD" or in the format '
577 '[now|today|yesterday][-N[day|week|month|year]]. E.g. --date today-2weeks'))
578 selection
.add_option(
580 metavar
='DATE', dest
='datebefore', default
=None,
582 'Download only videos uploaded on or before this date. '
583 'The date formats accepted is the same as --date'))
584 selection
.add_option(
586 metavar
='DATE', dest
='dateafter', default
=None,
588 'Download only videos uploaded on or after this date. '
589 'The date formats accepted is the same as --date'))
590 selection
.add_option(
592 metavar
='COUNT', dest
='min_views', default
=None, type=int,
593 help=optparse
.SUPPRESS_HELP
)
594 selection
.add_option(
596 metavar
='COUNT', dest
='max_views', default
=None, type=int,
597 help=optparse
.SUPPRESS_HELP
)
598 selection
.add_option(
600 metavar
='FILTER', dest
='match_filter', action
='append',
602 'Generic video filter. Any "OUTPUT TEMPLATE" field can be compared with a '
603 'number or a string using the operators defined in "Filtering Formats". '
604 'You can also simply specify a field to match if the field is present, '
605 'use "!field" to check if the field is not present, and "&" to check multiple conditions. '
606 'Use a "\\" to escape "&" or quotes if needed. If used multiple times, '
607 'the filter matches if atleast one of the conditions are met. E.g. --match-filter '
608 '!is_live --match-filter "like_count>?100 & description~=\'(?i)\\bcats \\& dogs\\b\'" '
609 'matches only videos that are not live OR those that have a like count more than 100 '
610 '(or the like field is not available) and also has a description '
611 'that contains the phrase "cats & dogs" (caseless). '
612 'Use "--match-filter -" to interactively ask whether to download each video'))
613 selection
.add_option(
615 metavar
='FILTER', dest
='match_filter', action
='store_const', const
=None,
616 help='Do not use generic video filter (default)')
617 selection
.add_option(
619 action
='store_true', dest
='noplaylist', default
=False,
620 help='Download only the video, if the URL refers to a video and a playlist')
621 selection
.add_option(
623 action
='store_false', dest
='noplaylist',
624 help='Download the playlist, if the URL refers to a video and a playlist')
625 selection
.add_option(
627 metavar
='YEARS', dest
='age_limit', default
=None, type=int,
628 help='Download only videos suitable for the given age')
629 selection
.add_option(
630 '--download-archive', metavar
='FILE',
631 dest
='download_archive',
632 help='Download only videos not listed in the archive file. Record the IDs of all downloaded videos in it')
633 selection
.add_option(
634 '--no-download-archive',
635 dest
='download_archive', action
="store_const", const
=None,
636 help='Do not use archive file (default)')
637 selection
.add_option(
639 dest
='max_downloads', metavar
='NUMBER', type=int, default
=None,
640 help='Abort after downloading NUMBER files')
641 selection
.add_option(
642 '--break-on-existing',
643 action
='store_true', dest
='break_on_existing', default
=False,
644 help='Stop the download process when encountering a file that is in the archive')
645 selection
.add_option(
647 action
='store_true', dest
='break_on_reject', default
=False,
648 help='Stop the download process when encountering a file that has been filtered out')
649 selection
.add_option(
651 action
='store_true', dest
='break_per_url', default
=False,
652 help='Alters --max-downloads, --break-on-existing, --break-on-reject, and autonumber to reset per input URL')
653 selection
.add_option(
654 '--no-break-per-input',
655 action
='store_false', dest
='break_per_url',
656 help='--break-on-existing and similar options terminates the entire download queue')
657 selection
.add_option(
658 '--skip-playlist-after-errors', metavar
='N',
659 dest
='skip_playlist_after_errors', default
=None, type=int,
660 help='Number of allowed failures until the rest of the playlist is skipped')
661 selection
.add_option(
663 dest
='include_ads', action
='store_true',
664 help=optparse
.SUPPRESS_HELP
)
665 selection
.add_option(
667 dest
='include_ads', action
='store_false',
668 help=optparse
.SUPPRESS_HELP
)
670 authentication
= optparse
.OptionGroup(parser
, 'Authentication Options')
671 authentication
.add_option(
673 dest
='username', metavar
='USERNAME',
674 help='Login with this account ID')
675 authentication
.add_option(
677 dest
='password', metavar
='PASSWORD',
678 help='Account password. If this option is left out, yt-dlp will ask interactively')
679 authentication
.add_option(
681 dest
='twofactor', metavar
='TWOFACTOR',
682 help='Two-factor authentication code')
683 authentication
.add_option(
685 action
='store_true', dest
='usenetrc', default
=False,
686 help='Use .netrc authentication data')
687 authentication
.add_option(
689 dest
='netrc_location', metavar
='PATH',
690 help='Location of .netrc authentication data; either the path or its containing directory. Defaults to ~/.netrc')
691 authentication
.add_option(
693 dest
='videopassword', metavar
='PASSWORD',
694 help='Video password (vimeo, youku)')
695 authentication
.add_option(
697 dest
='ap_mso', metavar
='MSO',
698 help='Adobe Pass multiple-system operator (TV provider) identifier, use --ap-list-mso for a list of available MSOs')
699 authentication
.add_option(
701 dest
='ap_username', metavar
='USERNAME',
702 help='Multiple-system operator account login')
703 authentication
.add_option(
705 dest
='ap_password', metavar
='PASSWORD',
706 help='Multiple-system operator account password. If this option is left out, yt-dlp will ask interactively')
707 authentication
.add_option(
709 action
='store_true', dest
='ap_list_mso', default
=False,
710 help='List all supported multiple-system operators')
711 authentication
.add_option(
712 '--client-certificate',
713 dest
='client_certificate', metavar
='CERTFILE',
714 help='Path to client certificate file in PEM format. May include the private key')
715 authentication
.add_option(
716 '--client-certificate-key',
717 dest
='client_certificate_key', metavar
='KEYFILE',
718 help='Path to private key file for client certificate')
719 authentication
.add_option(
720 '--client-certificate-password',
721 dest
='client_certificate_password', metavar
='PASSWORD',
722 help='Password for client certificate private key, if encrypted. '
723 'If not provided, and the key is encrypted, yt-dlp will ask interactively')
725 video_format
= optparse
.OptionGroup(parser
, 'Video Format Options')
726 video_format
.add_option(
728 action
='store', dest
='format', metavar
='FORMAT', default
=None,
729 help='Video format code, see "FORMAT SELECTION" for more details')
730 video_format
.add_option(
731 '-S', '--format-sort', metavar
='SORTORDER',
732 dest
='format_sort', default
=[], type='str', action
='callback',
733 callback
=_list_from_options_callback
, callback_kwargs
={'append': -1}
,
734 help='Sort the formats by the fields given, see "Sorting Formats" for more details')
735 video_format
.add_option(
736 '--format-sort-force', '--S-force',
737 action
='store_true', dest
='format_sort_force', metavar
='FORMAT', default
=False,
739 'Force user specified sort order to have precedence over all fields, '
740 'see "Sorting Formats" for more details (Alias: --S-force)'))
741 video_format
.add_option(
742 '--no-format-sort-force',
743 action
='store_false', dest
='format_sort_force', metavar
='FORMAT', default
=False,
744 help='Some fields have precedence over the user specified sort order (default)')
745 video_format
.add_option(
746 '--video-multistreams',
747 action
='store_true', dest
='allow_multiple_video_streams', default
=None,
748 help='Allow multiple video streams to be merged into a single file')
749 video_format
.add_option(
750 '--no-video-multistreams',
751 action
='store_false', dest
='allow_multiple_video_streams',
752 help='Only one video stream is downloaded for each output file (default)')
753 video_format
.add_option(
754 '--audio-multistreams',
755 action
='store_true', dest
='allow_multiple_audio_streams', default
=None,
756 help='Allow multiple audio streams to be merged into a single file')
757 video_format
.add_option(
758 '--no-audio-multistreams',
759 action
='store_false', dest
='allow_multiple_audio_streams',
760 help='Only one audio stream is downloaded for each output file (default)')
761 video_format
.add_option(
763 action
='store_const', dest
='format', const
='all',
764 help=optparse
.SUPPRESS_HELP
)
765 video_format
.add_option(
766 '--prefer-free-formats',
767 action
='store_true', dest
='prefer_free_formats', default
=False,
769 'Prefer video formats with free containers over non-free ones of same quality. '
770 'Use with "-S ext" to strictly prefer free containers irrespective of quality'))
771 video_format
.add_option(
772 '--no-prefer-free-formats',
773 action
='store_false', dest
='prefer_free_formats', default
=False,
774 help="Don't give any special preference to free containers (default)")
775 video_format
.add_option(
777 action
='store_const', const
='selected', dest
='check_formats', default
=None,
778 help='Make sure formats are selected only from those that are actually downloadable')
779 video_format
.add_option(
780 '--check-all-formats',
781 action
='store_true', dest
='check_formats',
782 help='Check all formats for whether they are actually downloadable')
783 video_format
.add_option(
784 '--no-check-formats',
785 action
='store_false', dest
='check_formats',
786 help='Do not check that the formats are actually downloadable')
787 video_format
.add_option(
788 '-F', '--list-formats',
789 action
='store_true', dest
='listformats',
790 help='List available formats of each video. Simulate unless --no-simulate is used')
791 video_format
.add_option(
792 '--list-formats-as-table',
793 action
='store_true', dest
='listformats_table', default
=True,
794 help=optparse
.SUPPRESS_HELP
)
795 video_format
.add_option(
796 '--list-formats-old', '--no-list-formats-as-table',
797 action
='store_false', dest
='listformats_table',
798 help=optparse
.SUPPRESS_HELP
)
799 video_format
.add_option(
800 '--merge-output-format',
801 action
='store', dest
='merge_output_format', metavar
='FORMAT', default
=None,
803 'Containers that may be used when merging formats, separated by "/", e.g. "mp4/mkv". '
804 'Ignored if no merge is required. '
805 f
'(currently supported: {", ".join(sorted(FFmpegMergerPP.SUPPORTED_EXTS))})'))
806 video_format
.add_option(
807 '--allow-unplayable-formats',
808 action
='store_true', dest
='allow_unplayable_formats', default
=False,
809 help=optparse
.SUPPRESS_HELP
)
810 video_format
.add_option(
811 '--no-allow-unplayable-formats',
812 action
='store_false', dest
='allow_unplayable_formats',
813 help=optparse
.SUPPRESS_HELP
)
815 subtitles
= optparse
.OptionGroup(parser
, 'Subtitle Options')
816 subtitles
.add_option(
817 '--write-subs', '--write-srt',
818 action
='store_true', dest
='writesubtitles', default
=False,
819 help='Write subtitle file')
820 subtitles
.add_option(
821 '--no-write-subs', '--no-write-srt',
822 action
='store_false', dest
='writesubtitles',
823 help='Do not write subtitle file (default)')
824 subtitles
.add_option(
825 '--write-auto-subs', '--write-automatic-subs',
826 action
='store_true', dest
='writeautomaticsub', default
=False,
827 help='Write automatically generated subtitle file (Alias: --write-automatic-subs)')
828 subtitles
.add_option(
829 '--no-write-auto-subs', '--no-write-automatic-subs',
830 action
='store_false', dest
='writeautomaticsub', default
=False,
831 help='Do not write auto-generated subtitles (default) (Alias: --no-write-automatic-subs)')
832 subtitles
.add_option(
834 action
='store_true', dest
='allsubtitles', default
=False,
835 help=optparse
.SUPPRESS_HELP
)
836 subtitles
.add_option(
838 action
='store_true', dest
='listsubtitles', default
=False,
839 help='List available subtitles of each video. Simulate unless --no-simulate is used')
840 subtitles
.add_option(
842 action
='store', dest
='subtitlesformat', metavar
='FORMAT', default
='best',
843 help='Subtitle format; accepts formats preference, e.g. "srt" or "ass/srt/best"')
844 subtitles
.add_option(
845 '--sub-langs', '--srt-langs',
846 action
='callback', dest
='subtitleslangs', metavar
='LANGS', type='str',
847 default
=[], callback
=_list_from_options_callback
,
849 'Languages of the subtitles to download (can be regex) or "all" separated by commas, e.g. --sub-langs "en.*,ja". '
850 'You can prefix the language code with a "-" to exclude it from the requested languages, e.g. --sub-langs all,-live_chat. '
851 'Use --list-subs for a list of available language tags'))
853 downloader
= optparse
.OptionGroup(parser
, 'Download Options')
854 downloader
.add_option(
855 '-N', '--concurrent-fragments',
856 dest
='concurrent_fragment_downloads', metavar
='N', default
=1, type=int,
857 help='Number of fragments of a dash/hlsnative video that should be downloaded concurrently (default is %default)')
858 downloader
.add_option(
859 '-r', '--limit-rate', '--rate-limit',
860 dest
='ratelimit', metavar
='RATE',
861 help='Maximum download rate in bytes per second, e.g. 50K or 4.2M')
862 downloader
.add_option(
864 dest
='throttledratelimit', metavar
='RATE',
865 help='Minimum download rate in bytes per second below which throttling is assumed and the video data is re-extracted, e.g. 100K')
866 downloader
.add_option(
868 dest
='retries', metavar
='RETRIES', default
=10,
869 help='Number of retries (default is %default), or "infinite"')
870 downloader
.add_option(
871 '--file-access-retries',
872 dest
='file_access_retries', metavar
='RETRIES', default
=3,
873 help='Number of times to retry on file access error (default is %default), or "infinite"')
874 downloader
.add_option(
875 '--fragment-retries',
876 dest
='fragment_retries', metavar
='RETRIES', default
=10,
877 help='Number of retries for a fragment (default is %default), or "infinite" (DASH, hlsnative and ISM)')
878 downloader
.add_option(
880 dest
='retry_sleep', metavar
='[TYPE:]EXPR', default
={}, type='str',
881 action
='callback', callback
=_dict_from_options_callback
,
883 'allowed_keys': 'http|fragment|file_access|extractor',
884 'default_key': 'http',
886 'Time to sleep between retries in seconds (optionally) prefixed by the type of retry '
887 '(http (default), fragment, file_access, extractor) to apply the sleep to. '
888 'EXPR can be a number, linear=START[:END[:STEP=1]] or exp=START[:END[:BASE=2]]. '
889 'This option can be used multiple times to set the sleep for the different retry types, '
890 'e.g. --retry-sleep linear=1::2 --retry-sleep fragment:exp=1:20'))
891 downloader
.add_option(
892 '--skip-unavailable-fragments', '--no-abort-on-unavailable-fragment',
893 action
='store_true', dest
='skip_unavailable_fragments', default
=True,
894 help='Skip unavailable fragments for DASH, hlsnative and ISM downloads (default) (Alias: --no-abort-on-unavailable-fragment)')
895 downloader
.add_option(
896 '--abort-on-unavailable-fragment', '--no-skip-unavailable-fragments',
897 action
='store_false', dest
='skip_unavailable_fragments',
898 help='Abort download if a fragment is unavailable (Alias: --no-skip-unavailable-fragments)')
899 downloader
.add_option(
901 action
='store_true', dest
='keep_fragments', default
=False,
902 help='Keep downloaded fragments on disk after downloading is finished')
903 downloader
.add_option(
904 '--no-keep-fragments',
905 action
='store_false', dest
='keep_fragments',
906 help='Delete downloaded fragments after downloading is finished (default)')
907 downloader
.add_option(
909 dest
='buffersize', metavar
='SIZE', default
='1024',
910 help='Size of download buffer, e.g. 1024 or 16K (default is %default)')
911 downloader
.add_option(
913 action
='store_false', dest
='noresizebuffer',
914 help='The buffer size is automatically resized from an initial value of --buffer-size (default)')
915 downloader
.add_option(
916 '--no-resize-buffer',
917 action
='store_true', dest
='noresizebuffer', default
=False,
918 help='Do not automatically adjust the buffer size')
919 downloader
.add_option(
921 dest
='http_chunk_size', metavar
='SIZE', default
=None,
923 'Size of a chunk for chunk-based HTTP downloading, e.g. 10485760 or 10M (default is disabled). '
924 'May be useful for bypassing bandwidth throttling imposed by a webserver (experimental)'))
925 downloader
.add_option(
927 action
='store_true', dest
='test', default
=False,
928 help=optparse
.SUPPRESS_HELP
)
929 downloader
.add_option(
930 '--playlist-reverse',
931 action
='store_true', dest
='playlist_reverse',
932 help=optparse
.SUPPRESS_HELP
)
933 downloader
.add_option(
934 '--no-playlist-reverse',
935 action
='store_false', dest
='playlist_reverse',
936 help=optparse
.SUPPRESS_HELP
)
937 downloader
.add_option(
939 action
='store_true', dest
='playlist_random',
940 help='Download playlist videos in random order')
941 downloader
.add_option(
943 action
='store_true', dest
='lazy_playlist',
944 help='Process entries in the playlist as they are received. This disables n_entries, --playlist-random and --playlist-reverse')
945 downloader
.add_option(
946 '--no-lazy-playlist',
947 action
='store_false', dest
='lazy_playlist',
948 help='Process videos in the playlist only after the entire playlist is parsed (default)')
949 downloader
.add_option(
950 '--xattr-set-filesize',
951 dest
='xattr_set_filesize', action
='store_true',
952 help='Set file xattribute ytdl.filesize with expected file size')
953 downloader
.add_option(
954 '--hls-prefer-native',
955 dest
='hls_prefer_native', action
='store_true', default
=None,
956 help=optparse
.SUPPRESS_HELP
)
957 downloader
.add_option(
958 '--hls-prefer-ffmpeg',
959 dest
='hls_prefer_native', action
='store_false', default
=None,
960 help=optparse
.SUPPRESS_HELP
)
961 downloader
.add_option(
963 dest
='hls_use_mpegts', action
='store_true', default
=None,
965 'Use the mpegts container for HLS videos; '
966 'allowing some players to play the video while downloading, '
967 'and reducing the chance of file corruption if download is interrupted. '
968 'This is enabled by default for live streams'))
969 downloader
.add_option(
970 '--no-hls-use-mpegts',
971 dest
='hls_use_mpegts', action
='store_false',
973 'Do not use the mpegts container for HLS videos. '
974 'This is default when not downloading live streams'))
975 downloader
.add_option(
976 '--download-sections',
977 metavar
='REGEX', dest
='download_ranges', action
='append',
979 'Download only chapters whose title matches the given regular expression. '
980 'Time ranges prefixed by a "*" can also be used in place of chapters to download the specified range. '
981 'Needs ffmpeg. This option can be used multiple times to download multiple sections, '
982 'e.g. --download-sections "*10:15-inf" --download-sections "intro"'))
983 downloader
.add_option(
984 '--downloader', '--external-downloader',
985 dest
='external_downloader', metavar
='[PROTO:]NAME', default
={}, type='str',
986 action
='callback', callback
=_dict_from_options_callback
,
988 'allowed_keys': 'http|ftp|m3u8|dash|rtsp|rtmp|mms',
989 'default_key': 'default',
992 'Name or path of the external downloader to use (optionally) prefixed by '
993 'the protocols (http, ftp, m3u8, dash, rstp, rtmp, mms) to use it for. '
994 f
'Currently supports native, {", ".join(sorted(list_external_downloaders()))}. '
995 'You can use this option multiple times to set different downloaders for different protocols. '
996 'E.g. --downloader aria2c --downloader "dash,m3u8:native" will use '
997 'aria2c for http/ftp downloads, and the native downloader for dash/m3u8 downloads '
998 '(Alias: --external-downloader)'))
999 downloader
.add_option(
1000 '--downloader-args', '--external-downloader-args',
1001 metavar
='NAME:ARGS', dest
='external_downloader_args', default
={}, type='str',
1002 action
='callback', callback
=_dict_from_options_callback
,
1004 'allowed_keys': r
'ffmpeg_[io]\d*|%s' % '|'.join(map(re
.escape
, list_external_downloaders())),
1005 'default_key': 'default',
1006 'process': shlex
.split
1008 'Give these arguments to the external downloader. '
1009 'Specify the downloader name and the arguments separated by a colon ":". '
1010 'For ffmpeg, arguments can be passed to different positions using the same syntax as --postprocessor-args. '
1011 'You can use this option multiple times to give different arguments to different downloaders '
1012 '(Alias: --external-downloader-args)'))
1014 workarounds
= optparse
.OptionGroup(parser
, 'Workarounds')
1015 workarounds
.add_option(
1017 dest
='encoding', metavar
='ENCODING',
1018 help='Force the specified encoding (experimental)')
1019 workarounds
.add_option(
1020 '--legacy-server-connect',
1021 action
='store_true', dest
='legacy_server_connect', default
=False,
1022 help='Explicitly allow HTTPS connection to servers that do not support RFC 5746 secure renegotiation')
1023 workarounds
.add_option(
1024 '--no-check-certificates',
1025 action
='store_true', dest
='no_check_certificate', default
=False,
1026 help='Suppress HTTPS certificate validation')
1027 workarounds
.add_option(
1028 '--prefer-insecure', '--prefer-unsecure',
1029 action
='store_true', dest
='prefer_insecure',
1030 help='Use an unencrypted connection to retrieve information about the video (Currently supported only for YouTube)')
1031 workarounds
.add_option(
1033 metavar
='UA', dest
='user_agent',
1034 help=optparse
.SUPPRESS_HELP
)
1035 workarounds
.add_option(
1037 metavar
='URL', dest
='referer', default
=None,
1038 help=optparse
.SUPPRESS_HELP
)
1039 workarounds
.add_option(
1041 metavar
='FIELD:VALUE', dest
='headers', default
={}, type='str',
1042 action
='callback', callback
=_dict_from_options_callback
,
1043 callback_kwargs
={'multiple_keys': False}
,
1044 help='Specify a custom HTTP header and its value, separated by a colon ":". You can use this option multiple times',
1046 workarounds
.add_option(
1047 '--bidi-workaround',
1048 dest
='bidi_workaround', action
='store_true',
1049 help='Work around terminals that lack bidirectional text support. Requires bidiv or fribidi executable in PATH')
1050 workarounds
.add_option(
1051 '--sleep-requests', metavar
='SECONDS',
1052 dest
='sleep_interval_requests', type=float,
1053 help='Number of seconds to sleep between requests during data extraction')
1054 workarounds
.add_option(
1055 '--sleep-interval', '--min-sleep-interval', metavar
='SECONDS',
1056 dest
='sleep_interval', type=float,
1058 'Number of seconds to sleep before each download. '
1059 'This is the minimum time to sleep when used along with --max-sleep-interval '
1060 '(Alias: --min-sleep-interval)'))
1061 workarounds
.add_option(
1062 '--max-sleep-interval', metavar
='SECONDS',
1063 dest
='max_sleep_interval', type=float,
1064 help='Maximum number of seconds to sleep. Can only be used along with --min-sleep-interval')
1065 workarounds
.add_option(
1066 '--sleep-subtitles', metavar
='SECONDS',
1067 dest
='sleep_interval_subtitles', default
=0, type=int,
1068 help='Number of seconds to sleep before each subtitle download')
1070 verbosity
= optparse
.OptionGroup(parser
, 'Verbosity and Simulation Options')
1071 verbosity
.add_option(
1073 action
='store_true', dest
='quiet', default
=False,
1074 help='Activate quiet mode. If used with --verbose, print the log to stderr')
1075 verbosity
.add_option(
1077 dest
='no_warnings', action
='store_true', default
=False,
1078 help='Ignore warnings')
1079 verbosity
.add_option(
1081 action
='store_true', dest
='simulate', default
=None,
1082 help='Do not download the video and do not write anything to disk')
1083 verbosity
.add_option(
1085 action
='store_false', dest
='simulate',
1086 help='Download the video even if printing/listing options are used')
1087 verbosity
.add_option(
1088 '--ignore-no-formats-error',
1089 action
='store_true', dest
='ignore_no_formats_error', default
=False,
1091 'Ignore "No video formats" error. Useful for extracting metadata '
1092 'even if the videos are not actually available for download (experimental)'))
1093 verbosity
.add_option(
1094 '--no-ignore-no-formats-error',
1095 action
='store_false', dest
='ignore_no_formats_error',
1096 help='Throw error when no downloadable video formats are found (default)')
1097 verbosity
.add_option(
1098 '--skip-download', '--no-download',
1099 action
='store_true', dest
='skip_download', default
=False,
1100 help='Do not download the video but write all related files (Alias: --no-download)')
1101 verbosity
.add_option(
1103 metavar
='[WHEN:]TEMPLATE', dest
='forceprint', **when_prefix('video'),
1105 'Field name or output template to print to screen, optionally prefixed with when to print it, separated by a ":". '
1106 'Supported values of "WHEN" are the same as that of --use-postprocessor (default: video). '
1107 'Implies --quiet. Implies --simulate unless --no-simulate or later stages of WHEN are used. '
1108 'This option can be used multiple times'))
1109 verbosity
.add_option(
1111 metavar
='[WHEN:]TEMPLATE FILE', dest
='print_to_file', nargs
=2, **when_prefix('video'),
1113 'Append given template to the file. The values of WHEN and TEMPLATE are same as that of --print. '
1114 'FILE uses the same syntax as the output template. This option can be used multiple times'))
1115 verbosity
.add_option(
1117 action
='store_true', dest
='geturl', default
=False,
1118 help=optparse
.SUPPRESS_HELP
)
1119 verbosity
.add_option(
1120 '-e', '--get-title',
1121 action
='store_true', dest
='gettitle', default
=False,
1122 help=optparse
.SUPPRESS_HELP
)
1123 verbosity
.add_option(
1125 action
='store_true', dest
='getid', default
=False,
1126 help=optparse
.SUPPRESS_HELP
)
1127 verbosity
.add_option(
1129 action
='store_true', dest
='getthumbnail', default
=False,
1130 help=optparse
.SUPPRESS_HELP
)
1131 verbosity
.add_option(
1132 '--get-description',
1133 action
='store_true', dest
='getdescription', default
=False,
1134 help=optparse
.SUPPRESS_HELP
)
1135 verbosity
.add_option(
1137 action
='store_true', dest
='getduration', default
=False,
1138 help=optparse
.SUPPRESS_HELP
)
1139 verbosity
.add_option(
1141 action
='store_true', dest
='getfilename', default
=False,
1142 help=optparse
.SUPPRESS_HELP
)
1143 verbosity
.add_option(
1145 action
='store_true', dest
='getformat', default
=False,
1146 help=optparse
.SUPPRESS_HELP
)
1147 verbosity
.add_option(
1148 '-j', '--dump-json',
1149 action
='store_true', dest
='dumpjson', default
=False,
1150 help='Quiet, but print JSON information for each video. Simulate unless --no-simulate is used. See "OUTPUT TEMPLATE" for a description of available keys')
1151 verbosity
.add_option(
1152 '-J', '--dump-single-json',
1153 action
='store_true', dest
='dump_single_json', default
=False,
1155 'Quiet, but print JSON information for each url or infojson passed. Simulate unless --no-simulate is used. '
1156 'If the URL refers to a playlist, the whole playlist information is dumped in a single line'))
1157 verbosity
.add_option(
1159 action
='store_true', dest
='print_json', default
=False,
1160 help=optparse
.SUPPRESS_HELP
)
1161 verbosity
.add_option(
1162 '--force-write-archive', '--force-write-download-archive', '--force-download-archive',
1163 action
='store_true', dest
='force_write_download_archive', default
=False,
1165 'Force download archive entries to be written as far as no errors occur, '
1166 'even if -s or another simulation option is used (Alias: --force-download-archive)'))
1167 verbosity
.add_option(
1169 action
='store_true', dest
='progress_with_newline', default
=False,
1170 help='Output progress bar as new lines')
1171 verbosity
.add_option(
1173 action
='store_true', dest
='noprogress', default
=None,
1174 help='Do not print progress bar')
1175 verbosity
.add_option(
1177 action
='store_false', dest
='noprogress',
1178 help='Show progress bar, even if in quiet mode')
1179 verbosity
.add_option(
1181 action
='store_true', dest
='consoletitle', default
=False,
1182 help='Display progress in console titlebar')
1183 verbosity
.add_option(
1184 '--progress-template',
1185 metavar
='[TYPES:]TEMPLATE', dest
='progress_template', default
={}, type='str',
1186 action
='callback', callback
=_dict_from_options_callback
,
1188 'allowed_keys': '(download|postprocess)(-title)?',
1189 'default_key': 'download'
1191 'Template for progress outputs, optionally prefixed with one of "download:" (default), '
1192 '"download-title:" (the console title), "postprocess:", or "postprocess-title:". '
1193 'The video\'s fields are accessible under the "info" key and '
1194 'the progress attributes are accessible under "progress" key. E.g. '
1195 # TODO: Document the fields inside "progress"
1196 '--console-title --progress-template "download-title:%(info.id)s-%(progress.eta)s"'))
1197 verbosity
.add_option(
1199 action
='store_true', dest
='verbose', default
=False,
1200 help='Print various debugging information')
1201 verbosity
.add_option(
1202 '--dump-pages', '--dump-intermediate-pages',
1203 action
='store_true', dest
='dump_intermediate_pages', default
=False,
1204 help='Print downloaded pages encoded using base64 to debug problems (very verbose)')
1205 verbosity
.add_option(
1207 action
='store_true', dest
='write_pages', default
=False,
1208 help='Write downloaded intermediary pages to files in the current directory to debug problems')
1209 verbosity
.add_option(
1211 action
='store_true', dest
='load_pages', default
=False,
1212 help=optparse
.SUPPRESS_HELP
)
1213 verbosity
.add_option(
1214 '--youtube-print-sig-code',
1215 action
='store_true', dest
='youtube_print_sig_code', default
=False,
1216 help=optparse
.SUPPRESS_HELP
)
1217 verbosity
.add_option(
1218 '--print-traffic', '--dump-headers',
1219 dest
='debug_printtraffic', action
='store_true', default
=False,
1220 help='Display sent and read HTTP traffic')
1221 verbosity
.add_option(
1222 '-C', '--call-home',
1223 dest
='call_home', action
='store_true', default
=False,
1224 # help='Contact the yt-dlp server for debugging')
1225 help=optparse
.SUPPRESS_HELP
)
1226 verbosity
.add_option(
1228 dest
='call_home', action
='store_false',
1229 # help='Do not contact the yt-dlp server for debugging (default)')
1230 help=optparse
.SUPPRESS_HELP
)
1232 filesystem
= optparse
.OptionGroup(parser
, 'Filesystem Options')
1233 filesystem
.add_option(
1234 '-a', '--batch-file',
1235 dest
='batchfile', metavar
='FILE',
1237 'File containing URLs to download ("-" for stdin), one URL per line. '
1238 'Lines starting with "#", ";" or "]" are considered as comments and ignored'))
1239 filesystem
.add_option(
1241 dest
='batchfile', action
='store_const', const
=None,
1242 help='Do not read URLs from batch file (default)')
1243 filesystem
.add_option(
1244 '--id', default
=False,
1245 action
='store_true', dest
='useid', help=optparse
.SUPPRESS_HELP
)
1246 filesystem
.add_option(
1248 metavar
='[TYPES:]PATH', dest
='paths', default
={}, type='str',
1249 action
='callback', callback
=_dict_from_options_callback
,
1251 'allowed_keys': 'home|temp|%s' % '|'.join(map(re
.escape
, OUTTMPL_TYPES
.keys())),
1252 'default_key': 'home'
1254 'The paths where the files should be downloaded. '
1255 'Specify the type of file and the path separated by a colon ":". '
1256 'All the same TYPES as --output are supported. '
1257 'Additionally, you can also provide "home" (default) and "temp" paths. '
1258 'All intermediary files are first downloaded to the temp path and '
1259 'then the final files are moved over to the home path after download is finished. '
1260 'This option is ignored if --output is an absolute path'))
1261 filesystem
.add_option(
1263 metavar
='[TYPES:]TEMPLATE', dest
='outtmpl', default
={}, type='str',
1264 action
='callback', callback
=_dict_from_options_callback
,
1266 'allowed_keys': '|'.join(map(re
.escape
, OUTTMPL_TYPES
.keys())),
1267 'default_key': 'default'
1268 }, help='Output filename template; see "OUTPUT TEMPLATE" for details')
1269 filesystem
.add_option(
1270 '--output-na-placeholder',
1271 dest
='outtmpl_na_placeholder', metavar
='TEXT', default
='NA',
1272 help=('Placeholder for unavailable fields in "OUTPUT TEMPLATE" (default: "%default")'))
1273 filesystem
.add_option(
1274 '--autonumber-size',
1275 dest
='autonumber_size', metavar
='NUMBER', type=int,
1276 help=optparse
.SUPPRESS_HELP
)
1277 filesystem
.add_option(
1278 '--autonumber-start',
1279 dest
='autonumber_start', metavar
='NUMBER', default
=1, type=int,
1280 help=optparse
.SUPPRESS_HELP
)
1281 filesystem
.add_option(
1282 '--restrict-filenames',
1283 action
='store_true', dest
='restrictfilenames', default
=False,
1284 help='Restrict filenames to only ASCII characters, and avoid "&" and spaces in filenames')
1285 filesystem
.add_option(
1286 '--no-restrict-filenames',
1287 action
='store_false', dest
='restrictfilenames',
1288 help='Allow Unicode characters, "&" and spaces in filenames (default)')
1289 filesystem
.add_option(
1290 '--windows-filenames',
1291 action
='store_true', dest
='windowsfilenames', default
=False,
1292 help='Force filenames to be Windows-compatible')
1293 filesystem
.add_option(
1294 '--no-windows-filenames',
1295 action
='store_false', dest
='windowsfilenames',
1296 help='Make filenames Windows-compatible only if using Windows (default)')
1297 filesystem
.add_option(
1298 '--trim-filenames', '--trim-file-names', metavar
='LENGTH',
1299 dest
='trim_file_name', default
=0, type=int,
1300 help='Limit the filename length (excluding extension) to the specified number of characters')
1301 filesystem
.add_option(
1302 '-w', '--no-overwrites',
1303 action
='store_false', dest
='overwrites', default
=None,
1304 help='Do not overwrite any files')
1305 filesystem
.add_option(
1306 '--force-overwrites', '--yes-overwrites',
1307 action
='store_true', dest
='overwrites',
1308 help='Overwrite all video and metadata files. This option includes --no-continue')
1309 filesystem
.add_option(
1310 '--no-force-overwrites',
1311 action
='store_const', dest
='overwrites', const
=None,
1312 help='Do not overwrite the video, but overwrite related files (default)')
1313 filesystem
.add_option(
1315 action
='store_true', dest
='continue_dl', default
=True,
1316 help='Resume partially downloaded files/fragments (default)')
1317 filesystem
.add_option(
1319 action
='store_false', dest
='continue_dl',
1321 'Do not resume partially downloaded fragments. '
1322 'If the file is not fragmented, restart download of the entire file'))
1323 filesystem
.add_option(
1325 action
='store_false', dest
='nopart', default
=False,
1326 help='Use .part files instead of writing directly into output file (default)')
1327 filesystem
.add_option(
1329 action
='store_true', dest
='nopart',
1330 help='Do not use .part files - write directly into output file')
1331 filesystem
.add_option(
1333 action
='store_true', dest
='updatetime', default
=True,
1334 help='Use the Last-modified header to set the file modification time (default)')
1335 filesystem
.add_option(
1337 action
='store_false', dest
='updatetime',
1338 help='Do not use the Last-modified header to set the file modification time')
1339 filesystem
.add_option(
1340 '--write-description',
1341 action
='store_true', dest
='writedescription', default
=False,
1342 help='Write video description to a .description file')
1343 filesystem
.add_option(
1344 '--no-write-description',
1345 action
='store_false', dest
='writedescription',
1346 help='Do not write video description (default)')
1347 filesystem
.add_option(
1348 '--write-info-json',
1349 action
='store_true', dest
='writeinfojson', default
=None,
1350 help='Write video metadata to a .info.json file (this may contain personal information)')
1351 filesystem
.add_option(
1352 '--no-write-info-json',
1353 action
='store_false', dest
='writeinfojson',
1354 help='Do not write video metadata (default)')
1355 filesystem
.add_option(
1356 '--write-annotations',
1357 action
='store_true', dest
='writeannotations', default
=False,
1358 help=optparse
.SUPPRESS_HELP
)
1359 filesystem
.add_option(
1360 '--no-write-annotations',
1361 action
='store_false', dest
='writeannotations',
1362 help=optparse
.SUPPRESS_HELP
)
1363 filesystem
.add_option(
1364 '--write-playlist-metafiles',
1365 action
='store_true', dest
='allow_playlist_files', default
=None,
1367 'Write playlist metadata in addition to the video metadata '
1368 'when using --write-info-json, --write-description etc. (default)'))
1369 filesystem
.add_option(
1370 '--no-write-playlist-metafiles',
1371 action
='store_false', dest
='allow_playlist_files',
1372 help='Do not write playlist metadata when using --write-info-json, --write-description etc.')
1373 filesystem
.add_option(
1374 '--clean-info-json', '--clean-infojson',
1375 action
='store_true', dest
='clean_infojson', default
=None,
1377 'Remove some private fields such as filenames from the infojson. '
1378 'Note that it could still contain some personal information (default)'))
1379 filesystem
.add_option(
1380 '--no-clean-info-json', '--no-clean-infojson',
1381 action
='store_false', dest
='clean_infojson',
1382 help='Write all fields to the infojson')
1383 filesystem
.add_option(
1384 '--write-comments', '--get-comments',
1385 action
='store_true', dest
='getcomments', default
=False,
1387 'Retrieve video comments to be placed in the infojson. '
1388 'The comments are fetched even without this option if the extraction is known to be quick (Alias: --get-comments)'))
1389 filesystem
.add_option(
1390 '--no-write-comments', '--no-get-comments',
1391 action
='store_false', dest
='getcomments',
1392 help='Do not retrieve video comments unless the extraction is known to be quick (Alias: --no-get-comments)')
1393 filesystem
.add_option(
1394 '--load-info-json', '--load-info',
1395 dest
='load_info_filename', metavar
='FILE',
1396 help='JSON file containing the video information (created with the "--write-info-json" option)')
1397 filesystem
.add_option(
1399 dest
='cookiefile', metavar
='FILE',
1400 help='Netscape formatted file to read cookies from and dump cookie jar in')
1401 filesystem
.add_option(
1403 action
='store_const', const
=None, dest
='cookiefile', metavar
='FILE',
1404 help='Do not read/dump cookies from/to file (default)')
1405 filesystem
.add_option(
1406 '--cookies-from-browser',
1407 dest
='cookiesfrombrowser', metavar
='BROWSER[+KEYRING][:PROFILE][::CONTAINER]',
1409 'The name of the browser to load cookies from. '
1410 f
'Currently supported browsers are: {", ".join(sorted(SUPPORTED_BROWSERS))}. '
1411 'Optionally, the KEYRING used for decrypting Chromium cookies on Linux, '
1412 'the name/path of the PROFILE to load cookies from, '
1413 'and the CONTAINER name (if Firefox) ("none" for no container) '
1414 'can be given with their respective seperators. '
1415 'By default, all containers of the most recently accessed profile are used. '
1416 f
'Currently supported keyrings are: {", ".join(map(str.lower, sorted(SUPPORTED_KEYRINGS)))}'))
1417 filesystem
.add_option(
1418 '--no-cookies-from-browser',
1419 action
='store_const', const
=None, dest
='cookiesfrombrowser',
1420 help='Do not load cookies from browser (default)')
1421 filesystem
.add_option(
1422 '--cache-dir', dest
='cachedir', default
=None, metavar
='DIR',
1424 'Location in the filesystem where yt-dlp can store some downloaded information '
1425 '(such as client ids and signatures) permanently. By default ${XDG_CACHE_HOME}/yt-dlp'))
1426 filesystem
.add_option(
1427 '--no-cache-dir', action
='store_false', dest
='cachedir',
1428 help='Disable filesystem caching')
1429 filesystem
.add_option(
1431 action
='store_true', dest
='rm_cachedir',
1432 help='Delete all filesystem cache files')
1434 thumbnail
= optparse
.OptionGroup(parser
, 'Thumbnail Options')
1435 thumbnail
.add_option(
1436 '--write-thumbnail',
1437 action
='callback', dest
='writethumbnail', default
=False,
1438 # Should override --no-write-thumbnail, but not --write-all-thumbnail
1439 callback
=lambda option
, _
, __
, parser
: setattr(
1440 parser
.values
, option
.dest
, getattr(parser
.values
, option
.dest
) or True),
1441 help='Write thumbnail image to disk')
1442 thumbnail
.add_option(
1443 '--no-write-thumbnail',
1444 action
='store_false', dest
='writethumbnail',
1445 help='Do not write thumbnail image to disk (default)')
1446 thumbnail
.add_option(
1447 '--write-all-thumbnails',
1448 action
='store_const', dest
='writethumbnail', const
='all',
1449 help='Write all thumbnail image formats to disk')
1450 thumbnail
.add_option(
1451 '--list-thumbnails',
1452 action
='store_true', dest
='list_thumbnails', default
=False,
1453 help='List available thumbnails of each video. Simulate unless --no-simulate is used')
1455 link
= optparse
.OptionGroup(parser
, 'Internet Shortcut Options')
1458 action
='store_true', dest
='writelink', default
=False,
1459 help='Write an internet shortcut file, depending on the current platform (.url, .webloc or .desktop). The URL may be cached by the OS')
1462 action
='store_true', dest
='writeurllink', default
=False,
1463 help='Write a .url Windows internet shortcut. The OS caches the URL based on the file path')
1465 '--write-webloc-link',
1466 action
='store_true', dest
='writewebloclink', default
=False,
1467 help='Write a .webloc macOS internet shortcut')
1469 '--write-desktop-link',
1470 action
='store_true', dest
='writedesktoplink', default
=False,
1471 help='Write a .desktop Linux internet shortcut')
1473 postproc
= optparse
.OptionGroup(parser
, 'Post-Processing Options')
1474 postproc
.add_option(
1475 '-x', '--extract-audio',
1476 action
='store_true', dest
='extractaudio', default
=False,
1477 help='Convert video files to audio-only files (requires ffmpeg and ffprobe)')
1478 postproc
.add_option(
1479 '--audio-format', metavar
='FORMAT', dest
='audioformat', default
='best',
1481 'Format to convert the audio to when -x is used. '
1482 f
'(currently supported: best (default), {", ".join(sorted(FFmpegExtractAudioPP.SUPPORTED_EXTS))}). '
1483 'You can specify multiple rules using similar syntax as --remux-video'))
1484 postproc
.add_option(
1485 '--audio-quality', metavar
='QUALITY',
1486 dest
='audioquality', default
='5',
1488 'Specify ffmpeg audio quality to use when converting the audio with -x. '
1489 'Insert a value between 0 (best) and 10 (worst) for VBR or a specific bitrate like 128K (default %default)'))
1490 postproc
.add_option(
1492 metavar
='FORMAT', dest
='remuxvideo', default
=None,
1494 'Remux the video into another container if necessary '
1495 f
'(currently supported: {", ".join(FFmpegVideoRemuxerPP.SUPPORTED_EXTS)}). '
1496 'If target container does not support the video/audio codec, remuxing will fail. You can specify multiple rules; '
1497 'e.g. "aac>m4a/mov>mp4/mkv" will remux aac to m4a, mov to mp4 and anything else to mkv'))
1498 postproc
.add_option(
1500 metavar
='FORMAT', dest
='recodevideo', default
=None,
1501 help='Re-encode the video into another format if necessary. The syntax and supported formats are the same as --remux-video')
1502 postproc
.add_option(
1503 '--postprocessor-args', '--ppa',
1504 metavar
='NAME:ARGS', dest
='postprocessor_args', default
={}, type='str',
1505 action
='callback', callback
=_dict_from_options_callback
,
1507 'allowed_keys': r
'\w+(?:\+\w+)?',
1508 'default_key': 'default-compat',
1509 'process': shlex
.split
,
1510 'multiple_keys': False
1512 'Give these arguments to the postprocessors. '
1513 'Specify the postprocessor/executable name and the arguments separated by a colon ":" '
1514 'to give the argument to the specified postprocessor/executable. Supported PP are: '
1515 'Merger, ModifyChapters, SplitChapters, ExtractAudio, VideoRemuxer, VideoConvertor, '
1516 'Metadata, EmbedSubtitle, EmbedThumbnail, SubtitlesConvertor, ThumbnailsConvertor, '
1517 'FixupStretched, FixupM4a, FixupM3u8, FixupTimestamp and FixupDuration. '
1518 'The supported executables are: AtomicParsley, FFmpeg and FFprobe. '
1519 'You can also specify "PP+EXE:ARGS" to give the arguments to the specified executable '
1520 'only when being used by the specified postprocessor. Additionally, for ffmpeg/ffprobe, '
1521 '"_i"/"_o" can be appended to the prefix optionally followed by a number to pass the argument '
1522 'before the specified input/output file, e.g. --ppa "Merger+ffmpeg_i1:-v quiet". '
1523 'You can use this option multiple times to give different arguments to different '
1524 'postprocessors. (Alias: --ppa)'))
1525 postproc
.add_option(
1526 '-k', '--keep-video',
1527 action
='store_true', dest
='keepvideo', default
=False,
1528 help='Keep the intermediate video file on disk after post-processing')
1529 postproc
.add_option(
1531 action
='store_false', dest
='keepvideo',
1532 help='Delete the intermediate video file after post-processing (default)')
1533 postproc
.add_option(
1534 '--post-overwrites',
1535 action
='store_false', dest
='nopostoverwrites',
1536 help='Overwrite post-processed files (default)')
1537 postproc
.add_option(
1538 '--no-post-overwrites',
1539 action
='store_true', dest
='nopostoverwrites', default
=False,
1540 help='Do not overwrite post-processed files')
1541 postproc
.add_option(
1543 action
='store_true', dest
='embedsubtitles', default
=False,
1544 help='Embed subtitles in the video (only for mp4, webm and mkv videos)')
1545 postproc
.add_option(
1547 action
='store_false', dest
='embedsubtitles',
1548 help='Do not embed subtitles (default)')
1549 postproc
.add_option(
1550 '--embed-thumbnail',
1551 action
='store_true', dest
='embedthumbnail', default
=False,
1552 help='Embed thumbnail in the video as cover art')
1553 postproc
.add_option(
1554 '--no-embed-thumbnail',
1555 action
='store_false', dest
='embedthumbnail',
1556 help='Do not embed thumbnail (default)')
1557 postproc
.add_option(
1558 '--embed-metadata', '--add-metadata',
1559 action
='store_true', dest
='addmetadata', default
=False,
1561 'Embed metadata to the video file. Also embeds chapters/infojson if present '
1562 'unless --no-embed-chapters/--no-embed-info-json are used (Alias: --add-metadata)'))
1563 postproc
.add_option(
1564 '--no-embed-metadata', '--no-add-metadata',
1565 action
='store_false', dest
='addmetadata',
1566 help='Do not add metadata to file (default) (Alias: --no-add-metadata)')
1567 postproc
.add_option(
1568 '--embed-chapters', '--add-chapters',
1569 action
='store_true', dest
='addchapters', default
=None,
1570 help='Add chapter markers to the video file (Alias: --add-chapters)')
1571 postproc
.add_option(
1572 '--no-embed-chapters', '--no-add-chapters',
1573 action
='store_false', dest
='addchapters',
1574 help='Do not add chapter markers (default) (Alias: --no-add-chapters)')
1575 postproc
.add_option(
1576 '--embed-info-json',
1577 action
='store_true', dest
='embed_infojson', default
=None,
1578 help='Embed the infojson as an attachment to mkv/mka video files')
1579 postproc
.add_option(
1580 '--no-embed-info-json',
1581 action
='store_false', dest
='embed_infojson',
1582 help='Do not embed the infojson as an attachment to the video file')
1583 postproc
.add_option(
1584 '--metadata-from-title',
1585 metavar
='FORMAT', dest
='metafromtitle',
1586 help=optparse
.SUPPRESS_HELP
)
1587 postproc
.add_option(
1589 metavar
='FROM:TO', dest
='parse_metadata', action
='append',
1591 'Parse additional metadata like title/artist from other fields; '
1592 'see "MODIFYING METADATA" for details'))
1593 postproc
.add_option(
1594 '--replace-in-metadata',
1595 dest
='parse_metadata', metavar
='FIELDS REGEX REPLACE', action
='append', nargs
=3,
1596 help='Replace text in a metadata field using the given regex. This option can be used multiple times')
1597 postproc
.add_option(
1598 '--xattrs', '--xattr',
1599 action
='store_true', dest
='xattrs', default
=False,
1600 help='Write metadata to the video file\'s xattrs (using dublin core and xdg standards)')
1601 postproc
.add_option(
1602 '--concat-playlist',
1603 metavar
='POLICY', dest
='concat_playlist', default
='multi_video',
1604 choices
=('never', 'always', 'multi_video'),
1606 'Concatenate videos in a playlist. One of "never", "always", or '
1607 '"multi_video" (default; only when the videos form a single show). '
1608 'All the video files must have same codecs and number of streams to be concatable. '
1609 'The "pl_video:" prefix can be used with "--paths" and "--output" to '
1610 'set the output filename for the concatenated files. See "OUTPUT TEMPLATE" for details'))
1611 postproc
.add_option(
1613 metavar
='POLICY', dest
='fixup', default
=None,
1614 choices
=('never', 'ignore', 'warn', 'detect_or_warn', 'force'),
1616 'Automatically correct known faults of the file. '
1617 'One of never (do nothing), warn (only emit a warning), '
1618 'detect_or_warn (the default; fix file if we can, warn otherwise), '
1619 'force (try fixing even if file already exists)'))
1620 postproc
.add_option(
1621 '--prefer-avconv', '--no-prefer-ffmpeg',
1622 action
='store_false', dest
='prefer_ffmpeg',
1623 help=optparse
.SUPPRESS_HELP
)
1624 postproc
.add_option(
1625 '--prefer-ffmpeg', '--no-prefer-avconv',
1626 action
='store_true', dest
='prefer_ffmpeg', default
=True,
1627 help=optparse
.SUPPRESS_HELP
)
1628 postproc
.add_option(
1629 '--ffmpeg-location', '--avconv-location', metavar
='PATH',
1630 dest
='ffmpeg_location',
1631 help='Location of the ffmpeg binary; either the path to the binary or its containing directory')
1632 postproc
.add_option(
1634 metavar
='[WHEN:]CMD', dest
='exec_cmd', **when_prefix('after_move'),
1636 'Execute a command, optionally prefixed with when to execute it, separated by a ":". '
1637 'Supported values of "WHEN" are the same as that of --use-postprocessor (default: after_move). '
1638 'Same syntax as the output template can be used to pass any field as arguments to the command. '
1639 'After download, an additional field "filepath" that contains the final path of the downloaded file '
1640 'is also available, and if no fields are passed, %(filepath)q is appended to the end of the command. '
1641 'This option can be used multiple times'))
1642 postproc
.add_option(
1644 action
='store_const', dest
='exec_cmd', const
={},
1645 help='Remove any previously defined --exec')
1646 postproc
.add_option(
1647 '--exec-before-download', metavar
='CMD',
1648 action
='append', dest
='exec_before_dl_cmd',
1649 help=optparse
.SUPPRESS_HELP
)
1650 postproc
.add_option(
1651 '--no-exec-before-download',
1652 action
='store_const', dest
='exec_before_dl_cmd', const
=None,
1653 help=optparse
.SUPPRESS_HELP
)
1654 postproc
.add_option(
1655 '--convert-subs', '--convert-sub', '--convert-subtitles',
1656 metavar
='FORMAT', dest
='convertsubtitles', default
=None,
1658 'Convert the subtitles to another format (currently supported: %s) '
1659 '(Alias: --convert-subtitles)' % ', '.join(sorted(FFmpegSubtitlesConvertorPP
.SUPPORTED_EXTS
))))
1660 postproc
.add_option(
1661 '--convert-thumbnails',
1662 metavar
='FORMAT', dest
='convertthumbnails', default
=None,
1664 'Convert the thumbnails to another format '
1665 f
'(currently supported: {", ".join(sorted(FFmpegThumbnailsConvertorPP.SUPPORTED_EXTS))}). '
1666 'You can specify multiple rules using similar syntax as --remux-video'))
1667 postproc
.add_option(
1668 '--split-chapters', '--split-tracks',
1669 dest
='split_chapters', action
='store_true', default
=False,
1671 'Split video into multiple files based on internal chapters. '
1672 'The "chapter:" prefix can be used with "--paths" and "--output" to '
1673 'set the output filename for the split files. See "OUTPUT TEMPLATE" for details'))
1674 postproc
.add_option(
1675 '--no-split-chapters', '--no-split-tracks',
1676 dest
='split_chapters', action
='store_false',
1677 help='Do not split video based on chapters (default)')
1678 postproc
.add_option(
1679 '--remove-chapters',
1680 metavar
='REGEX', dest
='remove_chapters', action
='append',
1682 'Remove chapters whose title matches the given regular expression. '
1683 'The syntax is the same as --download-sections. This option can be used multiple times'))
1684 postproc
.add_option(
1685 '--no-remove-chapters', dest
='remove_chapters', action
='store_const', const
=None,
1686 help='Do not remove any chapters from the file (default)')
1687 postproc
.add_option(
1688 '--force-keyframes-at-cuts',
1689 action
='store_true', dest
='force_keyframes_at_cuts', default
=False,
1691 'Force keyframes at cuts when downloading/splitting/removing sections. '
1692 'This is slow due to needing a re-encode, but the resulting video may have fewer artifacts around the cuts'))
1693 postproc
.add_option(
1694 '--no-force-keyframes-at-cuts',
1695 action
='store_false', dest
='force_keyframes_at_cuts',
1696 help='Do not force keyframes around the chapters when cutting/splitting (default)')
1697 _postprocessor_opts_parser
= lambda key
, val
='': (
1698 *(item
.split('=', 1) for item
in (val
.split(';') if val
else [])),
1699 ('key', remove_end(key
, 'PP')))
1700 postproc
.add_option(
1701 '--use-postprocessor',
1702 metavar
='NAME[:ARGS]', dest
='add_postprocessors', default
=[], type='str',
1703 action
='callback', callback
=_list_from_options_callback
,
1706 'process': lambda val
: dict(_postprocessor_opts_parser(*val
.split(':', 1)))
1708 'The (case sensitive) name of plugin postprocessors to be enabled, '
1709 'and (optionally) arguments to be passed to it, separated by a colon ":". '
1710 'ARGS are a semicolon ";" delimited list of NAME=VALUE. '
1711 'The "when" argument determines when the postprocessor is invoked. '
1712 'It can be one of "pre_process" (after video extraction), "after_filter" (after video passes filter), '
1713 '"video" (after --format; before --print/--output), "before_dl" (before each video download), '
1714 '"post_process" (after each video download; default), '
1715 '"after_move" (after moving video file to it\'s final locations), '
1716 '"after_video" (after downloading and processing all formats of a video), '
1717 'or "playlist" (at end of playlist). '
1718 'This option can be used multiple times to add different postprocessors'))
1720 sponsorblock
= optparse
.OptionGroup(parser
, 'SponsorBlock Options', description
=(
1721 'Make chapter entries for, or remove various segments (sponsor, introductions, etc.) '
1722 'from downloaded YouTube videos using the SponsorBlock API (https://sponsor.ajay.app)'))
1723 sponsorblock
.add_option(
1724 '--sponsorblock-mark', metavar
='CATS',
1725 dest
='sponsorblock_mark', default
=set(), action
='callback', type='str',
1726 callback
=_set_from_options_callback
, callback_kwargs
={
1727 'allowed_values': SponsorBlockPP
.CATEGORIES
.keys(),
1728 'aliases': {'default': ['all']}
1730 'SponsorBlock categories to create chapters for, separated by commas. '
1731 f
'Available categories are {", ".join(SponsorBlockPP.CATEGORIES.keys())}, all and default (=all). '
1732 'You can prefix the category with a "-" to exclude it. See [1] for description of the categories. '
1733 'E.g. --sponsorblock-mark all,-preview [1] https://wiki.sponsor.ajay.app/w/Segment_Categories'))
1734 sponsorblock
.add_option(
1735 '--sponsorblock-remove', metavar
='CATS',
1736 dest
='sponsorblock_remove', default
=set(), action
='callback', type='str',
1737 callback
=_set_from_options_callback
, callback_kwargs
={
1738 'allowed_values': set(SponsorBlockPP
.CATEGORIES
.keys()) - set(SponsorBlockPP
.NON_SKIPPABLE_CATEGORIES
.keys()),
1739 # Note: From https://wiki.sponsor.ajay.app/w/Types:
1740 # The filler category is very aggressive.
1741 # It is strongly recommended to not use this in a client by default.
1742 'aliases': {'default': ['all', '-filler']}
1744 'SponsorBlock categories to be removed from the video file, separated by commas. '
1745 'If a category is present in both mark and remove, remove takes precedence. '
1746 'The syntax and available categories are the same as for --sponsorblock-mark '
1747 'except that "default" refers to "all,-filler" '
1748 f
'and {", ".join(SponsorBlockPP.NON_SKIPPABLE_CATEGORIES.keys())} are not available'))
1749 sponsorblock
.add_option(
1750 '--sponsorblock-chapter-title', metavar
='TEMPLATE',
1751 default
=DEFAULT_SPONSORBLOCK_CHAPTER_TITLE
, dest
='sponsorblock_chapter_title',
1753 'An output template for the title of the SponsorBlock chapters created by --sponsorblock-mark. '
1754 'The only available fields are start_time, end_time, category, categories, name, category_names. '
1755 'Defaults to "%default"'))
1756 sponsorblock
.add_option(
1757 '--no-sponsorblock', default
=False,
1758 action
='store_true', dest
='no_sponsorblock',
1759 help='Disable both --sponsorblock-mark and --sponsorblock-remove')
1760 sponsorblock
.add_option(
1761 '--sponsorblock-api', metavar
='URL',
1762 default
='https://sponsor.ajay.app', dest
='sponsorblock_api',
1763 help='SponsorBlock API location, defaults to %default')
1765 sponsorblock
.add_option(
1767 action
='store_true', dest
='sponskrub', default
=False,
1768 help=optparse
.SUPPRESS_HELP
)
1769 sponsorblock
.add_option(
1771 action
='store_false', dest
='sponskrub',
1772 help=optparse
.SUPPRESS_HELP
)
1773 sponsorblock
.add_option(
1774 '--sponskrub-cut', default
=False,
1775 action
='store_true', dest
='sponskrub_cut',
1776 help=optparse
.SUPPRESS_HELP
)
1777 sponsorblock
.add_option(
1778 '--no-sponskrub-cut',
1779 action
='store_false', dest
='sponskrub_cut',
1780 help=optparse
.SUPPRESS_HELP
)
1781 sponsorblock
.add_option(
1782 '--sponskrub-force', default
=False,
1783 action
='store_true', dest
='sponskrub_force',
1784 help=optparse
.SUPPRESS_HELP
)
1785 sponsorblock
.add_option(
1786 '--no-sponskrub-force',
1787 action
='store_true', dest
='sponskrub_force',
1788 help=optparse
.SUPPRESS_HELP
)
1789 sponsorblock
.add_option(
1790 '--sponskrub-location', metavar
='PATH',
1791 dest
='sponskrub_path', default
='',
1792 help=optparse
.SUPPRESS_HELP
)
1793 sponsorblock
.add_option(
1794 '--sponskrub-args', dest
='sponskrub_args', metavar
='ARGS',
1795 help=optparse
.SUPPRESS_HELP
)
1797 extractor
= optparse
.OptionGroup(parser
, 'Extractor Options')
1798 extractor
.add_option(
1799 '--extractor-retries',
1800 dest
='extractor_retries', metavar
='RETRIES', default
=3,
1801 help='Number of retries for known extractor errors (default is %default), or "infinite"')
1802 extractor
.add_option(
1803 '--allow-dynamic-mpd', '--no-ignore-dynamic-mpd',
1804 action
='store_true', dest
='dynamic_mpd', default
=True,
1805 help='Process dynamic DASH manifests (default) (Alias: --no-ignore-dynamic-mpd)')
1806 extractor
.add_option(
1807 '--ignore-dynamic-mpd', '--no-allow-dynamic-mpd',
1808 action
='store_false', dest
='dynamic_mpd',
1809 help='Do not process dynamic DASH manifests (Alias: --no-allow-dynamic-mpd)')
1810 extractor
.add_option(
1811 '--hls-split-discontinuity',
1812 dest
='hls_split_discontinuity', action
='store_true', default
=False,
1813 help='Split HLS playlists to different formats at discontinuities such as ad breaks'
1815 extractor
.add_option(
1816 '--no-hls-split-discontinuity',
1817 dest
='hls_split_discontinuity', action
='store_false',
1818 help='Do not split HLS playlists to different formats at discontinuities such as ad breaks (default)')
1819 _extractor_arg_parser
= lambda key
, vals
='': (key
.strip().lower().replace('-', '_'), [
1820 val
.replace(r
'\,', ',').strip() for val
in re
.split(r
'(?<!\\),', vals
)])
1821 extractor
.add_option(
1823 metavar
='IE_KEY:ARGS', dest
='extractor_args', default
={}, type='str',
1824 action
='callback', callback
=_dict_from_options_callback
,
1826 'multiple_keys': False,
1827 'process': lambda val
: dict(
1828 _extractor_arg_parser(*arg
.split('=', 1)) for arg
in val
.split(';'))
1830 'Pass ARGS arguments to the IE_KEY extractor. See "EXTRACTOR ARGUMENTS" for details. '
1831 'You can use this option multiple times to give arguments for different extractors'))
1832 extractor
.add_option(
1833 '--youtube-include-dash-manifest', '--no-youtube-skip-dash-manifest',
1834 action
='store_true', dest
='youtube_include_dash_manifest', default
=True,
1835 help=optparse
.SUPPRESS_HELP
)
1836 extractor
.add_option(
1837 '--youtube-skip-dash-manifest', '--no-youtube-include-dash-manifest',
1838 action
='store_false', dest
='youtube_include_dash_manifest',
1839 help=optparse
.SUPPRESS_HELP
)
1840 extractor
.add_option(
1841 '--youtube-include-hls-manifest', '--no-youtube-skip-hls-manifest',
1842 action
='store_true', dest
='youtube_include_hls_manifest', default
=True,
1843 help=optparse
.SUPPRESS_HELP
)
1844 extractor
.add_option(
1845 '--youtube-skip-hls-manifest', '--no-youtube-include-hls-manifest',
1846 action
='store_false', dest
='youtube_include_hls_manifest',
1847 help=optparse
.SUPPRESS_HELP
)
1849 parser
.add_option_group(general
)
1850 parser
.add_option_group(network
)
1851 parser
.add_option_group(geo
)
1852 parser
.add_option_group(selection
)
1853 parser
.add_option_group(downloader
)
1854 parser
.add_option_group(filesystem
)
1855 parser
.add_option_group(thumbnail
)
1856 parser
.add_option_group(link
)
1857 parser
.add_option_group(verbosity
)
1858 parser
.add_option_group(workarounds
)
1859 parser
.add_option_group(video_format
)
1860 parser
.add_option_group(subtitles
)
1861 parser
.add_option_group(authentication
)
1862 parser
.add_option_group(postproc
)
1863 parser
.add_option_group(sponsorblock
)
1864 parser
.add_option_group(extractor
)
1869 def _hide_login_info(opts
):
1870 deprecation_warning(f
'"{__name__}._hide_login_info" is deprecated and may be removed '
1871 'in a future version. Use "yt_dlp.utils.Config.hide_login_info" instead')
1872 return Config
.hide_login_info(opts
)