[Rte] Improve extractor
[youtube-dl] / youtube_dl / options.py
1 from __future__ import unicode_literals
2
3 import os.path
4 import optparse
5 import shlex
6 import sys
7
8 from .utils import (
9     get_term_width,
10     write_string,
11 )
12 from .version import __version__
13
14
15 def parseOpts(overrideArguments=None):
16     def _readOptions(filename_bytes, default=[]):
17         try:
18             optionf = open(filename_bytes)
19         except IOError:
20             return default  # silently skip if file is not present
21         try:
22             res = []
23             for l in optionf:
24                 res += shlex.split(l, comments=True)
25         finally:
26             optionf.close()
27         return res
28
29     def _readUserConf():
30         xdg_config_home = os.environ.get('XDG_CONFIG_HOME')
31         if xdg_config_home:
32             userConfFile = os.path.join(xdg_config_home, 'youtube-dl', 'config')
33             if not os.path.isfile(userConfFile):
34                 userConfFile = os.path.join(xdg_config_home, 'youtube-dl.conf')
35         else:
36             userConfFile = os.path.join(os.path.expanduser('~'), '.config', 'youtube-dl', 'config')
37             if not os.path.isfile(userConfFile):
38                 userConfFile = os.path.join(os.path.expanduser('~'), '.config', 'youtube-dl.conf')
39         userConf = _readOptions(userConfFile, None)
40
41         if userConf is None:
42             appdata_dir = os.environ.get('appdata')
43             if appdata_dir:
44                 userConf = _readOptions(
45                     os.path.join(appdata_dir, 'youtube-dl', 'config'),
46                     default=None)
47                 if userConf is None:
48                     userConf = _readOptions(
49                         os.path.join(appdata_dir, 'youtube-dl', 'config.txt'),
50                         default=None)
51
52         if userConf is None:
53             userConf = _readOptions(
54                 os.path.join(os.path.expanduser('~'), 'youtube-dl.conf'),
55                 default=None)
56         if userConf is None:
57             userConf = _readOptions(
58                 os.path.join(os.path.expanduser('~'), 'youtube-dl.conf.txt'),
59                 default=None)
60
61         if userConf is None:
62             userConf = []
63
64         return userConf
65
66     def _format_option_string(option):
67         ''' ('-o', '--option') -> -o, --format METAVAR'''
68
69         opts = []
70
71         if option._short_opts:
72             opts.append(option._short_opts[0])
73         if option._long_opts:
74             opts.append(option._long_opts[0])
75         if len(opts) > 1:
76             opts.insert(1, ', ')
77
78         if option.takes_value():
79             opts.append(' %s' % option.metavar)
80
81         return "".join(opts)
82
83     def _comma_separated_values_options_callback(option, opt_str, value, parser):
84         setattr(parser.values, option.dest, value.split(','))
85
86     def _hide_login_info(opts):
87         opts = list(opts)
88         for private_opt in ['-p', '--password', '-u', '--username', '--video-password']:
89             try:
90                 i = opts.index(private_opt)
91                 opts[i + 1] = 'PRIVATE'
92             except ValueError:
93                 pass
94         return opts
95
96     # No need to wrap help messages if we're on a wide console
97     columns = get_term_width()
98     max_width = columns if columns else 80
99     max_help_position = 80
100
101     fmt = optparse.IndentedHelpFormatter(width=max_width, max_help_position=max_help_position)
102     fmt.format_option_strings = _format_option_string
103
104     kw = {
105         'version': __version__,
106         'formatter': fmt,
107         'usage': '%prog [options] url [url...]',
108         'conflict_handler': 'resolve',
109     }
110
111     parser = optparse.OptionParser(**kw)
112
113     general = optparse.OptionGroup(parser, 'General Options')
114     general.add_option(
115         '-h', '--help',
116         action='help',
117         help='print this help text and exit')
118     general.add_option(
119         '-v', '--version',
120         action='version',
121         help='print program version and exit')
122     general.add_option(
123         '-U', '--update',
124         action='store_true', dest='update_self',
125         help='update this program to latest version. Make sure that you have sufficient permissions (run with sudo if needed)')
126     general.add_option(
127         '-i', '--ignore-errors',
128         action='store_true', dest='ignoreerrors', default=False,
129         help='continue on download errors, for example to skip unavailable videos in a playlist')
130     general.add_option(
131         '--abort-on-error',
132         action='store_false', dest='ignoreerrors',
133         help='Abort downloading of further videos (in the playlist or the command line) if an error occurs')
134     general.add_option(
135         '--dump-user-agent',
136         action='store_true', dest='dump_user_agent', default=False,
137         help='display the current browser identification')
138     general.add_option(
139         '--list-extractors',
140         action='store_true', dest='list_extractors', default=False,
141         help='List all supported extractors and the URLs they would handle')
142     general.add_option(
143         '--extractor-descriptions',
144         action='store_true', dest='list_extractor_descriptions', default=False,
145         help='Output descriptions of all supported extractors')
146     general.add_option(
147         '--proxy', dest='proxy',
148         default=None, metavar='URL',
149         help='Use the specified HTTP/HTTPS proxy. Pass in an empty string (--proxy "") for direct connection')
150     general.add_option(
151         '--socket-timeout',
152         dest='socket_timeout', type=float, default=None,
153         help='Time to wait before giving up, in seconds')
154     general.add_option(
155         '--default-search',
156         dest='default_search', metavar='PREFIX',
157         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.')
158     general.add_option(
159         '--ignore-config',
160         action='store_true',
161         help='Do not read configuration files. When given in the global configuration file /etc/youtube-dl.conf: do not read the user configuration in ~/.config/youtube-dl.conf (%APPDATA%/youtube-dl/config.txt on Windows)')
162
163     selection = optparse.OptionGroup(parser, 'Video Selection')
164     selection.add_option(
165         '--playlist-start',
166         dest='playliststart', metavar='NUMBER', default=1, type=int,
167         help='playlist video to start at (default is %default)')
168     selection.add_option(
169         '--playlist-end',
170         dest='playlistend', metavar='NUMBER', default=None, type=int,
171         help='playlist video to end at (default is last)')
172     selection.add_option(
173         '--match-title',
174         dest='matchtitle', metavar='REGEX',
175         help='download only matching titles (regex or caseless sub-string)')
176     selection.add_option(
177         '--reject-title',
178         dest='rejecttitle', metavar='REGEX',
179         help='skip download for matching titles (regex or caseless sub-string)')
180     selection.add_option(
181         '--max-downloads',
182         dest='max_downloads', metavar='NUMBER', type=int, default=None,
183         help='Abort after downloading NUMBER files')
184     selection.add_option(
185         '--min-filesize',
186         metavar='SIZE', dest='min_filesize', default=None,
187         help='Do not download any videos smaller than SIZE (e.g. 50k or 44.6m)')
188     selection.add_option(
189         '--max-filesize',
190         metavar='SIZE', dest='max_filesize', default=None,
191         help='Do not download any videos larger than SIZE (e.g. 50k or 44.6m)')
192     selection.add_option(
193         '--date',
194         metavar='DATE', dest='date', default=None,
195         help='download only videos uploaded in this date')
196     selection.add_option(
197         '--datebefore',
198         metavar='DATE', dest='datebefore', default=None,
199         help='download only videos uploaded on or before this date (i.e. inclusive)')
200     selection.add_option(
201         '--dateafter',
202         metavar='DATE', dest='dateafter', default=None,
203         help='download only videos uploaded on or after this date (i.e. inclusive)')
204     selection.add_option(
205         '--min-views',
206         metavar='COUNT', dest='min_views', default=None, type=int,
207         help='Do not download any videos with less than COUNT views',)
208     selection.add_option(
209         '--max-views',
210         metavar='COUNT', dest='max_views', default=None, type=int,
211         help='Do not download any videos with more than COUNT views')
212     selection.add_option(
213         '--no-playlist',
214         action='store_true', dest='noplaylist', default=False,
215         help='download only the currently playing video')
216     selection.add_option(
217         '--age-limit',
218         metavar='YEARS', dest='age_limit', default=None, type=int,
219         help='download only videos suitable for the given age')
220     selection.add_option(
221         '--download-archive', metavar='FILE',
222         dest='download_archive',
223         help='Download only videos not listed in the archive file. Record the IDs of all downloaded videos in it.')
224     selection.add_option(
225         '--include-ads',
226         dest='include_ads', action='store_true',
227         help='Download advertisements as well (experimental)')
228
229     authentication = optparse.OptionGroup(parser, 'Authentication Options')
230     authentication.add_option(
231         '-u', '--username',
232         dest='username', metavar='USERNAME',
233         help='login with this account ID')
234     authentication.add_option(
235         '-p', '--password',
236         dest='password', metavar='PASSWORD',
237         help='account password')
238     authentication.add_option(
239         '-2', '--twofactor',
240         dest='twofactor', metavar='TWOFACTOR',
241         help='two-factor auth code')
242     authentication.add_option(
243         '-n', '--netrc',
244         action='store_true', dest='usenetrc', default=False,
245         help='use .netrc authentication data')
246     authentication.add_option(
247         '--video-password',
248         dest='videopassword', metavar='PASSWORD',
249         help='video password (vimeo, smotri)')
250
251     video_format = optparse.OptionGroup(parser, 'Video Format Options')
252     video_format.add_option(
253         '-f', '--format',
254         action='store', dest='format', metavar='FORMAT', default=None,
255         help='video format code, specify the order of preference using slashes: -f 22/17/18 .  -f mp4 , -f m4a and  -f flv  are also supported. You can also use the special names "best", "bestvideo", "bestaudio", "worst", "worstvideo" and "worstaudio". By default, youtube-dl will pick the best quality. Use commas to download multiple audio formats, such as  -f  136/137/mp4/bestvideo,140/m4a/bestaudio')
256     video_format.add_option(
257         '--all-formats',
258         action='store_const', dest='format', const='all',
259         help='download all available video formats')
260     video_format.add_option(
261         '--prefer-free-formats',
262         action='store_true', dest='prefer_free_formats', default=False,
263         help='prefer free video formats unless a specific one is requested')
264     video_format.add_option(
265         '--max-quality',
266         action='store', dest='format_limit', metavar='FORMAT',
267         help='highest quality format to download')
268     video_format.add_option(
269         '-F', '--list-formats',
270         action='store_true', dest='listformats',
271         help='list all available formats')
272     video_format.add_option(
273         '--youtube-include-dash-manifest',
274         action='store_true', dest='youtube_include_dash_manifest', default=True,
275         help=optparse.SUPPRESS_HELP)
276     video_format.add_option(
277         '--youtube-skip-dash-manifest',
278         action='store_false', dest='youtube_include_dash_manifest',
279         help='Do not download the DASH manifest on YouTube videos')
280
281     subtitles = optparse.OptionGroup(parser, 'Subtitle Options')
282     subtitles.add_option(
283         '--write-sub', '--write-srt',
284         action='store_true', dest='writesubtitles', default=False,
285         help='write subtitle file')
286     subtitles.add_option(
287         '--write-auto-sub', '--write-automatic-sub',
288         action='store_true', dest='writeautomaticsub', default=False,
289         help='write automatic subtitle file (youtube only)')
290     subtitles.add_option(
291         '--all-subs',
292         action='store_true', dest='allsubtitles', default=False,
293         help='downloads all the available subtitles of the video')
294     subtitles.add_option(
295         '--list-subs',
296         action='store_true', dest='listsubtitles', default=False,
297         help='lists all available subtitles for the video')
298     subtitles.add_option(
299         '--sub-format',
300         action='store', dest='subtitlesformat', metavar='FORMAT', default='srt',
301         help='subtitle format (default=srt) ([sbv/vtt] youtube only)')
302     subtitles.add_option(
303         '--sub-lang', '--sub-langs', '--srt-lang',
304         action='callback', dest='subtitleslangs', metavar='LANGS', type='str',
305         default=[], callback=_comma_separated_values_options_callback,
306         help='languages of the subtitles to download (optional) separated by commas, use IETF language tags like \'en,pt\'')
307
308     downloader = optparse.OptionGroup(parser, 'Download Options')
309     downloader.add_option(
310         '-r', '--rate-limit',
311         dest='ratelimit', metavar='LIMIT',
312         help='maximum download rate in bytes per second (e.g. 50K or 4.2M)')
313     downloader.add_option(
314         '-R', '--retries',
315         dest='retries', metavar='RETRIES', default=10,
316         help='number of retries (default is %default)')
317     downloader.add_option(
318         '--buffer-size',
319         dest='buffersize', metavar='SIZE', default='1024',
320         help='size of download buffer (e.g. 1024 or 16K) (default is %default)')
321     downloader.add_option(
322         '--no-resize-buffer',
323         action='store_true', dest='noresizebuffer', default=False,
324         help='do not automatically adjust the buffer size. By default, the buffer size is automatically resized from an initial value of SIZE.')
325     downloader.add_option(
326         '--test',
327         action='store_true', dest='test', default=False,
328         help=optparse.SUPPRESS_HELP)
329
330     workarounds = optparse.OptionGroup(parser, 'Workarounds')
331     workarounds.add_option(
332         '--encoding',
333         dest='encoding', metavar='ENCODING',
334         help='Force the specified encoding (experimental)')
335     workarounds.add_option(
336         '--no-check-certificate',
337         action='store_true', dest='no_check_certificate', default=False,
338         help='Suppress HTTPS certificate validation.')
339     workarounds.add_option(
340         '--prefer-insecure',
341         '--prefer-unsecure', action='store_true', dest='prefer_insecure',
342         help='Use an unencrypted connection to retrieve information about the video. (Currently supported only for YouTube)')
343     workarounds.add_option(
344         '--user-agent',
345         metavar='UA', dest='user_agent',
346         help='specify a custom user agent')
347     workarounds.add_option(
348         '--referer',
349         metavar='URL', dest='referer', default=None,
350         help='specify a custom referer, use if the video access is restricted to one domain',
351     )
352     workarounds.add_option(
353         '--add-header',
354         metavar='FIELD:VALUE', dest='headers', action='append',
355         help='specify a custom HTTP header and its value, separated by a colon \':\'. You can use this option multiple times',
356     )
357     workarounds.add_option(
358         '--bidi-workaround',
359         dest='bidi_workaround', action='store_true',
360         help='Work around terminals that lack bidirectional text support. Requires bidiv or fribidi executable in PATH')
361
362     verbosity = optparse.OptionGroup(parser, 'Verbosity / Simulation Options')
363     verbosity.add_option(
364         '-q', '--quiet',
365         action='store_true', dest='quiet', default=False,
366         help='activates quiet mode')
367     verbosity.add_option(
368         '--no-warnings',
369         dest='no_warnings', action='store_true', default=False,
370         help='Ignore warnings')
371     verbosity.add_option(
372         '-s', '--simulate',
373         action='store_true', dest='simulate', default=False,
374         help='do not download the video and do not write anything to disk',)
375     verbosity.add_option(
376         '--skip-download',
377         action='store_true', dest='skip_download', default=False,
378         help='do not download the video',)
379     verbosity.add_option(
380         '-g', '--get-url',
381         action='store_true', dest='geturl', default=False,
382         help='simulate, quiet but print URL')
383     verbosity.add_option(
384         '-e', '--get-title',
385         action='store_true', dest='gettitle', default=False,
386         help='simulate, quiet but print title')
387     verbosity.add_option(
388         '--get-id',
389         action='store_true', dest='getid', default=False,
390         help='simulate, quiet but print id')
391     verbosity.add_option(
392         '--get-thumbnail',
393         action='store_true', dest='getthumbnail', default=False,
394         help='simulate, quiet but print thumbnail URL')
395     verbosity.add_option(
396         '--get-description',
397         action='store_true', dest='getdescription', default=False,
398         help='simulate, quiet but print video description')
399     verbosity.add_option(
400         '--get-duration',
401         action='store_true', dest='getduration', default=False,
402         help='simulate, quiet but print video length')
403     verbosity.add_option(
404         '--get-filename',
405         action='store_true', dest='getfilename', default=False,
406         help='simulate, quiet but print output filename')
407     verbosity.add_option(
408         '--get-format',
409         action='store_true', dest='getformat', default=False,
410         help='simulate, quiet but print output format')
411     verbosity.add_option(
412         '-j', '--dump-json',
413         action='store_true', dest='dumpjson', default=False,
414         help='simulate, quiet but print JSON information. See --output for a description of available keys.')
415     verbosity.add_option(
416         '--newline',
417         action='store_true', dest='progress_with_newline', default=False,
418         help='output progress bar as new lines')
419     verbosity.add_option(
420         '--no-progress',
421         action='store_true', dest='noprogress', default=False,
422         help='do not print progress bar')
423     verbosity.add_option(
424         '--console-title',
425         action='store_true', dest='consoletitle', default=False,
426         help='display progress in console titlebar')
427     verbosity.add_option(
428         '-v', '--verbose',
429         action='store_true', dest='verbose', default=False,
430         help='print various debugging information')
431     verbosity.add_option(
432         '--dump-intermediate-pages',
433         action='store_true', dest='dump_intermediate_pages', default=False,
434         help='print downloaded pages to debug problems (very verbose)')
435     verbosity.add_option(
436         '--write-pages',
437         action='store_true', dest='write_pages', default=False,
438         help='Write downloaded intermediary pages to files in the current directory to debug problems')
439     verbosity.add_option(
440         '--youtube-print-sig-code',
441         action='store_true', dest='youtube_print_sig_code', default=False,
442         help=optparse.SUPPRESS_HELP)
443     verbosity.add_option(
444         '--print-traffic',
445         dest='debug_printtraffic', action='store_true', default=False,
446         help='Display sent and read HTTP traffic')
447
448     filesystem = optparse.OptionGroup(parser, 'Filesystem Options')
449     filesystem.add_option(
450         '-a', '--batch-file',
451         dest='batchfile', metavar='FILE',
452         help='file containing URLs to download (\'-\' for stdin)')
453     filesystem.add_option(
454         '--id', default=False,
455         action='store_true', dest='useid', help='use only video ID in file name')
456     filesystem.add_option(
457         '-A', '--auto-number',
458         action='store_true', dest='autonumber', default=False,
459         help='number downloaded files starting from 00000')
460     filesystem.add_option(
461         '-o', '--output',
462         dest='outtmpl', metavar='TEMPLATE',
463         help=('output filename template. Use %(title)s to get the title, '
464               '%(uploader)s for the uploader name, %(uploader_id)s for the uploader nickname if different, '
465               '%(autonumber)s to get an automatically incremented number, '
466               '%(ext)s for the filename extension, '
467               '%(format)s for the format description (like "22 - 1280x720" or "HD"), '
468               '%(format_id)s for the unique id of the format (like Youtube\'s itags: "137"), '
469               '%(upload_date)s for the upload date (YYYYMMDD), '
470               '%(extractor)s for the provider (youtube, metacafe, etc), '
471               '%(id)s for the video id, %(playlist)s for the playlist the video is in, '
472               '%(playlist_index)s for the position in the playlist and %% for a literal percent. '
473               '%(height)s and %(width)s for the width and height of the video format. '
474               '%(resolution)s for a textual description of the resolution of the video format. '
475               'Use - to output to stdout. Can also be used to download to a different directory, '
476               'for example with -o \'/my/downloads/%(uploader)s/%(title)s-%(id)s.%(ext)s\' .'))
477     filesystem.add_option(
478         '--autonumber-size',
479         dest='autonumber_size', metavar='NUMBER',
480         help='Specifies the number of digits in %(autonumber)s when it is present in output filename template or --auto-number option is given')
481     filesystem.add_option(
482         '--restrict-filenames',
483         action='store_true', dest='restrictfilenames', default=False,
484         help='Restrict filenames to only ASCII characters, and avoid "&" and spaces in filenames')
485     filesystem.add_option(
486         '-t', '--title',
487         action='store_true', dest='usetitle', default=False,
488         help='[deprecated] use title in file name (default)')
489     filesystem.add_option(
490         '-l', '--literal', default=False,
491         action='store_true', dest='usetitle',
492         help='[deprecated] alias of --title')
493     filesystem.add_option(
494         '-w', '--no-overwrites',
495         action='store_true', dest='nooverwrites', default=False,
496         help='do not overwrite files')
497     filesystem.add_option(
498         '-c', '--continue',
499         action='store_true', dest='continue_dl', default=True,
500         help='force resume of partially downloaded files. By default, youtube-dl will resume downloads if possible.')
501     filesystem.add_option(
502         '--no-continue',
503         action='store_false', dest='continue_dl',
504         help='do not resume partially downloaded files (restart from beginning)')
505     filesystem.add_option(
506         '--no-part',
507         action='store_true', dest='nopart', default=False,
508         help='do not use .part files - write directly into output file')
509     filesystem.add_option(
510         '--no-mtime',
511         action='store_false', dest='updatetime', default=True,
512         help='do not use the Last-modified header to set the file modification time')
513     filesystem.add_option(
514         '--write-description',
515         action='store_true', dest='writedescription', default=False,
516         help='write video description to a .description file')
517     filesystem.add_option(
518         '--write-info-json',
519         action='store_true', dest='writeinfojson', default=False,
520         help='write video metadata to a .info.json file')
521     filesystem.add_option(
522         '--write-annotations',
523         action='store_true', dest='writeannotations', default=False,
524         help='write video annotations to a .annotation file')
525     filesystem.add_option(
526         '--write-thumbnail',
527         action='store_true', dest='writethumbnail', default=False,
528         help='write thumbnail image to disk')
529     filesystem.add_option(
530         '--load-info',
531         dest='load_info_filename', metavar='FILE',
532         help='json file containing the video information (created with the "--write-json" option)')
533     filesystem.add_option(
534         '--cookies',
535         dest='cookiefile', metavar='FILE',
536         help='file to read cookies from and dump cookie jar in')
537     filesystem.add_option(
538         '--cache-dir', dest='cachedir', default=None, metavar='DIR',
539         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.')
540     filesystem.add_option(
541         '--no-cache-dir', action='store_const', const=False, dest='cachedir',
542         help='Disable filesystem caching')
543     filesystem.add_option(
544         '--rm-cache-dir',
545         action='store_true', dest='rm_cachedir',
546         help='Delete all filesystem cache files')
547
548     postproc = optparse.OptionGroup(parser, 'Post-processing Options')
549     postproc.add_option(
550         '-x', '--extract-audio',
551         action='store_true', dest='extractaudio', default=False,
552         help='convert video files to audio-only files (requires ffmpeg or avconv and ffprobe or avprobe)')
553     postproc.add_option(
554         '--audio-format', metavar='FORMAT', dest='audioformat', default='best',
555         help='"best", "aac", "vorbis", "mp3", "m4a", "opus", or "wav"; "%default" by default')
556     postproc.add_option(
557         '--audio-quality', metavar='QUALITY',
558         dest='audioquality', default='5',
559         help='ffmpeg/avconv audio quality specification, insert a value between 0 (better) and 9 (worse) for VBR or a specific bitrate like 128K (default %default)')
560     postproc.add_option(
561         '--recode-video',
562         metavar='FORMAT', dest='recodevideo', default=None,
563         help='Encode the video to another format if necessary (currently supported: mp4|flv|ogg|webm|mkv)')
564     postproc.add_option(
565         '-k', '--keep-video',
566         action='store_true', dest='keepvideo', default=False,
567         help='keeps the video file on disk after the post-processing; the video is erased by default')
568     postproc.add_option(
569         '--no-post-overwrites',
570         action='store_true', dest='nopostoverwrites', default=False,
571         help='do not overwrite post-processed files; the post-processed files are overwritten by default')
572     postproc.add_option(
573         '--embed-subs',
574         action='store_true', dest='embedsubtitles', default=False,
575         help='embed subtitles in the video (only for mp4 videos)')
576     postproc.add_option(
577         '--embed-thumbnail',
578         action='store_true', dest='embedthumbnail', default=False,
579         help='embed thumbnail in the audio as cover art')
580     postproc.add_option(
581         '--add-metadata',
582         action='store_true', dest='addmetadata', default=False,
583         help='write metadata to the video file')
584     postproc.add_option(
585         '--xattrs',
586         action='store_true', dest='xattrs', default=False,
587         help='write metadata to the video file\'s xattrs (using dublin core and xdg standards)')
588     postproc.add_option(
589         '--prefer-avconv',
590         action='store_false', dest='prefer_ffmpeg',
591         help='Prefer avconv over ffmpeg for running the postprocessors (default)')
592     postproc.add_option(
593         '--prefer-ffmpeg',
594         action='store_true', dest='prefer_ffmpeg',
595         help='Prefer ffmpeg over avconv for running the postprocessors')
596     postproc.add_option(
597         '--exec',
598         metavar='CMD', dest='exec_cmd',
599         help='Execute a command on the file after downloading, similar to find\'s -exec syntax. Example: --exec \'adb push {} /sdcard/Music/ && rm {}\'' )
600
601     parser.add_option_group(general)
602     parser.add_option_group(selection)
603     parser.add_option_group(downloader)
604     parser.add_option_group(filesystem)
605     parser.add_option_group(verbosity)
606     parser.add_option_group(workarounds)
607     parser.add_option_group(video_format)
608     parser.add_option_group(subtitles)
609     parser.add_option_group(authentication)
610     parser.add_option_group(postproc)
611
612     if overrideArguments is not None:
613         opts, args = parser.parse_args(overrideArguments)
614         if opts.verbose:
615             write_string('[debug] Override config: ' + repr(overrideArguments) + '\n')
616     else:
617         commandLineConf = sys.argv[1:]
618         if '--ignore-config' in commandLineConf:
619             systemConf = []
620             userConf = []
621         else:
622             systemConf = _readOptions('/etc/youtube-dl.conf')
623             if '--ignore-config' in systemConf:
624                 userConf = []
625             else:
626                 userConf = _readUserConf()
627         argv = systemConf + userConf + commandLineConf
628
629         opts, args = parser.parse_args(argv)
630         if opts.verbose:
631             write_string('[debug] System config: ' + repr(_hide_login_info(systemConf)) + '\n')
632             write_string('[debug] User config: ' + repr(_hide_login_info(userConf)) + '\n')
633             write_string('[debug] Command-line args: ' + repr(_hide_login_info(commandLineConf)) + '\n')
634
635     return parser, opts, args