1 from __future__
import unicode_literals
8 from .downloader
.external
import list_external_downloaders
11 compat_get_terminal_size
,
22 from .version
import __version__
25 _remux_formats
= ('mp4', 'mkv', 'flv', 'webm', 'mov', 'avi', 'mp3', 'mka', 'm4a', 'ogg', 'opus')
28 def _hide_login_info(opts
):
29 PRIVATE_OPTS
= set(['-p', '--password', '-u', '--username', '--video-password', '--ap-password', '--ap-username'])
30 eqre
= re
.compile('^(?P<key>' + ('|'.join(re
.escape(po
) for po
in PRIVATE_OPTS
)) + ')=.+$')
35 return m
.group('key') + '=PRIVATE'
39 opts
= list(map(_scrub_eq
, opts
))
40 for idx
, opt
in enumerate(opts
):
41 if opt
in PRIVATE_OPTS
and idx
+ 1 < len(opts
):
42 opts
[idx
+ 1] = 'PRIVATE'
46 def parseOpts(overrideArguments
=None):
47 def _readOptions(filename_bytes
, default
=[]):
49 optionf
= open(filename_bytes
)
51 return default
# silently skip if file is not present
53 # FIXME: https://github.com/ytdl-org/youtube-dl/commit/dfe5fa49aed02cf36ba9f743b11b0903554b5e56
54 contents
= optionf
.read()
55 if sys
.version_info
< (3,):
56 contents
= contents
.decode(preferredencoding())
57 res
= compat_shlex_split(contents
, comments
=True)
62 def _readUserConf(package_name
, default
=[]):
64 xdg_config_home
= compat_getenv('XDG_CONFIG_HOME') or compat_expanduser('~/.config')
65 userConfFile
= os
.path
.join(xdg_config_home
, package_name
, 'config')
66 if not os
.path
.isfile(userConfFile
):
67 userConfFile
= os
.path
.join(xdg_config_home
, '%s.conf' % package_name
)
68 userConf
= _readOptions(userConfFile
, default
=None)
69 if userConf
is not None:
70 return userConf
, userConfFile
73 appdata_dir
= compat_getenv('appdata')
75 userConfFile
= os
.path
.join(appdata_dir
, package_name
, 'config')
76 userConf
= _readOptions(userConfFile
, default
=None)
78 userConfFile
+= '.txt'
79 userConf
= _readOptions(userConfFile
, default
=None)
80 if userConf
is not None:
81 return userConf
, userConfFile
84 userConfFile
= os
.path
.join(compat_expanduser('~'), '%s.conf' % package_name
)
85 userConf
= _readOptions(userConfFile
, default
=None)
87 userConfFile
+= '.txt'
88 userConf
= _readOptions(userConfFile
, default
=None)
89 if userConf
is not None:
90 return userConf
, userConfFile
94 def _format_option_string(option
):
95 ''' ('-o', '--option') -> -o, --format METAVAR'''
99 if option
._short
_opts
:
100 opts
.append(option
._short
_opts
[0])
101 if option
._long
_opts
:
102 opts
.append(option
._long
_opts
[0])
106 if option
.takes_value():
107 opts
.append(' %s' % option
.metavar
)
111 def _comma_separated_values_options_callback(option
, opt_str
, value
, parser
):
112 setattr(parser
.values
, option
.dest
, value
.split(','))
114 def _dict_from_multiple_values_options_callback(
115 option
, opt_str
, value
, parser
, allowed_keys
=r
'[\w-]+', delimiter
=':', default_key
=None, process
=None):
117 out_dict
= getattr(parser
.values
, option
.dest
)
118 mobj
= re
.match(r
'(?i)(?P<key>%s)%s(?P<val>.*)$' % (allowed_keys
, delimiter
), value
)
120 key
, val
= mobj
.group('key').lower(), mobj
.group('val')
121 elif default_key
is not None:
122 key
, val
= default_key
, value
124 raise optparse
.OptionValueError(
125 'wrong %s formatting; it should be %s, not "%s"' % (opt_str
, option
.metavar
, value
))
126 out_dict
[key
] = process(val
) if callable(process
) else val
128 # No need to wrap help messages if we're on a wide console
129 columns
= compat_get_terminal_size().columns
130 max_width
= columns
if columns
else 80
131 max_help_position
= 80
133 fmt
= optparse
.IndentedHelpFormatter(width
=max_width
, max_help_position
=max_help_position
)
134 fmt
.format_option_strings
= _format_option_string
137 'version': __version__
,
139 'usage': '%prog [OPTIONS] URL [URL...]',
140 'conflict_handler': 'resolve',
143 parser
= optparse
.OptionParser(**compat_kwargs(kw
))
145 general
= optparse
.OptionGroup(parser
, 'General Options')
149 help='Print this help text and exit')
153 help='Print program version and exit')
156 action
='store_true', dest
='update_self',
157 help='[BROKEN] Update this program to latest version. Make sure that you have sufficient permissions (run with sudo if needed)')
159 '-i', '--ignore-errors', '--no-abort-on-error',
160 action
='store_true', dest
='ignoreerrors', default
=True,
161 help='Continue on download errors, for example to skip unavailable videos in a playlist (default) (Alias: --no-abort-on-error)')
163 '--abort-on-error', '--no-ignore-errors',
164 action
='store_false', dest
='ignoreerrors',
165 help='Abort downloading of further videos if an error occurs (Alias: --no-ignore-errors)')
168 action
='store_true', dest
='dump_user_agent', default
=False,
169 help='Display the current browser identification')
172 action
='store_true', dest
='list_extractors', default
=False,
173 help='List all supported extractors')
175 '--extractor-descriptions',
176 action
='store_true', dest
='list_extractor_descriptions', default
=False,
177 help='Output descriptions of all supported extractors')
179 '--force-generic-extractor',
180 action
='store_true', dest
='force_generic_extractor', default
=False,
181 help='Force extraction to use the generic extractor')
184 dest
='default_search', metavar
='PREFIX',
185 help='Use this prefix for unqualified URLs. For example "gvsearch2:" downloads two videos from google videos for youtube-dl "large apple". Use the value "auto" to let youtube-dl guess ("auto_warning" to emit a warning when guessing). "error" just throws an error. The default value "fixup_error" repairs broken URLs, but emits an error if this is not possible instead of searching')
187 '--ignore-config', '--no-config',
190 'Disable loading any configuration files except the one provided by --config-location. '
191 'When given inside a configuration file, no further configuration files are loaded. '
192 'Additionally, (for backward compatibility) if this option is found inside the '
193 'system configuration file, the user configuration is not loaded'))
196 dest
='config_location', metavar
='PATH',
197 help='Location of the main configuration file; either the path to the config or its containing directory')
200 action
='store_const', dest
='extract_flat', const
='in_playlist', default
=False,
201 help='Do not extract the videos of a playlist, only list them')
204 action
='store_true', dest
='extract_flat',
205 help='Do not resolve the video urls')
207 '--no-flat-playlist',
208 action
='store_false', dest
='extract_flat',
209 help='Extract the videos of a playlist')
212 action
='store_true', dest
='mark_watched', default
=False,
213 help='Mark videos watched (YouTube only)')
216 action
='store_false', dest
='mark_watched', default
=False,
217 help='Do not mark videos watched')
220 action
='store_true', dest
='no_color',
222 help='Do not emit color codes in output')
224 network
= optparse
.OptionGroup(parser
, 'Network Options')
226 '--proxy', dest
='proxy',
227 default
=None, metavar
='URL',
229 'Use the specified HTTP/HTTPS/SOCKS proxy. To enable '
230 'SOCKS proxy, specify a proper scheme. For example '
231 'socks5://127.0.0.1:1080/. Pass in an empty string (--proxy "") '
232 'for direct connection'))
235 dest
='socket_timeout', type=float, default
=None, metavar
='SECONDS',
236 help='Time to wait before giving up, in seconds')
239 metavar
='IP', dest
='source_address', default
=None,
240 help='Client-side IP address to bind to',
243 '-4', '--force-ipv4',
244 action
='store_const', const
='0.0.0.0', dest
='source_address',
245 help='Make all connections via IPv4',
248 '-6', '--force-ipv6',
249 action
='store_const', const
='::', dest
='source_address',
250 help='Make all connections via IPv6',
253 geo
= optparse
.OptionGroup(parser
, 'Geo Restriction')
255 '--geo-verification-proxy',
256 dest
='geo_verification_proxy', default
=None, metavar
='URL',
258 'Use this proxy to verify the IP address for some geo-restricted sites. '
259 'The default proxy specified by --proxy (or none, if the option is not present) is used for the actual downloading'))
261 '--cn-verification-proxy',
262 dest
='cn_verification_proxy', default
=None, metavar
='URL',
263 help=optparse
.SUPPRESS_HELP
)
266 action
='store_true', dest
='geo_bypass', default
=True,
267 help='Bypass geographic restriction via faking X-Forwarded-For HTTP header')
270 action
='store_false', dest
='geo_bypass', default
=True,
271 help='Do not bypass geographic restriction via faking X-Forwarded-For HTTP header')
273 '--geo-bypass-country', metavar
='CODE',
274 dest
='geo_bypass_country', default
=None,
275 help='Force bypass geographic restriction with explicitly provided two-letter ISO 3166-2 country code')
277 '--geo-bypass-ip-block', metavar
='IP_BLOCK',
278 dest
='geo_bypass_ip_block', default
=None,
279 help='Force bypass geographic restriction with explicitly provided IP block in CIDR notation')
281 selection
= optparse
.OptionGroup(parser
, 'Video Selection')
282 selection
.add_option(
284 dest
='playliststart', metavar
='NUMBER', default
=1, type=int,
285 help='Playlist video to start at (default is %default)')
286 selection
.add_option(
288 dest
='playlistend', metavar
='NUMBER', default
=None, type=int,
289 help='Playlist video to end at (default is last)')
290 selection
.add_option(
292 dest
='playlist_items', metavar
='ITEM_SPEC', default
=None,
293 help='Playlist video items to download. Specify indices of the videos in the playlist separated by commas like: "--playlist-items 1,2,5,8" if you want to download videos indexed 1, 2, 5, 8 in the playlist. You can specify range: "--playlist-items 1-3,7,10-13", it will download the videos at index 1, 2, 3, 7, 10, 11, 12 and 13')
294 selection
.add_option(
296 dest
='matchtitle', metavar
='REGEX',
297 help='Download only matching titles (regex or caseless sub-string)')
298 selection
.add_option(
300 dest
='rejecttitle', metavar
='REGEX',
301 help='Skip download for matching titles (regex or caseless sub-string)')
302 selection
.add_option(
304 dest
='max_downloads', metavar
='NUMBER', type=int, default
=None,
305 help='Abort after downloading NUMBER files')
306 selection
.add_option(
308 metavar
='SIZE', dest
='min_filesize', default
=None,
309 help='Do not download any videos smaller than SIZE (e.g. 50k or 44.6m)')
310 selection
.add_option(
312 metavar
='SIZE', dest
='max_filesize', default
=None,
313 help='Do not download any videos larger than SIZE (e.g. 50k or 44.6m)')
314 selection
.add_option(
316 metavar
='DATE', dest
='date', default
=None,
318 'Download only videos uploaded in this date. '
319 'The date can be "YYYYMMDD" or in the format '
320 '"(now|today)[+-][0-9](day|week|month|year)(s)?"'))
321 selection
.add_option(
323 metavar
='DATE', dest
='datebefore', default
=None,
325 'Download only videos uploaded on or before this date. '
326 'The date formats accepted is the same as --date'))
327 selection
.add_option(
329 metavar
='DATE', dest
='dateafter', default
=None,
331 'Download only videos uploaded on or after this date. '
332 'The date formats accepted is the same as --date'))
333 selection
.add_option(
335 metavar
='COUNT', dest
='min_views', default
=None, type=int,
336 help='Do not download any videos with less than COUNT views')
337 selection
.add_option(
339 metavar
='COUNT', dest
='max_views', default
=None, type=int,
340 help='Do not download any videos with more than COUNT views')
341 selection
.add_option(
343 metavar
='FILTER', dest
='match_filter', default
=None,
345 'Generic video filter. '
346 'Specify any key (see "OUTPUT TEMPLATE" for a list of available keys) to '
347 'match if the key is present, '
348 '!key to check if the key is not present, '
349 'key>NUMBER (like "comment_count > 12", also works with '
350 '>=, <, <=, !=, =) to compare against a number, '
351 'key = \'LITERAL\' (like "uploader = \'Mike Smith\'", also works with !=) '
352 'to match against a string literal '
353 'and & to require multiple matches. '
354 'Values which are not known are excluded unless you '
355 'put a question mark (?) after the operator. '
356 'For example, to only match videos that have been liked more than '
357 '100 times and disliked less than 50 times (or the dislike '
358 'functionality is not available at the given service), but who '
359 'also have a description, use --match-filter '
360 '"like_count > 100 & dislike_count <? 50 & description"'))
361 selection
.add_option(
363 metavar
='FILTER', dest
='match_filter', action
='store_const', const
=None,
364 help='Do not use generic video filter (default)')
365 selection
.add_option(
367 action
='store_true', dest
='noplaylist', default
=False,
368 help='Download only the video, if the URL refers to a video and a playlist')
369 selection
.add_option(
371 action
='store_false', dest
='noplaylist', default
=False,
372 help='Download the playlist, if the URL refers to a video and a playlist')
373 selection
.add_option(
375 metavar
='YEARS', dest
='age_limit', default
=None, type=int,
376 help='Download only videos suitable for the given age')
377 selection
.add_option(
378 '--download-archive', metavar
='FILE',
379 dest
='download_archive',
380 help='Download only videos not listed in the archive file. Record the IDs of all downloaded videos in it')
381 selection
.add_option(
382 '--break-on-existing',
383 action
='store_true', dest
='break_on_existing', default
=False,
384 help='Stop the download process when encountering a file that is in the archive')
385 selection
.add_option(
387 action
='store_true', dest
='break_on_reject', default
=False,
388 help='Stop the download process when encountering a file that has been filtered out')
389 selection
.add_option(
390 '--no-download-archive',
391 dest
='download_archive', action
="store_const", const
=None,
392 help='Do not use archive file (default)')
393 selection
.add_option(
395 dest
='include_ads', action
='store_true',
396 help='Download advertisements as well (experimental)')
397 selection
.add_option(
399 dest
='include_ads', action
='store_false',
400 help='Do not download advertisements (default)')
402 authentication
= optparse
.OptionGroup(parser
, 'Authentication Options')
403 authentication
.add_option(
405 dest
='username', metavar
='USERNAME',
406 help='Login with this account ID')
407 authentication
.add_option(
409 dest
='password', metavar
='PASSWORD',
410 help='Account password. If this option is left out, youtube-dlc will ask interactively')
411 authentication
.add_option(
413 dest
='twofactor', metavar
='TWOFACTOR',
414 help='Two-factor authentication code')
415 authentication
.add_option(
417 action
='store_true', dest
='usenetrc', default
=False,
418 help='Use .netrc authentication data')
419 authentication
.add_option(
421 dest
='videopassword', metavar
='PASSWORD',
422 help='Video password (vimeo, youku)')
424 adobe_pass
= optparse
.OptionGroup(parser
, 'Adobe Pass Options')
425 adobe_pass
.add_option(
427 dest
='ap_mso', metavar
='MSO',
428 help='Adobe Pass multiple-system operator (TV provider) identifier, use --ap-list-mso for a list of available MSOs')
429 adobe_pass
.add_option(
431 dest
='ap_username', metavar
='USERNAME',
432 help='Multiple-system operator account login')
433 adobe_pass
.add_option(
435 dest
='ap_password', metavar
='PASSWORD',
436 help='Multiple-system operator account password. If this option is left out, youtube-dlc will ask interactively')
437 adobe_pass
.add_option(
439 action
='store_true', dest
='ap_list_mso', default
=False,
440 help='List all supported multiple-system operators')
442 video_format
= optparse
.OptionGroup(parser
, 'Video Format Options')
443 video_format
.add_option(
445 action
='store', dest
='format', metavar
='FORMAT', default
=None,
446 help='Video format code, see "FORMAT SELECTION" for more details')
447 video_format
.add_option(
448 '-S', '--format-sort', metavar
='SORTORDER',
449 dest
='format_sort', default
=[],
450 action
='callback', callback
=_comma_separated_values_options_callback
, type='str',
451 help='Sort the formats by the fields given, see "Sorting Formats" for more details')
452 video_format
.add_option(
453 '--format-sort-force', '--S-force',
454 action
='store_true', dest
='format_sort_force', metavar
='FORMAT', default
=False,
456 'Force user specified sort order to have precedence over all fields, '
457 'see "Sorting Formats" for more details'))
458 video_format
.add_option(
459 '--no-format-sort-force',
460 action
='store_false', dest
='format_sort_force', metavar
='FORMAT', default
=False,
462 'Some fields have precedence over the user specified sort order (default), '
463 'see "Sorting Formats" for more details'))
464 video_format
.add_option(
465 '--video-multistreams',
466 action
='store_true', dest
='allow_multiple_video_streams', default
=False,
467 help='Allow multiple video streams to be merged into a single file')
468 video_format
.add_option(
469 '--no-video-multistreams',
470 action
='store_false', dest
='allow_multiple_video_streams',
471 help='Only one video stream is downloaded for each output file (default)')
472 video_format
.add_option(
473 '--audio-multistreams',
474 action
='store_true', dest
='allow_multiple_audio_streams', default
=False,
475 help='Allow multiple audio streams to be merged into a single file')
476 video_format
.add_option(
477 '--no-audio-multistreams',
478 action
='store_false', dest
='allow_multiple_audio_streams',
479 help='Only one audio stream is downloaded for each output file (default)')
480 video_format
.add_option(
482 action
='store_const', dest
='format', const
='all',
483 help='Download all available video formats')
484 video_format
.add_option(
485 '--prefer-free-formats',
486 action
='store_true', dest
='prefer_free_formats', default
=False,
487 help='Prefer free video formats over non-free formats of same quality')
488 video_format
.add_option(
489 '-F', '--list-formats',
490 action
='store_true', dest
='listformats',
491 help='List all available formats of requested videos')
492 video_format
.add_option(
493 '--list-formats-as-table',
494 action
='store_true', dest
='listformats_table', default
=True,
495 help='Present the output of -F in tabular form (default)')
496 video_format
.add_option(
497 '--list-formats-old', '--no-list-formats-as-table',
498 action
='store_false', dest
='listformats_table',
499 help='Present the output of -F in the old form (Alias: --no-list-formats-as-table)')
500 video_format
.add_option(
501 '--youtube-include-dash-manifest', '--no-youtube-skip-dash-manifest',
502 action
='store_true', dest
='youtube_include_dash_manifest', default
=True,
503 help='Download the DASH manifests and related data on YouTube videos (default) (Alias: --no-youtube-skip-dash-manifest)')
504 video_format
.add_option(
505 '--youtube-skip-dash-manifest', '--no-youtube-include-dash-manifest',
506 action
='store_false', dest
='youtube_include_dash_manifest',
507 help='Do not download the DASH manifests and related data on YouTube videos (Alias: --no-youtube-include-dash-manifest)')
508 video_format
.add_option(
509 '--youtube-include-hls-manifest', '--no-youtube-skip-hls-manifest',
510 action
='store_true', dest
='youtube_include_hls_manifest', default
=True,
511 help='Download the HLS manifests and related data on YouTube videos (default) (Alias: --no-youtube-skip-hls-manifest)')
512 video_format
.add_option(
513 '--youtube-skip-hls-manifest', '--no-youtube-include-hls-manifest',
514 action
='store_false', dest
='youtube_include_hls_manifest',
515 help='Do not download the HLS manifests and related data on YouTube videos (Alias: --no-youtube-include-hls-manifest)')
516 video_format
.add_option(
517 '--merge-output-format',
518 action
='store', dest
='merge_output_format', metavar
='FORMAT', default
=None,
520 'If a merge is required (e.g. bestvideo+bestaudio), '
521 'output to given container format. One of mkv, mp4, ogg, webm, flv. '
522 'Ignored if no merge is required'))
524 subtitles
= optparse
.OptionGroup(parser
, 'Subtitle Options')
525 subtitles
.add_option(
526 '--write-subs', '--write-srt',
527 action
='store_true', dest
='writesubtitles', default
=False,
528 help='Write subtitle file')
529 subtitles
.add_option(
530 '--no-write-subs', '--no-write-srt',
531 action
='store_false', dest
='writesubtitles',
532 help='Do not write subtitle file (default)')
533 subtitles
.add_option(
534 '--write-auto-subs', '--write-automatic-subs',
535 action
='store_true', dest
='writeautomaticsub', default
=False,
536 help='Write automatically generated subtitle file (YouTube only)')
537 subtitles
.add_option(
538 '--no-write-auto-subs', '--no-write-automatic-subs',
539 action
='store_false', dest
='writeautomaticsub', default
=False,
540 help='Do not write automatically generated subtitle file (default)')
541 subtitles
.add_option(
543 action
='store_true', dest
='allsubtitles', default
=False,
544 help='Download all the available subtitles of the video')
545 subtitles
.add_option(
547 action
='store_true', dest
='listsubtitles', default
=False,
548 help='List all available subtitles for the video')
549 subtitles
.add_option(
551 action
='store', dest
='subtitlesformat', metavar
='FORMAT', default
='best',
552 help='Subtitle format, accepts formats preference, for example: "srt" or "ass/srt/best"')
553 subtitles
.add_option(
554 '--sub-lang', '--sub-langs', '--srt-lang',
555 action
='callback', dest
='subtitleslangs', metavar
='LANGS', type='str',
556 default
=[], callback
=_comma_separated_values_options_callback
,
557 help='Languages of the subtitles to download (optional) separated by commas, use --list-subs for available language tags')
559 downloader
= optparse
.OptionGroup(parser
, 'Download Options')
560 downloader
.add_option(
561 '-r', '--limit-rate', '--rate-limit',
562 dest
='ratelimit', metavar
='RATE',
563 help='Maximum download rate in bytes per second (e.g. 50K or 4.2M)')
564 downloader
.add_option(
566 dest
='retries', metavar
='RETRIES', default
=10,
567 help='Number of retries (default is %default), or "infinite"')
568 downloader
.add_option(
569 '--fragment-retries',
570 dest
='fragment_retries', metavar
='RETRIES', default
=10,
571 help='Number of retries for a fragment (default is %default), or "infinite" (DASH, hlsnative and ISM)')
572 downloader
.add_option(
573 '--skip-unavailable-fragments', '--no-abort-on-unavailable-fragment',
574 action
='store_true', dest
='skip_unavailable_fragments', default
=True,
575 help='Skip unavailable fragments for DASH, hlsnative and ISM (default) (Alias: --no-abort-on-unavailable-fragment)')
576 downloader
.add_option(
577 '--abort-on-unavailable-fragment', '--no-skip-unavailable-fragments',
578 action
='store_false', dest
='skip_unavailable_fragments',
579 help='Abort downloading if a fragment is unavailable (Alias: --no-skip-unavailable-fragments)')
580 downloader
.add_option(
582 action
='store_true', dest
='keep_fragments', default
=False,
583 help='Keep downloaded fragments on disk after downloading is finished')
584 downloader
.add_option(
585 '--no-keep-fragments',
586 action
='store_false', dest
='keep_fragments',
587 help='Delete downloaded fragments after downloading is finished (default)')
588 downloader
.add_option(
590 dest
='buffersize', metavar
='SIZE', default
='1024',
591 help='Size of download buffer (e.g. 1024 or 16K) (default is %default)')
592 downloader
.add_option(
594 action
='store_false', dest
='noresizebuffer',
595 help='The buffer size is automatically resized from an initial value of --buffer-size (default)')
596 downloader
.add_option(
597 '--no-resize-buffer',
598 action
='store_true', dest
='noresizebuffer', default
=False,
599 help='Do not automatically adjust the buffer size')
600 downloader
.add_option(
602 dest
='http_chunk_size', metavar
='SIZE', default
=None,
604 'Size of a chunk for chunk-based HTTP downloading (e.g. 10485760 or 10M) (default is disabled). '
605 'May be useful for bypassing bandwidth throttling imposed by a webserver (experimental)'))
606 downloader
.add_option(
608 action
='store_true', dest
='test', default
=False,
609 help=optparse
.SUPPRESS_HELP
)
610 downloader
.add_option(
611 '--playlist-reverse',
613 help='Download playlist videos in reverse order')
614 downloader
.add_option(
615 '--no-playlist-reverse',
616 action
='store_false', dest
='playlist_reverse',
617 help='Download playlist videos in default order (default)')
618 downloader
.add_option(
621 help='Download playlist videos in random order')
622 downloader
.add_option(
623 '--xattr-set-filesize',
624 dest
='xattr_set_filesize', action
='store_true',
625 help='Set file xattribute ytdl.filesize with expected file size')
626 downloader
.add_option(
627 '--hls-prefer-native',
628 dest
='hls_prefer_native', action
='store_true', default
=None,
629 help='Use the native HLS downloader instead of ffmpeg')
630 downloader
.add_option(
631 '--hls-prefer-ffmpeg',
632 dest
='hls_prefer_native', action
='store_false', default
=None,
633 help='Use ffmpeg instead of the native HLS downloader')
634 downloader
.add_option(
636 dest
='hls_use_mpegts', action
='store_true',
638 'Use the mpegts container for HLS videos, allowing to play the '
639 'video while downloading (some players may not be able to play it)'))
640 downloader
.add_option(
641 '--external-downloader',
642 dest
='external_downloader', metavar
='NAME',
644 'Use the specified external downloader. '
645 'Currently supports %s' % ', '.join(list_external_downloaders())))
646 downloader
.add_option(
647 '--downloader-args', '--external-downloader-args',
648 metavar
='NAME:ARGS', dest
='external_downloader_args', default
={}, type='str',
649 action
='callback', callback
=_dict_from_multiple_values_options_callback
,
651 'allowed_keys': '|'.join(list_external_downloaders()),
652 'default_key': 'default', 'process': compat_shlex_split
},
654 'Give these arguments to the external downloader. '
655 'Specify the downloader name and the arguments separated by a colon ":". '
656 'You can use this option multiple times (Alias: --external-downloader-args)'))
658 workarounds
= optparse
.OptionGroup(parser
, 'Workarounds')
659 workarounds
.add_option(
661 dest
='encoding', metavar
='ENCODING',
662 help='Force the specified encoding (experimental)')
663 workarounds
.add_option(
664 '--no-check-certificate',
665 action
='store_true', dest
='no_check_certificate', default
=False,
666 help='Suppress HTTPS certificate validation')
667 workarounds
.add_option(
668 '--prefer-insecure', '--prefer-unsecure',
669 action
='store_true', dest
='prefer_insecure',
670 help='Use an unencrypted connection to retrieve information about the video. (Currently supported only for YouTube)')
671 workarounds
.add_option(
673 metavar
='UA', dest
='user_agent',
674 help='Specify a custom user agent')
675 workarounds
.add_option(
677 metavar
='URL', dest
='referer', default
=None,
678 help='Specify a custom referer, use if the video access is restricted to one domain',
680 workarounds
.add_option(
682 metavar
='FIELD:VALUE', dest
='headers', default
={}, type='str',
683 action
='callback', callback
=_dict_from_multiple_values_options_callback
,
684 help='Specify a custom HTTP header and its value, separated by a colon ":". You can use this option multiple times',
686 workarounds
.add_option(
688 dest
='bidi_workaround', action
='store_true',
689 help='Work around terminals that lack bidirectional text support. Requires bidiv or fribidi executable in PATH')
690 workarounds
.add_option(
691 '--sleep-interval', '--min-sleep-interval', metavar
='SECONDS',
692 dest
='sleep_interval', type=float,
694 'Number of seconds to sleep before each download when used alone '
695 'or a lower bound of a range for randomized sleep before each download '
696 '(minimum possible number of seconds to sleep) when used along with '
697 '--max-sleep-interval'))
698 workarounds
.add_option(
699 '--max-sleep-interval', metavar
='SECONDS',
700 dest
='max_sleep_interval', type=float,
702 'Upper bound of a range for randomized sleep before each download '
703 '(maximum possible number of seconds to sleep). Must only be used '
704 'along with --min-sleep-interval'))
705 workarounds
.add_option(
706 '--sleep-subtitles', metavar
='SECONDS',
707 dest
='sleep_interval_subtitles', default
=0, type=int,
708 help='Enforce sleep interval on subtitles as well')
710 verbosity
= optparse
.OptionGroup(parser
, 'Verbosity / Simulation Options')
711 verbosity
.add_option(
713 action
='store_true', dest
='quiet', default
=False,
714 help='Activate quiet mode')
715 verbosity
.add_option(
717 dest
='no_warnings', action
='store_true', default
=False,
718 help='Ignore warnings')
719 verbosity
.add_option(
721 action
='store_true', dest
='simulate', default
=False,
722 help='Do not download the video and do not write anything to disk')
723 verbosity
.add_option(
724 '--skip-download', '--no-download',
725 action
='store_true', dest
='skip_download', default
=False,
726 help='Do not download the video')
727 verbosity
.add_option(
729 action
='store_true', dest
='geturl', default
=False,
730 help='Simulate, quiet but print URL')
731 verbosity
.add_option(
733 action
='store_true', dest
='gettitle', default
=False,
734 help='Simulate, quiet but print title')
735 verbosity
.add_option(
737 action
='store_true', dest
='getid', default
=False,
738 help='Simulate, quiet but print id')
739 verbosity
.add_option(
741 action
='store_true', dest
='getthumbnail', default
=False,
742 help='Simulate, quiet but print thumbnail URL')
743 verbosity
.add_option(
745 action
='store_true', dest
='getdescription', default
=False,
746 help='Simulate, quiet but print video description')
747 verbosity
.add_option(
749 action
='store_true', dest
='getduration', default
=False,
750 help='Simulate, quiet but print video length')
751 verbosity
.add_option(
753 action
='store_true', dest
='getfilename', default
=False,
754 help='Simulate, quiet but print output filename')
755 verbosity
.add_option(
757 action
='store_true', dest
='getformat', default
=False,
758 help='Simulate, quiet but print output format')
759 verbosity
.add_option(
761 action
='store_true', dest
='dumpjson', default
=False,
762 help='Simulate, quiet but print JSON information. See "OUTPUT TEMPLATE" for a description of available keys')
763 verbosity
.add_option(
764 '-J', '--dump-single-json',
765 action
='store_true', dest
='dump_single_json', default
=False,
767 'Simulate, quiet but print JSON information for each command-line argument. '
768 'If the URL refers to a playlist, dump the whole playlist information in a single line'))
769 verbosity
.add_option(
771 action
='store_true', dest
='print_json', default
=False,
772 help='Be quiet and print the video information as JSON (video is still being downloaded)')
773 verbosity
.add_option(
774 '--force-write-archive', '--force-write-download-archive', '--force-download-archive',
775 action
='store_true', dest
='force_write_download_archive', default
=False,
777 'Force download archive entries to be written as far as no errors occur,'
778 'even if -s or another simulation switch is used (Alias: --force-download-archive)'))
779 verbosity
.add_option(
781 action
='store_true', dest
='progress_with_newline', default
=False,
782 help='Output progress bar as new lines')
783 verbosity
.add_option(
785 action
='store_true', dest
='noprogress', default
=False,
786 help='Do not print progress bar')
787 verbosity
.add_option(
789 action
='store_true', dest
='consoletitle', default
=False,
790 help='Display progress in console titlebar')
791 verbosity
.add_option(
793 action
='store_true', dest
='verbose', default
=False,
794 help='Print various debugging information')
795 verbosity
.add_option(
796 '--dump-pages', '--dump-intermediate-pages',
797 action
='store_true', dest
='dump_intermediate_pages', default
=False,
798 help='Print downloaded pages encoded using base64 to debug problems (very verbose)')
799 verbosity
.add_option(
801 action
='store_true', dest
='write_pages', default
=False,
802 help='Write downloaded intermediary pages to files in the current directory to debug problems')
803 verbosity
.add_option(
804 '--youtube-print-sig-code',
805 action
='store_true', dest
='youtube_print_sig_code', default
=False,
806 help=optparse
.SUPPRESS_HELP
)
807 verbosity
.add_option(
808 '--print-traffic', '--dump-headers',
809 dest
='debug_printtraffic', action
='store_true', default
=False,
810 help='Display sent and read HTTP traffic')
811 verbosity
.add_option(
813 dest
='call_home', action
='store_true', default
=False,
814 help='[Broken] Contact the youtube-dlc server for debugging')
815 verbosity
.add_option(
817 dest
='call_home', action
='store_false',
818 help='Do not contact the youtube-dlc server for debugging (default)')
820 filesystem
= optparse
.OptionGroup(parser
, 'Filesystem Options')
821 filesystem
.add_option(
822 '-a', '--batch-file',
823 dest
='batchfile', metavar
='FILE',
824 help="File containing URLs to download ('-' for stdin), one URL per line. "
825 "Lines starting with '#', ';' or ']' are considered as comments and ignored")
826 filesystem
.add_option(
827 '--id', default
=False,
828 action
='store_true', dest
='useid', help=optparse
.SUPPRESS_HELP
)
829 filesystem
.add_option(
831 metavar
='TYPE:PATH', dest
='paths', default
={}, type='str',
832 action
='callback', callback
=_dict_from_multiple_values_options_callback
,
834 'allowed_keys': 'home|temp|config|description|annotation|subtitle|infojson|thumbnail',
835 'process': lambda x
: x
.strip()},
837 'The paths where the files should be downloaded. '
838 'Specify the type of file and the path separated by a colon ":" '
839 '(supported: description|annotation|subtitle|infojson|thumbnail). '
840 'Additionally, you can also provide "home" and "temp" paths. '
841 'All intermediary files are first downloaded to the temp path and '
842 'then the final files are moved over to the home path after download is finished. '
843 'Note that this option is ignored if --output is an absolute path'))
844 filesystem
.add_option(
846 dest
='outtmpl', metavar
='TEMPLATE',
847 help='Output filename template, see "OUTPUT TEMPLATE" for details')
848 filesystem
.add_option(
849 '--output-na-placeholder',
850 dest
='outtmpl_na_placeholder', metavar
='TEXT', default
='NA',
851 help=('Placeholder value for unavailable meta fields in output filename template (default: "%default")'))
852 filesystem
.add_option(
854 dest
='autonumber_size', metavar
='NUMBER', type=int,
855 help=optparse
.SUPPRESS_HELP
)
856 filesystem
.add_option(
857 '--autonumber-start',
858 dest
='autonumber_start', metavar
='NUMBER', default
=1, type=int,
859 help='Specify the start value for %(autonumber)s (default is %default)')
860 filesystem
.add_option(
861 '--restrict-filenames',
862 action
='store_true', dest
='restrictfilenames', default
=False,
863 help='Restrict filenames to only ASCII characters, and avoid "&" and spaces in filenames')
864 filesystem
.add_option(
865 '--no-restrict-filenames',
866 action
='store_false', dest
='restrictfilenames', default
=False,
867 help='Allow Unicode characters, "&" and spaces in filenames (default)')
868 filesystem
.add_option(
869 '-A', '--auto-number',
870 action
='store_true', dest
='autonumber', default
=False,
871 help=optparse
.SUPPRESS_HELP
)
872 filesystem
.add_option(
874 action
='store_true', dest
='usetitle', default
=False,
875 help=optparse
.SUPPRESS_HELP
)
876 filesystem
.add_option(
877 '-l', '--literal', default
=False,
878 action
='store_true', dest
='usetitle',
879 help=optparse
.SUPPRESS_HELP
)
880 filesystem
.add_option(
881 '-w', '--no-overwrites',
882 action
='store_false', dest
='overwrites', default
=None,
883 help='Do not overwrite any files')
884 filesystem
.add_option(
885 '--force-overwrites', '--yes-overwrites',
886 action
='store_true', dest
='overwrites',
887 help='Overwrite all video and metadata files. This option includes --no-continue')
888 filesystem
.add_option(
889 '--no-force-overwrites',
890 action
='store_const', dest
='overwrites', const
=None,
891 help='Do not overwrite the video, but overwrite related files (default)')
892 filesystem
.add_option(
894 action
='store_true', dest
='continue_dl', default
=True,
895 help='Resume partially downloaded files (default)')
896 filesystem
.add_option(
898 action
='store_false', dest
='continue_dl',
899 help='Restart download of partially downloaded files from beginning')
900 filesystem
.add_option(
902 action
='store_false', dest
='nopart', default
=False,
903 help='Use .part files instead of writing directly into output file (default)')
904 filesystem
.add_option(
906 action
='store_true', dest
='nopart',
907 help='Do not use .part files - write directly into output file')
908 filesystem
.add_option(
910 action
='store_true', dest
='updatetime', default
=True,
911 help='Use the Last-modified header to set the file modification time (default)')
912 filesystem
.add_option(
914 action
='store_false', dest
='updatetime',
915 help='Do not use the Last-modified header to set the file modification time')
916 filesystem
.add_option(
917 '--write-description',
918 action
='store_true', dest
='writedescription', default
=False,
919 help='Write video description to a .description file')
920 filesystem
.add_option(
921 '--no-write-description',
922 action
='store_false', dest
='writedescription',
923 help='Do not write video description (default)')
924 filesystem
.add_option(
926 action
='store_true', dest
='writeinfojson', default
=False,
927 help='Write video metadata to a .info.json file')
928 filesystem
.add_option(
929 '--no-write-info-json',
930 action
='store_false', dest
='writeinfojson',
931 help='Do not write video metadata (default)')
932 filesystem
.add_option(
933 '--write-annotations',
934 action
='store_true', dest
='writeannotations', default
=False,
935 help='Write video annotations to a .annotations.xml file')
936 filesystem
.add_option(
937 '--no-write-annotations',
938 action
='store_false', dest
='writeannotations',
939 help='Do not write video annotations (default)')
940 filesystem
.add_option(
942 action
='store_true', dest
='getcomments', default
=False,
943 help='Retrieve video comments to be placed in the .info.json file')
944 filesystem
.add_option(
945 '--load-info-json', '--load-info',
946 dest
='load_info_filename', metavar
='FILE',
947 help='JSON file containing the video information (created with the "--write-info-json" option)')
948 filesystem
.add_option(
950 dest
='cookiefile', metavar
='FILE',
951 help='File to read cookies from and dump cookie jar in')
952 filesystem
.add_option(
954 action
='store_const', const
=None, dest
='cookiefile', metavar
='FILE',
955 help='Do not read/dump cookies (default)')
956 filesystem
.add_option(
957 '--cache-dir', dest
='cachedir', default
=None, metavar
='DIR',
958 help='Location in the filesystem where youtube-dl can store some downloaded information permanently. By default $XDG_CACHE_HOME/youtube-dl or ~/.cache/youtube-dl . At the moment, only YouTube player files (for videos with obfuscated signatures) are cached, but that may change')
959 filesystem
.add_option(
960 '--no-cache-dir', action
='store_false', dest
='cachedir',
961 help='Disable filesystem caching')
962 filesystem
.add_option(
964 action
='store_true', dest
='rm_cachedir',
965 help='Delete all filesystem cache files')
966 filesystem
.add_option(
967 '--trim-file-name', metavar
='LENGTH',
968 dest
='trim_file_name', default
=0, type=int,
969 help='Limit the filename length (extension excluded)')
971 thumbnail
= optparse
.OptionGroup(parser
, 'Thumbnail Images')
972 thumbnail
.add_option(
974 action
='store_true', dest
='writethumbnail', default
=False,
975 help='Write thumbnail image to disk')
976 thumbnail
.add_option(
977 '--no-write-thumbnail',
978 action
='store_false', dest
='writethumbnail',
979 help='Do not write thumbnail image to disk (default)')
980 thumbnail
.add_option(
981 '--write-all-thumbnails',
982 action
='store_true', dest
='write_all_thumbnails', default
=False,
983 help='Write all thumbnail image formats to disk')
984 thumbnail
.add_option(
986 action
='store_true', dest
='list_thumbnails', default
=False,
987 help='Simulate and list all available thumbnail formats')
989 link
= optparse
.OptionGroup(parser
, 'Internet Shortcut Options')
992 action
='store_true', dest
='writelink', default
=False,
993 help='Write an internet shortcut file, depending on the current platform (.url, .webloc or .desktop). The URL may be cached by the OS')
996 action
='store_true', dest
='writeurllink', default
=False,
997 help='Write a .url Windows internet shortcut. The OS caches the URL based on the file path')
999 '--write-webloc-link',
1000 action
='store_true', dest
='writewebloclink', default
=False,
1001 help='Write a .webloc macOS internet shortcut')
1003 '--write-desktop-link',
1004 action
='store_true', dest
='writedesktoplink', default
=False,
1005 help='Write a .desktop Linux internet shortcut')
1007 postproc
= optparse
.OptionGroup(parser
, 'Post-Processing Options')
1008 postproc
.add_option(
1009 '-x', '--extract-audio',
1010 action
='store_true', dest
='extractaudio', default
=False,
1011 help='Convert video files to audio-only files (requires ffmpeg and ffprobe)')
1012 postproc
.add_option(
1013 '--audio-format', metavar
='FORMAT', dest
='audioformat', default
='best',
1014 help='Specify audio format: "best", "aac", "flac", "mp3", "m4a", "opus", "vorbis", or "wav"; "%default" by default; No effect without -x')
1015 postproc
.add_option(
1016 '--audio-quality', metavar
='QUALITY',
1017 dest
='audioquality', default
='5',
1018 help='Specify ffmpeg audio quality, insert a value between 0 (better) and 9 (worse) for VBR or a specific bitrate like 128K (default %default)')
1019 postproc
.add_option(
1021 metavar
='FORMAT', dest
='remuxvideo', default
=None,
1023 'Remux the video into another container if necessary (currently supported: %s). '
1024 'If target container does not support the video/audio codec, remuxing will fail. '
1025 'You can specify multiple rules; eg. "aac>m4a/mov>mp4/mkv" will remux aac to m4a, mov to mp4 '
1026 'and anything else to mkv.' % '|'.join(_remux_formats
)))
1027 postproc
.add_option(
1029 metavar
='FORMAT', dest
='recodevideo', default
=None,
1031 'Re-encode the video into another format if re-encoding is necessary. '
1032 'The supported formats are the same as --remux-video'))
1033 postproc
.add_option(
1034 '--postprocessor-args', '--ppa',
1035 metavar
='NAME:ARGS', dest
='postprocessor_args', default
={}, type='str',
1036 action
='callback', callback
=_dict_from_multiple_values_options_callback
,
1037 callback_kwargs
={'default_key': 'default-compat', 'allowed_keys': r'\w+(?:\+\w+)?', 'process': compat_shlex_split}
,
1039 'Give these arguments to the postprocessors. '
1040 'Specify the postprocessor/executable name and the arguments separated by a colon ":" '
1041 'to give the argument to the specified postprocessor/executable. Supported postprocessors are: '
1042 'SponSkrub, ExtractAudio, VideoRemuxer, VideoConvertor, EmbedSubtitle, Metadata, Merger, '
1043 'FixupStretched, FixupM4a, FixupM3u8, SubtitlesConvertor and EmbedThumbnail. '
1044 'The supported executables are: SponSkrub, FFmpeg, FFprobe, and AtomicParsley. '
1045 'You can use this option multiple times to give different arguments to different postprocessors. '
1046 'You can also specify "PP+EXE:ARGS" to give the arguments to the specified executable '
1047 'only when being used by the specified postprocessor. '
1048 'You can use this option multiple times (Alias: --ppa)'))
1049 postproc
.add_option(
1050 '-k', '--keep-video',
1051 action
='store_true', dest
='keepvideo', default
=False,
1052 help='Keep the intermediate video file on disk after post-processing')
1053 postproc
.add_option(
1055 action
='store_false', dest
='keepvideo',
1056 help='Delete the intermediate video file after post-processing (default)')
1057 postproc
.add_option(
1058 '--post-overwrites',
1059 action
='store_false', dest
='nopostoverwrites',
1060 help='Overwrite post-processed files (default)')
1061 postproc
.add_option(
1062 '--no-post-overwrites',
1063 action
='store_true', dest
='nopostoverwrites', default
=False,
1064 help='Do not overwrite post-processed files')
1065 postproc
.add_option(
1067 action
='store_true', dest
='embedsubtitles', default
=False,
1068 help='Embed subtitles in the video (only for mp4, webm and mkv videos)')
1069 postproc
.add_option(
1071 action
='store_false', dest
='embedsubtitles',
1072 help='Do not embed subtitles (default)')
1073 postproc
.add_option(
1074 '--embed-thumbnail',
1075 action
='store_true', dest
='embedthumbnail', default
=False,
1076 help='Embed thumbnail in the audio as cover art')
1077 postproc
.add_option(
1078 '--no-embed-thumbnail',
1079 action
='store_false', dest
='embedthumbnail',
1080 help='Do not embed thumbnail (default)')
1081 postproc
.add_option(
1083 action
='store_true', dest
='addmetadata', default
=False,
1084 help='Write metadata to the video file')
1085 postproc
.add_option(
1086 '--no-add-metadata',
1087 action
='store_false', dest
='addmetadata',
1088 help='Do not write metadata (default)')
1089 postproc
.add_option(
1090 '--metadata-from-title',
1091 metavar
='FORMAT', dest
='metafromtitle',
1092 help=optparse
.SUPPRESS_HELP
)
1093 postproc
.add_option(
1095 metavar
='FIELD:FORMAT', dest
='metafromfield', action
='append',
1097 'Parse additional metadata like title/artist from other fields. '
1098 'Give field name to extract data from, and format of the field seperated by a ":". '
1099 'The format syntax is the same as --output. '
1100 'Regular expression with named capture groups may also be used. '
1101 'The parsed parameters replace existing values. '
1102 'This option can be used multiple times. '
1103 'Example: --parse-metadata "title:%(artist)s - %(title)s" matches a title like '
1104 '"Coldplay - Paradise". '
1105 'Example (regex): --parse-metadata "description:Artist - (?P<artist>.+?)"'))
1106 postproc
.add_option(
1108 action
='store_true', dest
='xattrs', default
=False,
1109 help='Write metadata to the video file\'s xattrs (using dublin core and xdg standards)')
1110 postproc
.add_option(
1112 metavar
='POLICY', dest
='fixup', default
='detect_or_warn',
1114 'Automatically correct known faults of the file. '
1115 'One of never (do nothing), warn (only emit a warning), '
1116 'detect_or_warn (the default; fix file if we can, warn otherwise)'))
1117 postproc
.add_option(
1118 '--prefer-avconv', '--no-prefer-ffmpeg',
1119 action
='store_false', dest
='prefer_ffmpeg',
1120 help=optparse
.SUPPRESS_HELP
)
1121 postproc
.add_option(
1122 '--prefer-ffmpeg', '--no-prefer-avconv',
1123 action
='store_true', dest
='prefer_ffmpeg', default
=True,
1124 help=optparse
.SUPPRESS_HELP
)
1125 postproc
.add_option(
1126 '--ffmpeg-location', '--avconv-location', metavar
='PATH',
1127 dest
='ffmpeg_location',
1128 help='Location of the ffmpeg binary; either the path to the binary or its containing directory')
1129 postproc
.add_option(
1131 metavar
='CMD', dest
='exec_cmd',
1132 help='Execute a command on the file after downloading and post-processing, similar to find\'s -exec syntax. Example: --exec \'adb push {} /sdcard/Music/ && rm {}\'')
1133 postproc
.add_option(
1134 '--convert-subs', '--convert-subtitles',
1135 metavar
='FORMAT', dest
='convertsubtitles', default
=None,
1136 help='Convert the subtitles to other format (currently supported: srt|ass|vtt|lrc)')
1138 sponskrub
= optparse
.OptionGroup(parser
, 'SponSkrub (SponsorBlock) Options', description
=(
1139 'SponSkrub (https://github.com/pukkandan/SponSkrub) is a utility to mark/remove sponsor segments '
1140 'from downloaded YouTube videos using SponsorBlock API (https://sponsor.ajay.app)'))
1141 sponskrub
.add_option(
1143 action
='store_true', dest
='sponskrub', default
=None,
1145 'Use sponskrub to mark sponsored sections. '
1146 'This is enabled by default if the sponskrub binary exists (Youtube only)'))
1147 sponskrub
.add_option(
1149 action
='store_false', dest
='sponskrub',
1150 help='Do not use sponskrub')
1151 sponskrub
.add_option(
1152 '--sponskrub-cut', default
=False,
1153 action
='store_true', dest
='sponskrub_cut',
1154 help='Cut out the sponsor sections instead of simply marking them')
1155 sponskrub
.add_option(
1156 '--no-sponskrub-cut',
1157 action
='store_false', dest
='sponskrub_cut',
1158 help='Simply mark the sponsor sections, not cut them out (default)')
1159 sponskrub
.add_option(
1160 '--sponskrub-force', default
=False,
1161 action
='store_true', dest
='sponskrub_force',
1162 help='Run sponskrub even if the video was already downloaded')
1163 sponskrub
.add_option(
1164 '--no-sponskrub-force',
1165 action
='store_true', dest
='sponskrub_force',
1166 help='Do not cut out the sponsor sections if the video was already downloaded (default)')
1167 sponskrub
.add_option(
1168 '--sponskrub-location', metavar
='PATH',
1169 dest
='sponskrub_path', default
='',
1170 help='Location of the sponskrub binary; either the path to the binary or its containing directory')
1171 sponskrub
.add_option(
1172 '--sponskrub-args', dest
='sponskrub_args', metavar
='ARGS',
1173 help=optparse
.SUPPRESS_HELP
)
1175 extractor
= optparse
.OptionGroup(parser
, 'Extractor Options')
1176 extractor
.add_option(
1177 '--allow-dynamic-mpd', '--no-ignore-dynamic-mpd',
1178 action
='store_true', dest
='dynamic_mpd', default
=True,
1179 help='Process dynamic DASH manifests (default) (Alias: --no-ignore-dynamic-mpd)')
1180 extractor
.add_option(
1181 '--ignore-dynamic-mpd', '--no-allow-dynamic-mpd',
1182 action
='store_false', dest
='dynamic_mpd',
1183 help='Do not process dynamic DASH manifests (Alias: --no-allow-dynamic-mpd)')
1185 parser
.add_option_group(general
)
1186 parser
.add_option_group(network
)
1187 parser
.add_option_group(geo
)
1188 parser
.add_option_group(selection
)
1189 parser
.add_option_group(downloader
)
1190 parser
.add_option_group(filesystem
)
1191 parser
.add_option_group(thumbnail
)
1192 parser
.add_option_group(link
)
1193 parser
.add_option_group(verbosity
)
1194 parser
.add_option_group(workarounds
)
1195 parser
.add_option_group(video_format
)
1196 parser
.add_option_group(subtitles
)
1197 parser
.add_option_group(authentication
)
1198 parser
.add_option_group(adobe_pass
)
1199 parser
.add_option_group(postproc
)
1200 parser
.add_option_group(sponskrub
)
1201 parser
.add_option_group(extractor
)
1203 if overrideArguments
is not None:
1204 opts
, args
= parser
.parse_args(overrideArguments
)
1206 write_string('[debug] Override config: ' + repr(overrideArguments
) + '\n')
1208 def compat_conf(conf
):
1209 if sys
.version_info
< (3,):
1210 return [a
.decode(preferredencoding(), 'replace') for a
in conf
]
1214 'command-line': compat_conf(sys
.argv
[1:]),
1215 'custom': [], 'home': [], 'portable': [], 'user': [], 'system': []}
1216 paths
= {'command-line': False}
1217 opts
, args
= parser
.parse_args(configs
['command-line'])
1220 if '--config-location' in configs
['command-line']:
1221 location
= compat_expanduser(opts
.config_location
)
1222 if os
.path
.isdir(location
):
1223 location
= os
.path
.join(location
, 'youtube-dlc.conf')
1224 if not os
.path
.exists(location
):
1225 parser
.error('config-location %s does not exist.' % location
)
1226 configs
['custom'] = _readOptions(location
, default
=None)
1227 if configs
['custom'] is None:
1228 configs
['custom'] = []
1230 paths
['custom'] = location
1231 if '--ignore-config' in configs
['command-line']:
1233 if '--ignore-config' in configs
['custom']:
1236 def read_options(path
, user
=False):
1237 for package
in ('yt-dlp', 'youtube-dlc'):
1239 config
, current_path
= _readUserConf(package
, default
=None)
1241 current_path
= os
.path
.join(path
, '%s.conf' % package
)
1242 config
= _readOptions(current_path
, default
=None)
1243 if config
is not None:
1244 return config
, current_path
1247 configs
['portable'], paths
['portable'] = read_options(get_executable_path())
1248 if '--ignore-config' in configs
['portable']:
1251 def get_home_path():
1252 opts
= parser
.parse_args(configs
['portable'] + configs
['custom'] + configs
['command-line'])[0]
1253 return expand_path(opts
.paths
.get('home', '')).strip()
1255 configs
['home'], paths
['home'] = read_options(get_home_path())
1256 if '--ignore-config' in configs
['home']:
1259 configs
['system'], paths
['system'] = read_options('/etc')
1260 if '--ignore-config' in configs
['system']:
1263 configs
['user'], paths
['user'] = read_options('', True)
1264 if '--ignore-config' in configs
['user']:
1265 configs
['system'], paths
['system'] = [], None
1268 argv
= configs
['system'] + configs
['user'] + configs
['home'] + configs
['portable'] + configs
['custom'] + configs
['command-line']
1269 opts
, args
= parser
.parse_args(argv
)
1271 for label
in ('System', 'User', 'Portable', 'Home', 'Custom', 'Command-line'):
1273 if paths
.get(key
) is None:
1276 write_string('[debug] %s config file: %s\n' % (label
, paths
[key
]))
1277 write_string('[debug] %s config: %s\n' % (label
, repr(_hide_login_info(configs
[key
]))))
1279 return parser
, opts
, args