]>
Commit | Line | Data |
---|---|---|
2daabe49 PH |
1 | from __future__ import unicode_literals |
2 | ||
34a741a8 PH |
3 | import os.path |
4 | import optparse | |
3aa9a735 | 5 | import re |
34a741a8 PH |
6 | import sys |
7 | ||
222516d9 | 8 | from .downloader.external import list_external_downloaders |
8c25f81b | 9 | from .compat import ( |
4644ac55 | 10 | compat_expanduser, |
003c69a8 | 11 | compat_get_terminal_size, |
4644ac55 | 12 | compat_getenv, |
c7b0add8 | 13 | compat_kwargs, |
cab792ab | 14 | compat_shlex_split, |
8c25f81b PH |
15 | ) |
16 | from .utils import ( | |
ff556f5c | 17 | preferredencoding, |
34a741a8 PH |
18 | write_string, |
19 | ) | |
20 | from .version import __version__ | |
21 | ||
22 | ||
23 | def parseOpts(overrideArguments=None): | |
24 | def _readOptions(filename_bytes, default=[]): | |
25 | try: | |
26 | optionf = open(filename_bytes) | |
27 | except IOError: | |
28 | return default # silently skip if file is not present | |
29 | try: | |
1251565e S |
30 | # FIXME: https://github.com/rg3/youtube-dl/commit/dfe5fa49aed02cf36ba9f743b11b0903554b5e56 |
31 | contents = optionf.read() | |
32 | if sys.version_info < (3,): | |
33 | contents = contents.decode(preferredencoding()) | |
34 | res = compat_shlex_split(contents, comments=True) | |
34a741a8 PH |
35 | finally: |
36 | optionf.close() | |
37 | return res | |
38 | ||
39 | def _readUserConf(): | |
4644ac55 | 40 | xdg_config_home = compat_getenv('XDG_CONFIG_HOME') |
34a741a8 PH |
41 | if xdg_config_home: |
42 | userConfFile = os.path.join(xdg_config_home, 'youtube-dl', 'config') | |
43 | if not os.path.isfile(userConfFile): | |
44 | userConfFile = os.path.join(xdg_config_home, 'youtube-dl.conf') | |
45 | else: | |
4644ac55 | 46 | userConfFile = os.path.join(compat_expanduser('~'), '.config', 'youtube-dl', 'config') |
34a741a8 | 47 | if not os.path.isfile(userConfFile): |
4644ac55 | 48 | userConfFile = os.path.join(compat_expanduser('~'), '.config', 'youtube-dl.conf') |
34a741a8 PH |
49 | userConf = _readOptions(userConfFile, None) |
50 | ||
51 | if userConf is None: | |
4644ac55 | 52 | appdata_dir = compat_getenv('appdata') |
34a741a8 PH |
53 | if appdata_dir: |
54 | userConf = _readOptions( | |
55 | os.path.join(appdata_dir, 'youtube-dl', 'config'), | |
56 | default=None) | |
57 | if userConf is None: | |
58 | userConf = _readOptions( | |
59 | os.path.join(appdata_dir, 'youtube-dl', 'config.txt'), | |
60 | default=None) | |
61 | ||
62 | if userConf is None: | |
63 | userConf = _readOptions( | |
4644ac55 | 64 | os.path.join(compat_expanduser('~'), 'youtube-dl.conf'), |
34a741a8 PH |
65 | default=None) |
66 | if userConf is None: | |
67 | userConf = _readOptions( | |
4644ac55 | 68 | os.path.join(compat_expanduser('~'), 'youtube-dl.conf.txt'), |
34a741a8 PH |
69 | default=None) |
70 | ||
71 | if userConf is None: | |
72 | userConf = [] | |
73 | ||
74 | return userConf | |
75 | ||
76 | def _format_option_string(option): | |
77 | ''' ('-o', '--option') -> -o, --format METAVAR''' | |
78 | ||
79 | opts = [] | |
80 | ||
81 | if option._short_opts: | |
82 | opts.append(option._short_opts[0]) | |
83 | if option._long_opts: | |
84 | opts.append(option._long_opts[0]) | |
85 | if len(opts) > 1: | |
86 | opts.insert(1, ', ') | |
87 | ||
8450c15c PH |
88 | if option.takes_value(): |
89 | opts.append(' %s' % option.metavar) | |
34a741a8 | 90 | |
611c1dd9 | 91 | return ''.join(opts) |
34a741a8 PH |
92 | |
93 | def _comma_separated_values_options_callback(option, opt_str, value, parser): | |
94 | setattr(parser.values, option.dest, value.split(',')) | |
95 | ||
96 | def _hide_login_info(opts): | |
1b6712ab | 97 | PRIVATE_OPTS = ['-p', '--password', '-u', '--username', '--video-password', '--ap-password', '--ap-username'] |
3aa9a735 PH |
98 | eqre = re.compile('^(?P<key>' + ('|'.join(re.escape(po) for po in PRIVATE_OPTS)) + ')=.+$') |
99 | ||
100 | def _scrub_eq(o): | |
101 | m = eqre.match(o) | |
102 | if m: | |
103 | return m.group('key') + '=PRIVATE' | |
104 | else: | |
105 | return o | |
106 | ||
107 | opts = list(map(_scrub_eq, opts)) | |
108 | for private_opt in PRIVATE_OPTS: | |
34a741a8 PH |
109 | try: |
110 | i = opts.index(private_opt) | |
8450c15c | 111 | opts[i + 1] = 'PRIVATE' |
34a741a8 PH |
112 | except ValueError: |
113 | pass | |
114 | return opts | |
115 | ||
34a741a8 | 116 | # No need to wrap help messages if we're on a wide console |
003c69a8 | 117 | columns = compat_get_terminal_size().columns |
8450c15c PH |
118 | max_width = columns if columns else 80 |
119 | max_help_position = 80 | |
34a741a8 PH |
120 | |
121 | fmt = optparse.IndentedHelpFormatter(width=max_width, max_help_position=max_help_position) | |
122 | fmt.format_option_strings = _format_option_string | |
123 | ||
124 | kw = { | |
8450c15c PH |
125 | 'version': __version__, |
126 | 'formatter': fmt, | |
a42419da | 127 | 'usage': '%prog [OPTIONS] URL [URL...]', |
8450c15c | 128 | 'conflict_handler': 'resolve', |
34a741a8 PH |
129 | } |
130 | ||
c7b0add8 | 131 | parser = optparse.OptionParser(**compat_kwargs(kw)) |
34a741a8 | 132 | |
8450c15c PH |
133 | general = optparse.OptionGroup(parser, 'General Options') |
134 | general.add_option( | |
135 | '-h', '--help', | |
136 | action='help', | |
17941321 | 137 | help='Print this help text and exit') |
8450c15c PH |
138 | general.add_option( |
139 | '-v', '--version', | |
140 | action='version', | |
17941321 | 141 | help='Print program version and exit') |
8450c15c PH |
142 | general.add_option( |
143 | '-U', '--update', | |
144 | action='store_true', dest='update_self', | |
17941321 | 145 | help='Update this program to latest version. Make sure that you have sufficient permissions (run with sudo if needed)') |
8450c15c PH |
146 | general.add_option( |
147 | '-i', '--ignore-errors', | |
148 | action='store_true', dest='ignoreerrors', default=False, | |
17941321 | 149 | help='Continue on download errors, for example to skip unavailable videos in a playlist') |
8450c15c PH |
150 | general.add_option( |
151 | '--abort-on-error', | |
152 | action='store_false', dest='ignoreerrors', | |
153 | help='Abort downloading of further videos (in the playlist or the command line) if an error occurs') | |
154 | general.add_option( | |
155 | '--dump-user-agent', | |
156 | action='store_true', dest='dump_user_agent', default=False, | |
17941321 | 157 | help='Display the current browser identification') |
34a741a8 | 158 | general.add_option( |
8450c15c PH |
159 | '--list-extractors', |
160 | action='store_true', dest='list_extractors', default=False, | |
9836cfb8 | 161 | help='List all supported extractors') |
8450c15c PH |
162 | general.add_option( |
163 | '--extractor-descriptions', | |
164 | action='store_true', dest='list_extractor_descriptions', default=False, | |
165 | help='Output descriptions of all supported extractors') | |
d22dec74 S |
166 | general.add_option( |
167 | '--force-generic-extractor', | |
168 | action='store_true', dest='force_generic_extractor', default=False, | |
169 | help='Force extraction to use the generic extractor') | |
34a741a8 PH |
170 | general.add_option( |
171 | '--default-search', | |
172 | dest='default_search', metavar='PREFIX', | |
17941321 | 173 | 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.') |
34a741a8 PH |
174 | general.add_option( |
175 | '--ignore-config', | |
176 | action='store_true', | |
d4e06d4a PH |
177 | help='Do not read configuration files. ' |
178 | 'When given in the global configuration file /etc/youtube-dl.conf: ' | |
179 | 'Do not read the user configuration in ~/.config/youtube-dl/config ' | |
180 | '(%APPDATA%/youtube-dl/config.txt on Windows)') | |
e66dca5e | 181 | general.add_option( |
b6ee45e9 S |
182 | '--config-location', |
183 | dest='config_location', metavar='PATH', | |
184 | help='Location of the configuration file; either the path to the config or its containing directory.') | |
057a5206 PH |
185 | general.add_option( |
186 | '--flat-playlist', | |
187 | action='store_const', dest='extract_flat', const='in_playlist', | |
188 | default=False, | |
189 | help='Do not extract the videos of a playlist, only list them.') | |
d77ab8e2 S |
190 | general.add_option( |
191 | '--mark-watched', | |
192 | action='store_true', dest='mark_watched', default=False, | |
193 | help='Mark videos watched (YouTube only)') | |
90f794c6 S |
194 | general.add_option( |
195 | '--no-mark-watched', | |
196 | action='store_false', dest='mark_watched', default=False, | |
197 | help='Do not mark videos watched (YouTube only)') | |
7e5db8c9 PH |
198 | general.add_option( |
199 | '--no-color', '--no-colors', | |
200 | action='store_true', dest='no_color', | |
201 | default=False, | |
17941321 | 202 | help='Do not emit color codes in output') |
34a741a8 | 203 | |
be4a824d PH |
204 | network = optparse.OptionGroup(parser, 'Network Options') |
205 | network.add_option( | |
206 | '--proxy', dest='proxy', | |
207 | default=None, metavar='URL', | |
6ddb4888 YCH |
208 | help='Use the specified HTTP/HTTPS/SOCKS proxy. To enable experimental ' |
209 | 'SOCKS proxy, specify a proper scheme. For example ' | |
210 | 'socks5://127.0.0.1:1080/. Pass in an empty string (--proxy "") ' | |
211 | 'for direct connection') | |
be4a824d PH |
212 | network.add_option( |
213 | '--socket-timeout', | |
214 | dest='socket_timeout', type=float, default=None, metavar='SECONDS', | |
215 | help='Time to wait before giving up, in seconds') | |
216 | network.add_option( | |
217 | '--source-address', | |
218 | metavar='IP', dest='source_address', default=None, | |
24ee6b97 | 219 | help='Client-side IP address to bind to', |
be4a824d | 220 | ) |
500b8b41 PH |
221 | network.add_option( |
222 | '-4', '--force-ipv4', | |
223 | action='store_const', const='0.0.0.0', dest='source_address', | |
24ee6b97 | 224 | help='Make all connections via IPv4', |
500b8b41 PH |
225 | ) |
226 | network.add_option( | |
227 | '-6', '--force-ipv6', | |
228 | action='store_const', const='::', dest='source_address', | |
24ee6b97 | 229 | help='Make all connections via IPv6', |
500b8b41 | 230 | ) |
0aa10994 S |
231 | |
232 | geo = optparse.OptionGroup(parser, 'Geo Restriction') | |
233 | geo.add_option( | |
38cce791 YCH |
234 | '--geo-verification-proxy', |
235 | dest='geo_verification_proxy', default=None, metavar='URL', | |
236 | help='Use this proxy to verify the IP address for some geo-restricted sites. ' | |
0aa10994 S |
237 | 'The default proxy specified by --proxy (or none, if the options is not present) is used for the actual downloading.') |
238 | geo.add_option( | |
91410c9b PH |
239 | '--cn-verification-proxy', |
240 | dest='cn_verification_proxy', default=None, metavar='URL', | |
0aa10994 S |
241 | help=optparse.SUPPRESS_HELP) |
242 | geo.add_option( | |
243 | '--geo-bypass', | |
244 | action='store_true', dest='geo_bypass', default=True, | |
245 | help='Bypass geographic restriction via faking X-Forwarded-For HTTP header (experimental)') | |
246 | geo.add_option( | |
247 | '--no-geo-bypass', | |
248 | action='store_false', dest='geo_bypass', default=True, | |
249 | help='Do not bypass geographic restriction via faking X-Forwarded-For HTTP header (experimental)') | |
250 | geo.add_option( | |
251 | '--geo-bypass-country', metavar='CODE', | |
252 | dest='geo_bypass_country', default=None, | |
253 | help='Force bypass geographic restriction with explicitly provided two-letter ISO 3166-2 country code (experimental)') | |
be4a824d | 254 | |
8450c15c | 255 | selection = optparse.OptionGroup(parser, 'Video Selection') |
34a741a8 PH |
256 | selection.add_option( |
257 | '--playlist-start', | |
258 | dest='playliststart', metavar='NUMBER', default=1, type=int, | |
17941321 | 259 | help='Playlist video to start at (default is %default)') |
34a741a8 PH |
260 | selection.add_option( |
261 | '--playlist-end', | |
262 | dest='playlistend', metavar='NUMBER', default=None, type=int, | |
17941321 | 263 | help='Playlist video to end at (default is last)') |
c14e88f0 PH |
264 | selection.add_option( |
265 | '--playlist-items', | |
266 | dest='playlist_items', metavar='ITEM_SPEC', default=None, | |
4eb59a6b | 267 | 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.') |
34a741a8 | 268 | selection.add_option( |
8450c15c PH |
269 | '--match-title', |
270 | dest='matchtitle', metavar='REGEX', | |
17941321 | 271 | help='Download only matching titles (regex or caseless sub-string)') |
8450c15c PH |
272 | selection.add_option( |
273 | '--reject-title', | |
274 | dest='rejecttitle', metavar='REGEX', | |
17941321 | 275 | help='Skip download for matching titles (regex or caseless sub-string)') |
8450c15c PH |
276 | selection.add_option( |
277 | '--max-downloads', | |
278 | dest='max_downloads', metavar='NUMBER', type=int, default=None, | |
279 | help='Abort after downloading NUMBER files') | |
280 | selection.add_option( | |
281 | '--min-filesize', | |
282 | metavar='SIZE', dest='min_filesize', default=None, | |
283 | help='Do not download any videos smaller than SIZE (e.g. 50k or 44.6m)') | |
284 | selection.add_option( | |
285 | '--max-filesize', | |
286 | metavar='SIZE', dest='max_filesize', default=None, | |
287 | help='Do not download any videos larger than SIZE (e.g. 50k or 44.6m)') | |
288 | selection.add_option( | |
289 | '--date', | |
290 | metavar='DATE', dest='date', default=None, | |
17941321 | 291 | help='Download only videos uploaded in this date') |
8450c15c PH |
292 | selection.add_option( |
293 | '--datebefore', | |
294 | metavar='DATE', dest='datebefore', default=None, | |
17941321 | 295 | help='Download only videos uploaded on or before this date (i.e. inclusive)') |
34a741a8 | 296 | selection.add_option( |
8450c15c PH |
297 | '--dateafter', |
298 | metavar='DATE', dest='dateafter', default=None, | |
17941321 | 299 | help='Download only videos uploaded on or after this date (i.e. inclusive)') |
34a741a8 | 300 | selection.add_option( |
8450c15c PH |
301 | '--min-views', |
302 | metavar='COUNT', dest='min_views', default=None, type=int, | |
17941321 | 303 | help='Do not download any videos with less than COUNT views') |
34a741a8 | 304 | selection.add_option( |
8450c15c PH |
305 | '--max-views', |
306 | metavar='COUNT', dest='max_views', default=None, type=int, | |
307 | help='Do not download any videos with more than COUNT views') | |
347de493 PH |
308 | selection.add_option( |
309 | '--match-filter', | |
310 | metavar='FILTER', dest='match_filter', default=None, | |
311 | help=( | |
24ee6b97 | 312 | 'Generic video filter. ' |
a355b57f | 313 | 'Specify any key (see the "OUTPUT TEMPLATE" for a list of available keys) to ' |
2c1f442c S |
314 | 'match if the key is present, ' |
315 | '!key to check if the key is not present, ' | |
347de493 | 316 | 'key > NUMBER (like "comment_count > 12", also works with ' |
ac33accd S |
317 | '>=, <, <=, !=, =) to compare against a number, ' |
318 | 'key = \'LITERAL\' (like "uploader = \'Mike Smith\'", also works with !=) ' | |
319 | 'to match against a string literal ' | |
320 | 'and & to require multiple matches. ' | |
2c1f442c S |
321 | 'Values which are not known are excluded unless you ' |
322 | 'put a question mark (?) after the operator. ' | |
347de493 PH |
323 | 'For example, to only match videos that have been liked more than ' |
324 | '100 times and disliked less than 50 times (or the dislike ' | |
325 | 'functionality is not available at the given service), but who ' | |
5495937f | 326 | 'also have a description, use --match-filter ' |
347de493 PH |
327 | '"like_count > 100 & dislike_count <? 50 & description" .' |
328 | )) | |
34a741a8 | 329 | selection.add_option( |
8450c15c PH |
330 | '--no-playlist', |
331 | action='store_true', dest='noplaylist', default=False, | |
17941321 | 332 | help='Download only the video, if the URL refers to a video and a playlist.') |
df4bd0d5 PH |
333 | selection.add_option( |
334 | '--yes-playlist', | |
335 | action='store_false', dest='noplaylist', default=False, | |
17941321 | 336 | help='Download the playlist, if the URL refers to a video and a playlist.') |
8450c15c PH |
337 | selection.add_option( |
338 | '--age-limit', | |
339 | metavar='YEARS', dest='age_limit', default=None, type=int, | |
17941321 | 340 | help='Download only videos suitable for the given age') |
8450c15c PH |
341 | selection.add_option( |
342 | '--download-archive', metavar='FILE', | |
343 | dest='download_archive', | |
344 | help='Download only videos not listed in the archive file. Record the IDs of all downloaded videos in it.') | |
345 | selection.add_option( | |
346 | '--include-ads', | |
347 | dest='include_ads', action='store_true', | |
34a741a8 | 348 | help='Download advertisements as well (experimental)') |
34a741a8 | 349 | |
8450c15c PH |
350 | authentication = optparse.OptionGroup(parser, 'Authentication Options') |
351 | authentication.add_option( | |
352 | '-u', '--username', | |
353 | dest='username', metavar='USERNAME', | |
17941321 | 354 | help='Login with this account ID') |
8450c15c PH |
355 | authentication.add_option( |
356 | '-p', '--password', | |
357 | dest='password', metavar='PASSWORD', | |
17941321 | 358 | help='Account password. If this option is left out, youtube-dl will ask interactively.') |
8450c15c PH |
359 | authentication.add_option( |
360 | '-2', '--twofactor', | |
361 | dest='twofactor', metavar='TWOFACTOR', | |
3540fe26 | 362 | help='Two-factor authentication code') |
8450c15c PH |
363 | authentication.add_option( |
364 | '-n', '--netrc', | |
365 | action='store_true', dest='usenetrc', default=False, | |
17941321 | 366 | help='Use .netrc authentication data') |
8450c15c PH |
367 | authentication.add_option( |
368 | '--video-password', | |
369 | dest='videopassword', metavar='PASSWORD', | |
804c343a | 370 | help='Video password (vimeo, smotri, youku)') |
1b6712ab RA |
371 | |
372 | adobe_pass = optparse.OptionGroup(parser, 'Adobe Pass Options') | |
373 | adobe_pass.add_option( | |
797c636b RA |
374 | '--ap-mso', |
375 | dest='ap_mso', metavar='MSO', | |
537f7533 | 376 | help='Adobe Pass multiple-system operator (TV provider) identifier, use --ap-list-mso for a list of available MSOs') |
1b6712ab RA |
377 | adobe_pass.add_option( |
378 | '--ap-username', | |
797c636b | 379 | dest='ap_username', metavar='USERNAME', |
537f7533 | 380 | help='Multiple-system operator account login') |
1b6712ab RA |
381 | adobe_pass.add_option( |
382 | '--ap-password', | |
797c636b | 383 | dest='ap_password', metavar='PASSWORD', |
537f7533 | 384 | help='Multiple-system operator account password. If this option is left out, youtube-dl will ask interactively.') |
1b6712ab | 385 | adobe_pass.add_option( |
87148bb7 RA |
386 | '--ap-list-mso', |
387 | action='store_true', dest='ap_list_mso', default=False, | |
537f7533 | 388 | help='List all supported multiple-system operators') |
8450c15c PH |
389 | |
390 | video_format = optparse.OptionGroup(parser, 'Video Format Options') | |
391 | video_format.add_option( | |
392 | '-f', '--format', | |
393 | action='store', dest='format', metavar='FORMAT', default=None, | |
a3805092 | 394 | help='Video format code, see the "FORMAT SELECTION" for all the info') |
8450c15c PH |
395 | video_format.add_option( |
396 | '--all-formats', | |
397 | action='store_const', dest='format', const='all', | |
17941321 | 398 | help='Download all available video formats') |
8450c15c PH |
399 | video_format.add_option( |
400 | '--prefer-free-formats', | |
401 | action='store_true', dest='prefer_free_formats', default=False, | |
17941321 | 402 | help='Prefer free video formats unless a specific one is requested') |
8450c15c PH |
403 | video_format.add_option( |
404 | '-F', '--list-formats', | |
405 | action='store_true', dest='listformats', | |
4b3fbafd | 406 | help='List all available formats of requested videos') |
203fb43f PH |
407 | video_format.add_option( |
408 | '--youtube-include-dash-manifest', | |
409 | action='store_true', dest='youtube_include_dash_manifest', default=True, | |
410 | help=optparse.SUPPRESS_HELP) | |
411 | video_format.add_option( | |
412 | '--youtube-skip-dash-manifest', | |
413 | action='store_false', dest='youtube_include_dash_manifest', | |
b2575b38 | 414 | help='Do not download the DASH manifests and related data on YouTube videos') |
d120e901 | 415 | video_format.add_option( |
bd1a281e PH |
416 | '--merge-output-format', |
417 | action='store', dest='merge_output_format', metavar='FORMAT', default=None, | |
d120e901 | 418 | help=( |
00334d0d S |
419 | 'If a merge is required (e.g. bestvideo+bestaudio), ' |
420 | 'output to given container format. One of mkv, mp4, ogg, webm, flv. ' | |
d120e901 | 421 | 'Ignored if no merge is required')) |
8450c15c PH |
422 | |
423 | subtitles = optparse.OptionGroup(parser, 'Subtitle Options') | |
424 | subtitles.add_option( | |
425 | '--write-sub', '--write-srt', | |
426 | action='store_true', dest='writesubtitles', default=False, | |
17941321 | 427 | help='Write subtitle file') |
8450c15c PH |
428 | subtitles.add_option( |
429 | '--write-auto-sub', '--write-automatic-sub', | |
430 | action='store_true', dest='writeautomaticsub', default=False, | |
741dd8ea | 431 | help='Write automatically generated subtitle file (YouTube only)') |
8450c15c PH |
432 | subtitles.add_option( |
433 | '--all-subs', | |
434 | action='store_true', dest='allsubtitles', default=False, | |
17941321 | 435 | help='Download all the available subtitles of the video') |
8450c15c PH |
436 | subtitles.add_option( |
437 | '--list-subs', | |
438 | action='store_true', dest='listsubtitles', default=False, | |
17941321 | 439 | help='List all available subtitles for the video') |
8450c15c PH |
440 | subtitles.add_option( |
441 | '--sub-format', | |
a504ced0 | 442 | action='store', dest='subtitlesformat', metavar='FORMAT', default='best', |
4a3cdf81 | 443 | help='Subtitle format, accepts formats preference, for example: "srt" or "ass/srt/best"') |
8450c15c PH |
444 | subtitles.add_option( |
445 | '--sub-lang', '--sub-langs', '--srt-lang', | |
446 | action='callback', dest='subtitleslangs', metavar='LANGS', type='str', | |
447 | default=[], callback=_comma_separated_values_options_callback, | |
1ca59dac | 448 | help='Languages of the subtitles to download (optional) separated by commas, use --list-subs for available language tags') |
8450c15c PH |
449 | |
450 | downloader = optparse.OptionGroup(parser, 'Download Options') | |
451 | downloader.add_option( | |
8ec2b2c4 S |
452 | '-r', '--limit-rate', '--rate-limit', |
453 | dest='ratelimit', metavar='RATE', | |
17941321 | 454 | help='Maximum download rate in bytes per second (e.g. 50K or 4.2M)') |
8450c15c PH |
455 | downloader.add_option( |
456 | '-R', '--retries', | |
457 | dest='retries', metavar='RETRIES', default=10, | |
17941321 | 458 | help='Number of retries (default is %default), or "infinite".') |
52bb437e S |
459 | downloader.add_option( |
460 | '--fragment-retries', | |
461 | dest='fragment_retries', metavar='RETRIES', default=10, | |
12ee65ea | 462 | help='Number of retries for a fragment (default is %default), or "infinite" (DASH, hlsnative and ISM)') |
9603b660 S |
463 | downloader.add_option( |
464 | '--skip-unavailable-fragments', | |
465 | action='store_true', dest='skip_unavailable_fragments', default=True, | |
12ee65ea | 466 | help='Skip unavailable fragments (DASH, hlsnative and ISM)') |
732fb3f8 | 467 | downloader.add_option( |
9603b660 S |
468 | '--abort-on-unavailable-fragment', |
469 | action='store_false', dest='skip_unavailable_fragments', | |
470 | help='Abort downloading when some fragment is not available') | |
0eee52f3 S |
471 | downloader.add_option( |
472 | '--keep-fragments', | |
473 | action='store_true', dest='keep_fragments', default=False, | |
474 | help='Keep downloaded fragments on disk after downloading is finished; fragments are erased by default') | |
8450c15c PH |
475 | downloader.add_option( |
476 | '--buffer-size', | |
477 | dest='buffersize', metavar='SIZE', default='1024', | |
17941321 | 478 | help='Size of download buffer (e.g. 1024 or 16K) (default is %default)') |
8450c15c PH |
479 | downloader.add_option( |
480 | '--no-resize-buffer', | |
481 | action='store_true', dest='noresizebuffer', default=False, | |
17941321 | 482 | help='Do not automatically adjust the buffer size. By default, the buffer size is automatically resized from an initial value of SIZE.') |
8450c15c PH |
483 | downloader.add_option( |
484 | '--test', | |
485 | action='store_true', dest='test', default=False, | |
486 | help=optparse.SUPPRESS_HELP) | |
ff815fe6 MS |
487 | downloader.add_option( |
488 | '--playlist-reverse', | |
489 | action='store_true', | |
490 | help='Download playlist videos in reverse order') | |
75822ca7 TC |
491 | downloader.add_option( |
492 | '--playlist-random', | |
493 | action='store_true', | |
494 | help='Download playlist videos in random order') | |
881e6a1f PH |
495 | downloader.add_option( |
496 | '--xattr-set-filesize', | |
497 | dest='xattr_set_filesize', action='store_true', | |
3540fe26 | 498 | help='Set file xattribute ytdl.filesize with expected file size (experimental)') |
85729c51 PH |
499 | downloader.add_option( |
500 | '--hls-prefer-native', | |
bf09af3a | 501 | dest='hls_prefer_native', action='store_true', default=None, |
870d5258 | 502 | help='Use the native HLS downloader instead of ffmpeg') |
bf09af3a S |
503 | downloader.add_option( |
504 | '--hls-prefer-ffmpeg', | |
505 | dest='hls_prefer_native', action='store_false', default=None, | |
506 | help='Use ffmpeg instead of the native HLS downloader') | |
7d106a65 JMF |
507 | downloader.add_option( |
508 | '--hls-use-mpegts', | |
509 | dest='hls_use_mpegts', action='store_true', | |
510 | help='Use the mpegts container for HLS videos, allowing to play the ' | |
53be8894 | 511 | 'video while downloading (some players may not be able to play it)') |
222516d9 PH |
512 | downloader.add_option( |
513 | '--external-downloader', | |
514 | dest='external_downloader', metavar='COMMAND', | |
c75f0b36 | 515 | help='Use the specified external downloader. ' |
222516d9 | 516 | 'Currently supports %s' % ','.join(list_external_downloaders())) |
c75f0b36 PH |
517 | downloader.add_option( |
518 | '--external-downloader-args', | |
519 | dest='external_downloader_args', metavar='ARGS', | |
17941321 | 520 | help='Give these arguments to the external downloader') |
8450c15c PH |
521 | |
522 | workarounds = optparse.OptionGroup(parser, 'Workarounds') | |
34a741a8 | 523 | workarounds.add_option( |
8450c15c PH |
524 | '--encoding', |
525 | dest='encoding', metavar='ENCODING', | |
34a741a8 PH |
526 | help='Force the specified encoding (experimental)') |
527 | workarounds.add_option( | |
8450c15c PH |
528 | '--no-check-certificate', |
529 | action='store_true', dest='no_check_certificate', default=False, | |
17941321 | 530 | help='Suppress HTTPS certificate validation') |
34a741a8 | 531 | workarounds.add_option( |
8450c15c PH |
532 | '--prefer-insecure', |
533 | '--prefer-unsecure', action='store_true', dest='prefer_insecure', | |
34a741a8 PH |
534 | help='Use an unencrypted connection to retrieve information about the video. (Currently supported only for YouTube)') |
535 | workarounds.add_option( | |
8450c15c PH |
536 | '--user-agent', |
537 | metavar='UA', dest='user_agent', | |
17941321 | 538 | help='Specify a custom user agent') |
34a741a8 | 539 | workarounds.add_option( |
8450c15c PH |
540 | '--referer', |
541 | metavar='URL', dest='referer', default=None, | |
17941321 | 542 | help='Specify a custom referer, use if the video access is restricted to one domain', |
34a741a8 PH |
543 | ) |
544 | workarounds.add_option( | |
8450c15c PH |
545 | '--add-header', |
546 | metavar='FIELD:VALUE', dest='headers', action='append', | |
17941321 | 547 | help='Specify a custom HTTP header and its value, separated by a colon \':\'. You can use this option multiple times', |
34a741a8 PH |
548 | ) |
549 | workarounds.add_option( | |
8450c15c PH |
550 | '--bidi-workaround', |
551 | dest='bidi_workaround', action='store_true', | |
552 | help='Work around terminals that lack bidirectional text support. Requires bidiv or fribidi executable in PATH') | |
5f0d813d | 553 | workarounds.add_option( |
065bc354 | 554 | '--sleep-interval', '--min-sleep-interval', metavar='SECONDS', |
649f7966 | 555 | dest='sleep_interval', type=float, |
7aa589a5 S |
556 | help=( |
557 | 'Number of seconds to sleep before each download when used alone ' | |
558 | 'or a lower bound of a range for randomized sleep before each download ' | |
559 | '(minimum possible number of seconds to sleep) when used along with ' | |
560 | '--max-sleep-interval.')) | |
065bc354 | 561 | workarounds.add_option( |
562 | '--max-sleep-interval', metavar='SECONDS', | |
563 | dest='max_sleep_interval', type=float, | |
7aa589a5 S |
564 | help=( |
565 | 'Upper bound of a range for randomized sleep before each download ' | |
566 | '(maximum possible number of seconds to sleep). Must only be used ' | |
567 | 'along with --min-sleep-interval.')) | |
34a741a8 | 568 | |
8450c15c PH |
569 | verbosity = optparse.OptionGroup(parser, 'Verbosity / Simulation Options') |
570 | verbosity.add_option( | |
571 | '-q', '--quiet', | |
572 | action='store_true', dest='quiet', default=False, | |
17941321 | 573 | help='Activate quiet mode') |
34a741a8 PH |
574 | verbosity.add_option( |
575 | '--no-warnings', | |
576 | dest='no_warnings', action='store_true', default=False, | |
577 | help='Ignore warnings') | |
8450c15c PH |
578 | verbosity.add_option( |
579 | '-s', '--simulate', | |
580 | action='store_true', dest='simulate', default=False, | |
17941321 | 581 | help='Do not download the video and do not write anything to disk') |
8450c15c PH |
582 | verbosity.add_option( |
583 | '--skip-download', | |
584 | action='store_true', dest='skip_download', default=False, | |
17941321 | 585 | help='Do not download the video') |
8450c15c PH |
586 | verbosity.add_option( |
587 | '-g', '--get-url', | |
588 | action='store_true', dest='geturl', default=False, | |
17941321 | 589 | help='Simulate, quiet but print URL') |
8450c15c PH |
590 | verbosity.add_option( |
591 | '-e', '--get-title', | |
592 | action='store_true', dest='gettitle', default=False, | |
17941321 | 593 | help='Simulate, quiet but print title') |
8450c15c PH |
594 | verbosity.add_option( |
595 | '--get-id', | |
596 | action='store_true', dest='getid', default=False, | |
17941321 | 597 | help='Simulate, quiet but print id') |
8450c15c PH |
598 | verbosity.add_option( |
599 | '--get-thumbnail', | |
600 | action='store_true', dest='getthumbnail', default=False, | |
17941321 | 601 | help='Simulate, quiet but print thumbnail URL') |
8450c15c PH |
602 | verbosity.add_option( |
603 | '--get-description', | |
604 | action='store_true', dest='getdescription', default=False, | |
17941321 | 605 | help='Simulate, quiet but print video description') |
8450c15c PH |
606 | verbosity.add_option( |
607 | '--get-duration', | |
608 | action='store_true', dest='getduration', default=False, | |
17941321 | 609 | help='Simulate, quiet but print video length') |
8450c15c PH |
610 | verbosity.add_option( |
611 | '--get-filename', | |
612 | action='store_true', dest='getfilename', default=False, | |
17941321 | 613 | help='Simulate, quiet but print output filename') |
8450c15c PH |
614 | verbosity.add_option( |
615 | '--get-format', | |
616 | action='store_true', dest='getformat', default=False, | |
17941321 | 617 | help='Simulate, quiet but print output format') |
8450c15c PH |
618 | verbosity.add_option( |
619 | '-j', '--dump-json', | |
620 | action='store_true', dest='dumpjson', default=False, | |
a355b57f | 621 | help='Simulate, quiet but print JSON information. See the "OUTPUT TEMPLATE" for a description of available keys.') |
63e0be34 PH |
622 | verbosity.add_option( |
623 | '-J', '--dump-single-json', | |
624 | action='store_true', dest='dump_single_json', default=False, | |
17941321 | 625 | help='Simulate, quiet but print JSON information for each command-line argument. If the URL refers to a playlist, dump the whole playlist information in a single line.') |
c0bdf32a PH |
626 | verbosity.add_option( |
627 | '--print-json', | |
628 | action='store_true', dest='print_json', default=False, | |
629 | help='Be quiet and print the video information as JSON (video is still being downloaded).', | |
630 | ) | |
8450c15c PH |
631 | verbosity.add_option( |
632 | '--newline', | |
633 | action='store_true', dest='progress_with_newline', default=False, | |
17941321 | 634 | help='Output progress bar as new lines') |
8450c15c PH |
635 | verbosity.add_option( |
636 | '--no-progress', | |
637 | action='store_true', dest='noprogress', default=False, | |
17941321 | 638 | help='Do not print progress bar') |
8450c15c PH |
639 | verbosity.add_option( |
640 | '--console-title', | |
641 | action='store_true', dest='consoletitle', default=False, | |
17941321 | 642 | help='Display progress in console titlebar') |
8450c15c PH |
643 | verbosity.add_option( |
644 | '-v', '--verbose', | |
645 | action='store_true', dest='verbose', default=False, | |
17941321 | 646 | help='Print various debugging information') |
8450c15c | 647 | verbosity.add_option( |
8bba753c | 648 | '--dump-pages', '--dump-intermediate-pages', |
8450c15c | 649 | action='store_true', dest='dump_intermediate_pages', default=False, |
79979c68 | 650 | help='Print downloaded pages encoded using base64 to debug problems (very verbose)') |
8450c15c PH |
651 | verbosity.add_option( |
652 | '--write-pages', | |
653 | action='store_true', dest='write_pages', default=False, | |
654 | help='Write downloaded intermediary pages to files in the current directory to debug problems') | |
655 | verbosity.add_option( | |
656 | '--youtube-print-sig-code', | |
657 | action='store_true', dest='youtube_print_sig_code', default=False, | |
658 | help=optparse.SUPPRESS_HELP) | |
659 | verbosity.add_option( | |
2f543a21 | 660 | '--print-traffic', '--dump-headers', |
8450c15c PH |
661 | dest='debug_printtraffic', action='store_true', default=False, |
662 | help='Display sent and read HTTP traffic') | |
58b1f00d PH |
663 | verbosity.add_option( |
664 | '-C', '--call-home', | |
665 | dest='call_home', action='store_true', default=False, | |
17941321 | 666 | help='Contact the youtube-dl server for debugging') |
8bfa7545 PH |
667 | verbosity.add_option( |
668 | '--no-call-home', | |
669 | dest='call_home', action='store_false', default=False, | |
17941321 | 670 | help='Do NOT contact the youtube-dl server for debugging') |
8450c15c PH |
671 | |
672 | filesystem = optparse.OptionGroup(parser, 'Filesystem Options') | |
673 | filesystem.add_option( | |
674 | '-a', '--batch-file', | |
675 | dest='batchfile', metavar='FILE', | |
17941321 | 676 | help='File containing URLs to download (\'-\' for stdin)') |
8450c15c PH |
677 | filesystem.add_option( |
678 | '--id', default=False, | |
17941321 | 679 | action='store_true', dest='useid', help='Use only video ID in file name') |
8450c15c PH |
680 | filesystem.add_option( |
681 | '-o', '--output', | |
682 | dest='outtmpl', metavar='TEMPLATE', | |
8b2dc4c3 | 683 | help=('Output filename template, see the "OUTPUT TEMPLATE" for all the info')) |
8450c15c PH |
684 | filesystem.add_option( |
685 | '--autonumber-size', | |
be5df5ee S |
686 | dest='autonumber_size', metavar='NUMBER', type=int, |
687 | help=optparse.SUPPRESS_HELP) | |
acbb2374 CP |
688 | filesystem.add_option( |
689 | '--autonumber-start', | |
1a241a2d S |
690 | dest='autonumber_start', metavar='NUMBER', default=1, type=int, |
691 | help='Specify the start value for %(autonumber)s (default is %default)') | |
8450c15c PH |
692 | filesystem.add_option( |
693 | '--restrict-filenames', | |
694 | action='store_true', dest='restrictfilenames', default=False, | |
695 | help='Restrict filenames to only ASCII characters, and avoid "&" and spaces in filenames') | |
2865cf04 PH |
696 | filesystem.add_option( |
697 | '-A', '--auto-number', | |
698 | action='store_true', dest='autonumber', default=False, | |
be5df5ee | 699 | help=optparse.SUPPRESS_HELP) |
8450c15c PH |
700 | filesystem.add_option( |
701 | '-t', '--title', | |
702 | action='store_true', dest='usetitle', default=False, | |
be5df5ee | 703 | help=optparse.SUPPRESS_HELP) |
8450c15c PH |
704 | filesystem.add_option( |
705 | '-l', '--literal', default=False, | |
706 | action='store_true', dest='usetitle', | |
be5df5ee | 707 | help=optparse.SUPPRESS_HELP) |
8450c15c PH |
708 | filesystem.add_option( |
709 | '-w', '--no-overwrites', | |
710 | action='store_true', dest='nooverwrites', default=False, | |
17941321 | 711 | help='Do not overwrite files') |
8450c15c PH |
712 | filesystem.add_option( |
713 | '-c', '--continue', | |
714 | action='store_true', dest='continue_dl', default=True, | |
17941321 | 715 | help='Force resume of partially downloaded files. By default, youtube-dl will resume downloads if possible.') |
8450c15c PH |
716 | filesystem.add_option( |
717 | '--no-continue', | |
718 | action='store_false', dest='continue_dl', | |
17941321 | 719 | help='Do not resume partially downloaded files (restart from beginning)') |
8450c15c PH |
720 | filesystem.add_option( |
721 | '--no-part', | |
722 | action='store_true', dest='nopart', default=False, | |
17941321 | 723 | help='Do not use .part files - write directly into output file') |
8450c15c PH |
724 | filesystem.add_option( |
725 | '--no-mtime', | |
726 | action='store_false', dest='updatetime', default=True, | |
17941321 | 727 | help='Do not use the Last-modified header to set the file modification time') |
8450c15c PH |
728 | filesystem.add_option( |
729 | '--write-description', | |
730 | action='store_true', dest='writedescription', default=False, | |
17941321 | 731 | help='Write video description to a .description file') |
8450c15c PH |
732 | filesystem.add_option( |
733 | '--write-info-json', | |
734 | action='store_true', dest='writeinfojson', default=False, | |
17941321 | 735 | help='Write video metadata to a .info.json file') |
8450c15c PH |
736 | filesystem.add_option( |
737 | '--write-annotations', | |
738 | action='store_true', dest='writeannotations', default=False, | |
0669c89c | 739 | help='Write video annotations to a .annotations.xml file') |
8450c15c | 740 | filesystem.add_option( |
244fe977 | 741 | '--load-info-json', '--load-info', |
8450c15c | 742 | dest='load_info_filename', metavar='FILE', |
1a48181a | 743 | help='JSON file containing the video information (created with the "--write-info-json" option)') |
8450c15c PH |
744 | filesystem.add_option( |
745 | '--cookies', | |
746 | dest='cookiefile', metavar='FILE', | |
17941321 | 747 | help='File to read cookies from and dump cookie jar in') |
34a741a8 PH |
748 | filesystem.add_option( |
749 | '--cache-dir', dest='cachedir', default=None, metavar='DIR', | |
750 | 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.') | |
751 | filesystem.add_option( | |
752 | '--no-cache-dir', action='store_const', const=False, dest='cachedir', | |
753 | help='Disable filesystem caching') | |
754 | filesystem.add_option( | |
8450c15c PH |
755 | '--rm-cache-dir', |
756 | action='store_true', dest='rm_cachedir', | |
34a741a8 PH |
757 | help='Delete all filesystem cache files') |
758 | ||
cfb56d1a PH |
759 | thumbnail = optparse.OptionGroup(parser, 'Thumbnail images') |
760 | thumbnail.add_option( | |
761 | '--write-thumbnail', | |
762 | action='store_true', dest='writethumbnail', default=False, | |
17941321 | 763 | help='Write thumbnail image to disk') |
ec82d85a PH |
764 | thumbnail.add_option( |
765 | '--write-all-thumbnails', | |
766 | action='store_true', dest='write_all_thumbnails', default=False, | |
17941321 | 767 | help='Write all thumbnail image formats to disk') |
cfb56d1a PH |
768 | thumbnail.add_option( |
769 | '--list-thumbnails', | |
770 | action='store_true', dest='list_thumbnails', default=False, | |
771 | help='Simulate and list all available thumbnail formats') | |
772 | ||
8450c15c PH |
773 | postproc = optparse.OptionGroup(parser, 'Post-processing Options') |
774 | postproc.add_option( | |
775 | '-x', '--extract-audio', | |
776 | action='store_true', dest='extractaudio', default=False, | |
17941321 | 777 | help='Convert video files to audio-only files (requires ffmpeg or avconv and ffprobe or avprobe)') |
8450c15c PH |
778 | postproc.add_option( |
779 | '--audio-format', metavar='FORMAT', dest='audioformat', default='best', | |
0efbc6b5 | 780 | help='Specify audio format: "best", "aac", "flac", "mp3", "m4a", "opus", "vorbis", or "wav"; "%default" by default; No effect without -x') |
8450c15c PH |
781 | postproc.add_option( |
782 | '--audio-quality', metavar='QUALITY', | |
783 | dest='audioquality', default='5', | |
17941321 | 784 | help='Specify ffmpeg/avconv audio quality, insert a value between 0 (better) and 9 (worse) for VBR or a specific bitrate like 128K (default %default)') |
8450c15c PH |
785 | postproc.add_option( |
786 | '--recode-video', | |
787 | metavar='FORMAT', dest='recodevideo', default=None, | |
f72b0a60 | 788 | help='Encode the video to another format if necessary (currently supported: mp4|flv|ogg|webm|mkv|avi)') |
d84f1d14 | 789 | postproc.add_option( |
1866432d | 790 | '--postprocessor-args', |
f72b0a60 S |
791 | dest='postprocessor_args', metavar='ARGS', |
792 | help='Give these arguments to the postprocessor') | |
8450c15c PH |
793 | postproc.add_option( |
794 | '-k', '--keep-video', | |
795 | action='store_true', dest='keepvideo', default=False, | |
17941321 | 796 | help='Keep the video file on disk after the post-processing; the video is erased by default') |
8450c15c PH |
797 | postproc.add_option( |
798 | '--no-post-overwrites', | |
799 | action='store_true', dest='nopostoverwrites', default=False, | |
17941321 | 800 | help='Do not overwrite post-processed files; the post-processed files are overwritten by default') |
8450c15c PH |
801 | postproc.add_option( |
802 | '--embed-subs', | |
803 | action='store_true', dest='embedsubtitles', default=False, | |
40025ee2 | 804 | help='Embed subtitles in the video (only for mp4, webm and mkv videos)') |
8450c15c PH |
805 | postproc.add_option( |
806 | '--embed-thumbnail', | |
807 | action='store_true', dest='embedthumbnail', default=False, | |
17941321 | 808 | help='Embed thumbnail in the audio as cover art') |
8450c15c PH |
809 | postproc.add_option( |
810 | '--add-metadata', | |
811 | action='store_true', dest='addmetadata', default=False, | |
17941321 | 812 | help='Write metadata to the video file') |
e7db87f7 | 813 | postproc.add_option( |
814 | '--metadata-from-title', | |
815 | metavar='FORMAT', dest='metafromtitle', | |
17941321 | 816 | help='Parse additional metadata like song title / artist from the video title. ' |
fa26734e S |
817 | 'The format syntax is the same as --output. Regular expression with ' |
818 | 'named capture groups may also be used. ' | |
819 | 'The parsed parameters replace existing values. ' | |
166d12b0 | 820 | 'Example: --metadata-from-title "%(artist)s - %(title)s" matches a title like ' |
fa26734e S |
821 | '"Coldplay - Paradise". ' |
822 | 'Example (regex): --metadata-from-title "(?P<artist>.+?) - (?P<title>.+)"') | |
8450c15c PH |
823 | postproc.add_option( |
824 | '--xattrs', | |
825 | action='store_true', dest='xattrs', default=False, | |
17941321 | 826 | help='Write metadata to the video file\'s xattrs (using dublin core and xdg standards)') |
6271f1ca PH |
827 | postproc.add_option( |
828 | '--fixup', | |
829 | metavar='POLICY', dest='fixup', default='detect_or_warn', | |
9fffd046 | 830 | help='Automatically correct known faults of the file. ' |
6271f1ca | 831 | 'One of never (do nothing), warn (only emit a warning), ' |
5774ef35 | 832 | 'detect_or_warn (the default; fix file if we can, warn otherwise)') |
8450c15c PH |
833 | postproc.add_option( |
834 | '--prefer-avconv', | |
835 | action='store_false', dest='prefer_ffmpeg', | |
34a741a8 | 836 | help='Prefer avconv over ffmpeg for running the postprocessors (default)') |
8450c15c PH |
837 | postproc.add_option( |
838 | '--prefer-ffmpeg', | |
839 | action='store_true', dest='prefer_ffmpeg', | |
34a741a8 | 840 | help='Prefer ffmpeg over avconv for running the postprocessors') |
73fac4e9 PH |
841 | postproc.add_option( |
842 | '--ffmpeg-location', '--avconv-location', metavar='PATH', | |
843 | dest='ffmpeg_location', | |
844 | help='Location of the ffmpeg/avconv binary; either the path to the binary or its containing directory.') | |
34a741a8 | 845 | postproc.add_option( |
8450c15c PH |
846 | '--exec', |
847 | metavar='CMD', dest='exec_cmd', | |
5f6a1245 | 848 | help='Execute a command on the file after downloading, similar to find\'s -exec syntax. Example: --exec \'adb push {} /sdcard/Music/ && rm {}\'') |
e9fade72 | 849 | postproc.add_option( |
f5bc4b5f | 850 | '--convert-subs', '--convert-subtitles', |
e9fade72 JMF |
851 | metavar='FORMAT', dest='convertsubtitles', default=None, |
852 | help='Convert the subtitles to other format (currently supported: srt|ass|vtt)') | |
34a741a8 PH |
853 | |
854 | parser.add_option_group(general) | |
be4a824d | 855 | parser.add_option_group(network) |
0aa10994 | 856 | parser.add_option_group(geo) |
34a741a8 PH |
857 | parser.add_option_group(selection) |
858 | parser.add_option_group(downloader) | |
859 | parser.add_option_group(filesystem) | |
cfb56d1a | 860 | parser.add_option_group(thumbnail) |
34a741a8 PH |
861 | parser.add_option_group(verbosity) |
862 | parser.add_option_group(workarounds) | |
863 | parser.add_option_group(video_format) | |
864 | parser.add_option_group(subtitles) | |
865 | parser.add_option_group(authentication) | |
d2522b86 | 866 | parser.add_option_group(adobe_pass) |
34a741a8 PH |
867 | parser.add_option_group(postproc) |
868 | ||
869 | if overrideArguments is not None: | |
870 | opts, args = parser.parse_args(overrideArguments) | |
871 | if opts.verbose: | |
8450c15c | 872 | write_string('[debug] Override config: ' + repr(overrideArguments) + '\n') |
34a741a8 | 873 | else: |
b04b94da S |
874 | def compat_conf(conf): |
875 | if sys.version_info < (3,): | |
876 | return [a.decode(preferredencoding(), 'replace') for a in conf] | |
877 | return conf | |
878 | ||
879 | command_line_conf = compat_conf(sys.argv[1:]) | |
e66dca5e | 880 | opts, args = parser.parse_args(command_line_conf) |
f5e2efbb | 881 | |
b6ee45e9 S |
882 | system_conf = user_conf = custom_conf = [] |
883 | ||
884 | if '--config-location' in command_line_conf: | |
885 | location = compat_expanduser(opts.config_location) | |
886 | if os.path.isdir(location): | |
887 | location = os.path.join(location, 'youtube-dl.conf') | |
888 | if not os.path.exists(location): | |
889 | parser.error('config-location %s does not exist.' % location) | |
890 | custom_conf = _readOptions(location) | |
891 | elif '--ignore-config' in command_line_conf: | |
892 | pass | |
34a741a8 | 893 | else: |
30d22dae | 894 | system_conf = _readOptions('/etc/youtube-dl.conf') |
b6ee45e9 | 895 | if '--ignore-config' not in system_conf: |
30d22dae | 896 | user_conf = _readUserConf() |
e66dca5e | 897 | |
0ce8c66f | 898 | argv = system_conf + user_conf + custom_conf + command_line_conf |
34a741a8 PH |
899 | opts, args = parser.parse_args(argv) |
900 | if opts.verbose: | |
b6ee45e9 S |
901 | for conf_label, conf in ( |
902 | ('System config', system_conf), | |
903 | ('User config', user_conf), | |
904 | ('Custom config', custom_conf), | |
905 | ('Command-line args', command_line_conf)): | |
906 | write_string('[debug] %s: %s\n' % (conf_label, repr(_hide_login_info(conf)))) | |
34a741a8 PH |
907 | |
908 | return parser, opts, args |