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