return parser, opts, args
+class _YoutubeDLOptionParser(optparse.OptionParser):
+ # optparse is deprecated since python 3.2. So assume a stable interface even for private methods
+
+ def _match_long_opt(self, opt):
+ """Improve ambigious argument resolution by comparing option objects instead of argument strings"""
+ try:
+ return super()._match_long_opt(opt)
+ except optparse.AmbiguousOptionError as e:
+ if len(set(self._long_opt[p] for p in e.possibilities)) == 1:
+ return e.possibilities[0]
+ raise
+
+
def create_parser():
def _format_option_string(option):
''' ('-o', '--option') -> -o, --format METAVAR'''
'conflict_handler': 'resolve',
}
- parser = optparse.OptionParser(**compat_kwargs(kw))
+ parser = _YoutubeDLOptionParser(**compat_kwargs(kw))
general = optparse.OptionGroup(parser, 'General Options')
general.add_option(
general.add_option(
'--mark-watched',
action='store_true', dest='mark_watched', default=False,
- help='Mark videos watched (even with --simulate). Currently only supported for YouTube')
+ help='Mark videos watched (even with --simulate)')
general.add_option(
'--no-mark-watched',
action='store_false', dest='mark_watched',
'filename', 'format-sort', 'abort-on-error', 'format-spec', 'no-playlist-metafiles',
'multistreams', 'no-live-chat', 'playlist-index', 'list-formats', 'no-direct-merge',
'no-youtube-channel-redirect', 'no-youtube-unavailable-videos', 'no-attach-info-json', 'embed-metadata',
- 'embed-thumbnail-atomicparsley', 'seperate-video-versions', 'no-clean-infojson', 'no-keep-subs',
+ 'embed-thumbnail-atomicparsley', 'seperate-video-versions', 'no-clean-infojson', 'no-keep-subs', 'no-certifi',
}, 'aliases': {
'youtube-dl': ['-multistreams', 'all'],
'youtube-dlc': ['-no-youtube-channel-redirect', '-no-live-chat', 'all'],
help='Number of retries (default is %default), or "infinite"')
downloader.add_option(
'--file-access-retries',
- dest='file_access_retries', metavar='RETRIES', default=10,
+ dest='file_access_retries', metavar='RETRIES', default=3,
help='Number of times to retry on file access error (default is %default), or "infinite"')
downloader.add_option(
'--fragment-retries',
workarounds.add_option(
'--user-agent',
metavar='UA', dest='user_agent',
- help='Specify a custom user agent')
+ help=optparse.SUPPRESS_HELP)
workarounds.add_option(
'--referer',
metavar='URL', dest='referer', default=None,
- help='Specify a custom referer, use if the video access is restricted to one domain',
- )
+ help=optparse.SUPPRESS_HELP)
workarounds.add_option(
'--add-header',
metavar='FIELD:VALUE', dest='headers', default={}, type='str',
action='callback', callback=_dict_from_options_callback,
- callback_kwargs={'multiple_keys': False, 'process_key': None},
+ callback_kwargs={'multiple_keys': False},
help='Specify a custom HTTP header and its value, separated by a colon ":". You can use this option multiple times',
)
workarounds.add_option(
help='Do not write video description (default)')
filesystem.add_option(
'--write-info-json',
- action='store_true', dest='writeinfojson', default=False,
+ action='store_true', dest='writeinfojson', default=None,
help='Write video metadata to a .info.json file (this may contain personal information)')
filesystem.add_option(
'--no-write-info-json',
action='store_false', dest='allow_playlist_files',
help='Do not write playlist metadata when using --write-info-json, --write-description etc.')
filesystem.add_option(
- '--clean-infojson',
+ '--clean-info-json', '--clean-infojson',
action='store_true', dest='clean_infojson', default=None,
help=(
'Remove some private fields such as filenames from the infojson. '
'Note that it could still contain some personal information (default)'))
filesystem.add_option(
- '--no-clean-infojson',
+ '--no-clean-info-json', '--no-clean-infojson',
action='store_false', dest='clean_infojson',
help='Write all fields to the infojson')
filesystem.add_option(
'and (optionally) arguments to be passed to it, separated by a colon ":". '
'ARGS are a semicolon ";" delimited list of NAME=VALUE. '
'The "when" argument determines when the postprocessor is invoked. '
- 'It can be one of "pre_process" (after extraction), '
- '"before_dl" (before video download), "post_process" (after video download; default), '
- '"after_move" (after moving file to their final locations), '
+ 'It can be one of "pre_process" (after video extraction), "after_filter" (after video passes filter), '
+ '"before_dl" (before each video download), "post_process" (after each video download; default), '
+ '"after_move" (after moving video file to it\'s final locations), '
'"after_video" (after downloading and processing all formats of a video), '
- 'or "playlist" (end of playlist). '
+ 'or "playlist" (at end of playlist). '
'This option can be used multiple times to add different postprocessors'))
sponsorblock = optparse.OptionGroup(parser, 'SponsorBlock Options', description=(