]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube-dl.1
Update README.md
[youtubedl] / youtube-dl.1
1 .\" Automatically generated by Pandoc 2.1.3
2 .\"
3 .TH "YOUTUBE\-DL" "1" "" "" ""
4 .hy
5 .SH NAME
6 .PP
7 youtube\-dl \- download videos from youtube.com or other video platforms
8 .SH SYNOPSIS
9 .PP
10 \f[B]youtube\-dl\f[] [OPTIONS] URL [URL...]
11 .SH DESCRIPTION
12 .PP
13 \f[B]youtube\-dl\f[] is a command\-line program to download videos from
14 YouTube.com and a few more sites.
15 It requires the Python interpreter, version 2.6, 2.7, or 3.2+, and it is
16 not platform specific.
17 It should work on your Unix box, on Windows or on macOS.
18 It is released to the public domain, which means you can modify it,
19 redistribute it or use it however you like.
20 .SH OPTIONS
21 .TP
22 .B \-h, \-\-help
23 Print this help text and exit
24 .RS
25 .RE
26 .TP
27 .B \-\-version
28 Print program version and exit
29 .RS
30 .RE
31 .TP
32 .B \-U, \-\-update
33 Update this program to latest version.
34 Make sure that you have sufficient permissions (run with sudo if needed)
35 .RS
36 .RE
37 .TP
38 .B \-i, \-\-ignore\-errors
39 Continue on download errors, for example to skip unavailable videos in a
40 playlist
41 .RS
42 .RE
43 .TP
44 .B \-\-abort\-on\-error
45 Abort downloading of further videos (in the playlist or the command
46 line) if an error occurs
47 .RS
48 .RE
49 .TP
50 .B \-\-dump\-user\-agent
51 Display the current browser identification
52 .RS
53 .RE
54 .TP
55 .B \-\-list\-extractors
56 List all supported extractors
57 .RS
58 .RE
59 .TP
60 .B \-\-extractor\-descriptions
61 Output descriptions of all supported extractors
62 .RS
63 .RE
64 .TP
65 .B \-\-force\-generic\-extractor
66 Force extraction to use the generic extractor
67 .RS
68 .RE
69 .TP
70 .B \-\-default\-search \f[I]PREFIX\f[]
71 Use this prefix for unqualified URLs.
72 For example "gvsearch2:" downloads two videos from google videos for
73 youtube\-dl "large apple".
74 Use the value "auto" to let youtube\-dl guess ("auto_warning" to emit a
75 warning when guessing).
76 "error" just throws an error.
77 The default value "fixup_error" repairs broken URLs, but emits an error
78 if this is not possible instead of searching.
79 .RS
80 .RE
81 .TP
82 .B \-\-ignore\-config
83 Do not read configuration files.
84 When given in the global configuration file /etc/youtube\-dl.conf: Do
85 not read the user configuration in ~/.config/youtube\- dl/config
86 (%APPDATA%/youtube\-dl/config.txt on Windows)
87 .RS
88 .RE
89 .TP
90 .B \-\-config\-location \f[I]PATH\f[]
91 Location of the configuration file; either the path to the config or its
92 containing directory.
93 .RS
94 .RE
95 .TP
96 .B \-\-flat\-playlist
97 Do not extract the videos of a playlist, only list them.
98 .RS
99 .RE
100 .TP
101 .B \-\-mark\-watched
102 Mark videos watched (YouTube only)
103 .RS
104 .RE
105 .TP
106 .B \-\-no\-mark\-watched
107 Do not mark videos watched (YouTube only)
108 .RS
109 .RE
110 .TP
111 .B \-\-no\-color
112 Do not emit color codes in output
113 .RS
114 .RE
115 .SS Network Options:
116 .TP
117 .B \-\-proxy \f[I]URL\f[]
118 Use the specified HTTP/HTTPS/SOCKS proxy.
119 To enable SOCKS proxy, specify a proper scheme.
120 For example socks5://127.0.0.1:1080/.
121 Pass in an empty string (\-\-proxy "") for direct connection
122 .RS
123 .RE
124 .TP
125 .B \-\-socket\-timeout \f[I]SECONDS\f[]
126 Time to wait before giving up, in seconds
127 .RS
128 .RE
129 .TP
130 .B \-\-source\-address \f[I]IP\f[]
131 Client\-side IP address to bind to
132 .RS
133 .RE
134 .TP
135 .B \-4, \-\-force\-ipv4
136 Make all connections via IPv4
137 .RS
138 .RE
139 .TP
140 .B \-6, \-\-force\-ipv6
141 Make all connections via IPv6
142 .RS
143 .RE
144 .SS Geo Restriction:
145 .TP
146 .B \-\-geo\-verification\-proxy \f[I]URL\f[]
147 Use this proxy to verify the IP address for some geo\-restricted sites.
148 The default proxy specified by \-\-proxy (or none, if the option is not
149 present) is used for the actual downloading.
150 .RS
151 .RE
152 .TP
153 .B \-\-geo\-bypass
154 Bypass geographic restriction via faking X\-Forwarded\-For HTTP header
155 .RS
156 .RE
157 .TP
158 .B \-\-no\-geo\-bypass
159 Do not bypass geographic restriction via faking X\-Forwarded\-For HTTP
160 header
161 .RS
162 .RE
163 .TP
164 .B \-\-geo\-bypass\-country \f[I]CODE\f[]
165 Force bypass geographic restriction with explicitly provided two\-letter
166 ISO 3166\-2 country code
167 .RS
168 .RE
169 .TP
170 .B \-\-geo\-bypass\-ip\-block \f[I]IP_BLOCK\f[]
171 Force bypass geographic restriction with explicitly provided IP block in
172 CIDR notation
173 .RS
174 .RE
175 .SS Video Selection:
176 .TP
177 .B \-\-playlist\-start \f[I]NUMBER\f[]
178 Playlist video to start at (default is 1)
179 .RS
180 .RE
181 .TP
182 .B \-\-playlist\-end \f[I]NUMBER\f[]
183 Playlist video to end at (default is last)
184 .RS
185 .RE
186 .TP
187 .B \-\-playlist\-items \f[I]ITEM_SPEC\f[]
188 Playlist video items to download.
189 Specify indices of the videos in the playlist separated by commas like:
190 "\-\-playlist\-items 1,2,5,8" if you want to download videos indexed 1,
191 2, 5, 8 in the playlist.
192 You can specify range: "\-\-playlist\-items 1\-3,7,10\-13", it will
193 download the videos at index 1, 2, 3, 7, 10, 11, 12 and 13.
194 .RS
195 .RE
196 .TP
197 .B \-\-match\-title \f[I]REGEX\f[]
198 Download only matching titles (regex or caseless sub\-string)
199 .RS
200 .RE
201 .TP
202 .B \-\-reject\-title \f[I]REGEX\f[]
203 Skip download for matching titles (regex or caseless sub\-string)
204 .RS
205 .RE
206 .TP
207 .B \-\-max\-downloads \f[I]NUMBER\f[]
208 Abort after downloading NUMBER files
209 .RS
210 .RE
211 .TP
212 .B \-\-min\-filesize \f[I]SIZE\f[]
213 Do not download any videos smaller than SIZE (e.g.
214 50k or 44.6m)
215 .RS
216 .RE
217 .TP
218 .B \-\-max\-filesize \f[I]SIZE\f[]
219 Do not download any videos larger than SIZE (e.g.
220 50k or 44.6m)
221 .RS
222 .RE
223 .TP
224 .B \-\-date \f[I]DATE\f[]
225 Download only videos uploaded in this date
226 .RS
227 .RE
228 .TP
229 .B \-\-datebefore \f[I]DATE\f[]
230 Download only videos uploaded on or before this date (i.e.
231 inclusive)
232 .RS
233 .RE
234 .TP
235 .B \-\-dateafter \f[I]DATE\f[]
236 Download only videos uploaded on or after this date (i.e.
237 inclusive)
238 .RS
239 .RE
240 .TP
241 .B \-\-min\-views \f[I]COUNT\f[]
242 Do not download any videos with less than COUNT views
243 .RS
244 .RE
245 .TP
246 .B \-\-max\-views \f[I]COUNT\f[]
247 Do not download any videos with more than COUNT views
248 .RS
249 .RE
250 .TP
251 .B \-\-match\-filter \f[I]FILTER\f[]
252 Generic video filter.
253 Specify any key (see the "OUTPUT TEMPLATE" for a list of available keys)
254 to match if the key is present, !key to check if the key is not present,
255 key > NUMBER (like "comment_count > 12", also works with >=, <, <=, !=,
256 =) to compare against a number, key = \[aq]LITERAL\[aq] (like "uploader
257 = \[aq]Mike Smith\[aq]", also works with !=) to match against a string
258 literal and & to require multiple matches.
259 Values which are not known are excluded unless you put a question mark
260 (?) after the operator.
261 For example, to only match videos that have been liked more than 100
262 times and disliked less than 50 times (or the dislike functionality is
263 not available at the given service), but who also have a description,
264 use \-\-match\-filter "like_count > 100 & dislike_count <?
265 50 & description" .
266 .RS
267 .RE
268 .TP
269 .B \-\-no\-playlist
270 Download only the video, if the URL refers to a video and a playlist.
271 .RS
272 .RE
273 .TP
274 .B \-\-yes\-playlist
275 Download the playlist, if the URL refers to a video and a playlist.
276 .RS
277 .RE
278 .TP
279 .B \-\-age\-limit \f[I]YEARS\f[]
280 Download only videos suitable for the given age
281 .RS
282 .RE
283 .TP
284 .B \-\-download\-archive \f[I]FILE\f[]
285 Download only videos not listed in the archive file.
286 Record the IDs of all downloaded videos in it.
287 .RS
288 .RE
289 .TP
290 .B \-\-include\-ads
291 Download advertisements as well (experimental)
292 .RS
293 .RE
294 .SS Download Options:
295 .TP
296 .B \-r, \-\-limit\-rate \f[I]RATE\f[]
297 Maximum download rate in bytes per second (e.g.
298 50K or 4.2M)
299 .RS
300 .RE
301 .TP
302 .B \-R, \-\-retries \f[I]RETRIES\f[]
303 Number of retries (default is 10), or "infinite".
304 .RS
305 .RE
306 .TP
307 .B \-\-fragment\-retries \f[I]RETRIES\f[]
308 Number of retries for a fragment (default is 10), or "infinite" (DASH,
309 hlsnative and ISM)
310 .RS
311 .RE
312 .TP
313 .B \-\-skip\-unavailable\-fragments
314 Skip unavailable fragments (DASH, hlsnative and ISM)
315 .RS
316 .RE
317 .TP
318 .B \-\-abort\-on\-unavailable\-fragment
319 Abort downloading when some fragment is not available
320 .RS
321 .RE
322 .TP
323 .B \-\-keep\-fragments
324 Keep downloaded fragments on disk after downloading is finished;
325 fragments are erased by default
326 .RS
327 .RE
328 .TP
329 .B \-\-buffer\-size \f[I]SIZE\f[]
330 Size of download buffer (e.g.
331 1024 or 16K) (default is 1024)
332 .RS
333 .RE
334 .TP
335 .B \-\-no\-resize\-buffer
336 Do not automatically adjust the buffer size.
337 By default, the buffer size is automatically resized from an initial
338 value of SIZE.
339 .RS
340 .RE
341 .TP
342 .B \-\-http\-chunk\-size \f[I]SIZE\f[]
343 Size of a chunk for chunk\-based HTTP downloading (e.g.
344 10485760 or 10M) (default is disabled).
345 May be useful for bypassing bandwidth throttling imposed by a webserver
346 (experimental)
347 .RS
348 .RE
349 .TP
350 .B \-\-playlist\-reverse
351 Download playlist videos in reverse order
352 .RS
353 .RE
354 .TP
355 .B \-\-playlist\-random
356 Download playlist videos in random order
357 .RS
358 .RE
359 .TP
360 .B \-\-xattr\-set\-filesize
361 Set file xattribute ytdl.filesize with expected file size
362 .RS
363 .RE
364 .TP
365 .B \-\-hls\-prefer\-native
366 Use the native HLS downloader instead of ffmpeg
367 .RS
368 .RE
369 .TP
370 .B \-\-hls\-prefer\-ffmpeg
371 Use ffmpeg instead of the native HLS downloader
372 .RS
373 .RE
374 .TP
375 .B \-\-hls\-use\-mpegts
376 Use the mpegts container for HLS videos, allowing to play the video
377 while downloading (some players may not be able to play it)
378 .RS
379 .RE
380 .TP
381 .B \-\-external\-downloader \f[I]COMMAND\f[]
382 Use the specified external downloader.
383 Currently supports aria2c,avconv,axel,curl,ffmpeg,httpie,wget
384 .RS
385 .RE
386 .TP
387 .B \-\-external\-downloader\-args \f[I]ARGS\f[]
388 Give these arguments to the external downloader
389 .RS
390 .RE
391 .SS Filesystem Options:
392 .TP
393 .B \-a, \-\-batch\-file \f[I]FILE\f[]
394 File containing URLs to download (\[aq]\-\[aq] for stdin), one URL per
395 line.
396 Lines starting with \[aq]#\[aq], \[aq];\[aq] or \[aq]]\[aq] are
397 considered as comments and ignored.
398 .RS
399 .RE
400 .TP
401 .B \-\-id
402 Use only video ID in file name
403 .RS
404 .RE
405 .TP
406 .B \-o, \-\-output \f[I]TEMPLATE\f[]
407 Output filename template, see the "OUTPUT TEMPLATE" for all the info
408 .RS
409 .RE
410 .TP
411 .B \-\-autonumber\-start \f[I]NUMBER\f[]
412 Specify the start value for %(autonumber)s (default is 1)
413 .RS
414 .RE
415 .TP
416 .B \-\-restrict\-filenames
417 Restrict filenames to only ASCII characters, and avoid "&" and spaces in
418 filenames
419 .RS
420 .RE
421 .TP
422 .B \-w, \-\-no\-overwrites
423 Do not overwrite files
424 .RS
425 .RE
426 .TP
427 .B \-c, \-\-continue
428 Force resume of partially downloaded files.
429 By default, youtube\-dl will resume downloads if possible.
430 .RS
431 .RE
432 .TP
433 .B \-\-no\-continue
434 Do not resume partially downloaded files (restart from beginning)
435 .RS
436 .RE
437 .TP
438 .B \-\-no\-part
439 Do not use .part files \- write directly into output file
440 .RS
441 .RE
442 .TP
443 .B \-\-no\-mtime
444 Do not use the Last\-modified header to set the file modification time
445 .RS
446 .RE
447 .TP
448 .B \-\-write\-description
449 Write video description to a .description file
450 .RS
451 .RE
452 .TP
453 .B \-\-write\-info\-json
454 Write video metadata to a .info.json file
455 .RS
456 .RE
457 .TP
458 .B \-\-write\-annotations
459 Write video annotations to a .annotations.xml file
460 .RS
461 .RE
462 .TP
463 .B \-\-load\-info\-json \f[I]FILE\f[]
464 JSON file containing the video information (created with the
465 "\-\-write\-info\-json" option)
466 .RS
467 .RE
468 .TP
469 .B \-\-cookies \f[I]FILE\f[]
470 File to read cookies from and dump cookie jar in
471 .RS
472 .RE
473 .TP
474 .B \-\-cache\-dir \f[I]DIR\f[]
475 Location in the filesystem where youtube\-dl can store some downloaded
476 information permanently.
477 By default $XDG_CACHE_HOME/youtube\-dl or ~/.cache/youtube\-dl .
478 At the moment, only YouTube player files (for videos with obfuscated
479 signatures) are cached, but that may change.
480 .RS
481 .RE
482 .TP
483 .B \-\-no\-cache\-dir
484 Disable filesystem caching
485 .RS
486 .RE
487 .TP
488 .B \-\-rm\-cache\-dir
489 Delete all filesystem cache files
490 .RS
491 .RE
492 .SS Thumbnail images:
493 .TP
494 .B \-\-write\-thumbnail
495 Write thumbnail image to disk
496 .RS
497 .RE
498 .TP
499 .B \-\-write\-all\-thumbnails
500 Write all thumbnail image formats to disk
501 .RS
502 .RE
503 .TP
504 .B \-\-list\-thumbnails
505 Simulate and list all available thumbnail formats
506 .RS
507 .RE
508 .SS Verbosity / Simulation Options:
509 .TP
510 .B \-q, \-\-quiet
511 Activate quiet mode
512 .RS
513 .RE
514 .TP
515 .B \-\-no\-warnings
516 Ignore warnings
517 .RS
518 .RE
519 .TP
520 .B \-s, \-\-simulate
521 Do not download the video and do not write anything to disk
522 .RS
523 .RE
524 .TP
525 .B \-\-skip\-download
526 Do not download the video
527 .RS
528 .RE
529 .TP
530 .B \-g, \-\-get\-url
531 Simulate, quiet but print URL
532 .RS
533 .RE
534 .TP
535 .B \-e, \-\-get\-title
536 Simulate, quiet but print title
537 .RS
538 .RE
539 .TP
540 .B \-\-get\-id
541 Simulate, quiet but print id
542 .RS
543 .RE
544 .TP
545 .B \-\-get\-thumbnail
546 Simulate, quiet but print thumbnail URL
547 .RS
548 .RE
549 .TP
550 .B \-\-get\-description
551 Simulate, quiet but print video description
552 .RS
553 .RE
554 .TP
555 .B \-\-get\-duration
556 Simulate, quiet but print video length
557 .RS
558 .RE
559 .TP
560 .B \-\-get\-filename
561 Simulate, quiet but print output filename
562 .RS
563 .RE
564 .TP
565 .B \-\-get\-format
566 Simulate, quiet but print output format
567 .RS
568 .RE
569 .TP
570 .B \-j, \-\-dump\-json
571 Simulate, quiet but print JSON information.
572 See the "OUTPUT TEMPLATE" for a description of available keys.
573 .RS
574 .RE
575 .TP
576 .B \-J, \-\-dump\-single\-json
577 Simulate, quiet but print JSON information for each command\-line
578 argument.
579 If the URL refers to a playlist, dump the whole playlist information in
580 a single line.
581 .RS
582 .RE
583 .TP
584 .B \-\-print\-json
585 Be quiet and print the video information as JSON (video is still being
586 downloaded).
587 .RS
588 .RE
589 .TP
590 .B \-\-newline
591 Output progress bar as new lines
592 .RS
593 .RE
594 .TP
595 .B \-\-no\-progress
596 Do not print progress bar
597 .RS
598 .RE
599 .TP
600 .B \-\-console\-title
601 Display progress in console titlebar
602 .RS
603 .RE
604 .TP
605 .B \-v, \-\-verbose
606 Print various debugging information
607 .RS
608 .RE
609 .TP
610 .B \-\-dump\-pages
611 Print downloaded pages encoded using base64 to debug problems (very
612 verbose)
613 .RS
614 .RE
615 .TP
616 .B \-\-write\-pages
617 Write downloaded intermediary pages to files in the current directory to
618 debug problems
619 .RS
620 .RE
621 .TP
622 .B \-\-print\-traffic
623 Display sent and read HTTP traffic
624 .RS
625 .RE
626 .TP
627 .B \-C, \-\-call\-home
628 Contact the youtube\-dl server for debugging
629 .RS
630 .RE
631 .TP
632 .B \-\-no\-call\-home
633 Do NOT contact the youtube\-dl server for debugging
634 .RS
635 .RE
636 .SS Workarounds:
637 .TP
638 .B \-\-encoding \f[I]ENCODING\f[]
639 Force the specified encoding (experimental)
640 .RS
641 .RE
642 .TP
643 .B \-\-no\-check\-certificate
644 Suppress HTTPS certificate validation
645 .RS
646 .RE
647 .TP
648 .B \-\-prefer\-insecure
649 Use an unencrypted connection to retrieve information about the video.
650 (Currently supported only for YouTube)
651 .RS
652 .RE
653 .TP
654 .B \-\-user\-agent \f[I]UA\f[]
655 Specify a custom user agent
656 .RS
657 .RE
658 .TP
659 .B \-\-referer \f[I]URL\f[]
660 Specify a custom referer, use if the video access is restricted to one
661 domain
662 .RS
663 .RE
664 .TP
665 .B \-\-add\-header \f[I]FIELD:VALUE\f[]
666 Specify a custom HTTP header and its value, separated by a colon
667 \[aq]:\[aq].
668 You can use this option multiple times
669 .RS
670 .RE
671 .TP
672 .B \-\-bidi\-workaround
673 Work around terminals that lack bidirectional text support.
674 Requires bidiv or fribidi executable in PATH
675 .RS
676 .RE
677 .TP
678 .B \-\-sleep\-interval \f[I]SECONDS\f[]
679 Number of seconds to sleep before each download when used alone or a
680 lower bound of a range for randomized sleep before each download
681 (minimum possible number of seconds to sleep) when used along with
682 \-\-max\-sleep\-interval.
683 .RS
684 .RE
685 .TP
686 .B \-\-max\-sleep\-interval \f[I]SECONDS\f[]
687 Upper bound of a range for randomized sleep before each download
688 (maximum possible number of seconds to sleep).
689 Must only be used along with \-\-min\-sleep\-interval.
690 .RS
691 .RE
692 .SS Video Format Options:
693 .TP
694 .B \-f, \-\-format \f[I]FORMAT\f[]
695 Video format code, see the "FORMAT SELECTION" for all the info
696 .RS
697 .RE
698 .TP
699 .B \-\-all\-formats
700 Download all available video formats
701 .RS
702 .RE
703 .TP
704 .B \-\-prefer\-free\-formats
705 Prefer free video formats unless a specific one is requested
706 .RS
707 .RE
708 .TP
709 .B \-F, \-\-list\-formats
710 List all available formats of requested videos
711 .RS
712 .RE
713 .TP
714 .B \-\-youtube\-skip\-dash\-manifest
715 Do not download the DASH manifests and related data on YouTube videos
716 .RS
717 .RE
718 .TP
719 .B \-\-merge\-output\-format \f[I]FORMAT\f[]
720 If a merge is required (e.g.
721 bestvideo+bestaudio), output to given container format.
722 One of mkv, mp4, ogg, webm, flv.
723 Ignored if no merge is required
724 .RS
725 .RE
726 .SS Subtitle Options:
727 .TP
728 .B \-\-write\-sub
729 Write subtitle file
730 .RS
731 .RE
732 .TP
733 .B \-\-write\-auto\-sub
734 Write automatically generated subtitle file (YouTube only)
735 .RS
736 .RE
737 .TP
738 .B \-\-all\-subs
739 Download all the available subtitles of the video
740 .RS
741 .RE
742 .TP
743 .B \-\-list\-subs
744 List all available subtitles for the video
745 .RS
746 .RE
747 .TP
748 .B \-\-sub\-format \f[I]FORMAT\f[]
749 Subtitle format, accepts formats preference, for example: "srt" or
750 "ass/srt/best"
751 .RS
752 .RE
753 .TP
754 .B \-\-sub\-lang \f[I]LANGS\f[]
755 Languages of the subtitles to download (optional) separated by commas,
756 use \-\-list\- subs for available language tags
757 .RS
758 .RE
759 .SS Authentication Options:
760 .TP
761 .B \-u, \-\-username \f[I]USERNAME\f[]
762 Login with this account ID
763 .RS
764 .RE
765 .TP
766 .B \-p, \-\-password \f[I]PASSWORD\f[]
767 Account password.
768 If this option is left out, youtube\-dl will ask interactively.
769 .RS
770 .RE
771 .TP
772 .B \-2, \-\-twofactor \f[I]TWOFACTOR\f[]
773 Two\-factor authentication code
774 .RS
775 .RE
776 .TP
777 .B \-n, \-\-netrc
778 Use .netrc authentication data
779 .RS
780 .RE
781 .TP
782 .B \-\-video\-password \f[I]PASSWORD\f[]
783 Video password (vimeo, smotri, youku)
784 .RS
785 .RE
786 .SS Adobe Pass Options:
787 .TP
788 .B \-\-ap\-mso \f[I]MSO\f[]
789 Adobe Pass multiple\-system operator (TV provider) identifier, use
790 \-\-ap\-list\-mso for a list of available MSOs
791 .RS
792 .RE
793 .TP
794 .B \-\-ap\-username \f[I]USERNAME\f[]
795 Multiple\-system operator account login
796 .RS
797 .RE
798 .TP
799 .B \-\-ap\-password \f[I]PASSWORD\f[]
800 Multiple\-system operator account password.
801 If this option is left out, youtube\-dl will ask interactively.
802 .RS
803 .RE
804 .TP
805 .B \-\-ap\-list\-mso
806 List all supported multiple\-system operators
807 .RS
808 .RE
809 .SS Post\-processing Options:
810 .TP
811 .B \-x, \-\-extract\-audio
812 Convert video files to audio\-only files (requires ffmpeg or avconv and
813 ffprobe or avprobe)
814 .RS
815 .RE
816 .TP
817 .B \-\-audio\-format \f[I]FORMAT\f[]
818 Specify audio format: "best", "aac", "flac", "mp3", "m4a", "opus",
819 "vorbis", or "wav"; "best" by default; No effect without \-x
820 .RS
821 .RE
822 .TP
823 .B \-\-audio\-quality \f[I]QUALITY\f[]
824 Specify ffmpeg/avconv audio quality, insert a value between 0 (better)
825 and 9 (worse) for VBR or a specific bitrate like 128K (default 5)
826 .RS
827 .RE
828 .TP
829 .B \-\-recode\-video \f[I]FORMAT\f[]
830 Encode the video to another format if necessary (currently supported:
831 mp4|flv|ogg|webm|mkv|avi)
832 .RS
833 .RE
834 .TP
835 .B \-\-postprocessor\-args \f[I]ARGS\f[]
836 Give these arguments to the postprocessor
837 .RS
838 .RE
839 .TP
840 .B \-k, \-\-keep\-video
841 Keep the video file on disk after the post\- processing; the video is
842 erased by default
843 .RS
844 .RE
845 .TP
846 .B \-\-no\-post\-overwrites
847 Do not overwrite post\-processed files; the post\-processed files are
848 overwritten by default
849 .RS
850 .RE
851 .TP
852 .B \-\-embed\-subs
853 Embed subtitles in the video (only for mp4, webm and mkv videos)
854 .RS
855 .RE
856 .TP
857 .B \-\-embed\-thumbnail
858 Embed thumbnail in the audio as cover art
859 .RS
860 .RE
861 .TP
862 .B \-\-add\-metadata
863 Write metadata to the video file
864 .RS
865 .RE
866 .TP
867 .B \-\-metadata\-from\-title \f[I]FORMAT\f[]
868 Parse additional metadata like song title / artist from the video title.
869 The format syntax is the same as \-\-output.
870 Regular expression with named capture groups may also be used.
871 The parsed parameters replace existing values.
872 Example: \-\-metadata\-from\- title "%(artist)s \- %(title)s" matches a
873 title like "Coldplay \- Paradise".
874 Example (regex): \-\-metadata\-from\-title "(?P.+?) \- (?P
875 .RS
876 \&.+)"
877 .RE
878 .TP
879 .B \-\-xattrs
880 Write metadata to the video file\[aq]s xattrs (using dublin core and xdg
881 standards)
882 .RS
883 .RE
884 .TP
885 .B \-\-fixup \f[I]POLICY\f[]
886 Automatically correct known faults of the file.
887 One of never (do nothing), warn (only emit a warning), detect_or_warn
888 (the default; fix file if we can, warn otherwise)
889 .RS
890 .RE
891 .TP
892 .B \-\-prefer\-avconv
893 Prefer avconv over ffmpeg for running the postprocessors
894 .RS
895 .RE
896 .TP
897 .B \-\-prefer\-ffmpeg
898 Prefer ffmpeg over avconv for running the postprocessors (default)
899 .RS
900 .RE
901 .TP
902 .B \-\-ffmpeg\-location \f[I]PATH\f[]
903 Location of the ffmpeg/avconv binary; either the path to the binary or
904 its containing directory.
905 .RS
906 .RE
907 .TP
908 .B \-\-exec \f[I]CMD\f[]
909 Execute a command on the file after downloading and post\-processing,
910 similar to find\[aq]s \-exec syntax.
911 Example: \-\-exec \[aq]adb push {} /sdcard/Music/ && rm {}\[aq]
912 .RS
913 .RE
914 .TP
915 .B \-\-convert\-subs \f[I]FORMAT\f[]
916 Convert the subtitles to other format (currently supported:
917 srt|ass|vtt|lrc)
918 .RS
919 .RE
920 .SH CONFIGURATION
921 .PP
922 You can configure youtube\-dl by placing any supported command line
923 option to a configuration file.
924 On Linux and macOS, the system wide configuration file is located at
925 \f[C]/etc/youtube\-dl.conf\f[] and the user wide configuration file at
926 \f[C]~/.config/youtube\-dl/config\f[].
927 On Windows, the user wide configuration file locations are
928 \f[C]%APPDATA%\\youtube\-dl\\config.txt\f[] or
929 \f[C]C:\\Users\\<user\ name>\\youtube\-dl.conf\f[].
930 Note that by default configuration file may not exist so you may need to
931 create it yourself.
932 .PP
933 For example, with the following configuration file youtube\-dl will
934 always extract the audio, not copy the mtime, use a proxy and save all
935 videos under \f[C]Movies\f[] directory in your home directory:
936 .IP
937 .nf
938 \f[C]
939 #\ Lines\ starting\ with\ #\ are\ comments
940
941 #\ Always\ extract\ audio
942 \-x
943
944 #\ Do\ not\ copy\ the\ mtime
945 \-\-no\-mtime
946
947 #\ Use\ this\ proxy
948 \-\-proxy\ 127.0.0.1:3128
949
950 #\ Save\ all\ videos\ under\ Movies\ directory\ in\ your\ home\ directory
951 \-o\ ~/Movies/%(title)s.%(ext)s
952 \f[]
953 .fi
954 .PP
955 Note that options in configuration file are just the same options aka
956 switches used in regular command line calls thus there \f[B]must be no
957 whitespace\f[] after \f[C]\-\f[] or \f[C]\-\-\f[], e.g.
958 \f[C]\-o\f[] or \f[C]\-\-proxy\f[] but not \f[C]\-\ o\f[] or
959 \f[C]\-\-\ proxy\f[].
960 .PP
961 You can use \f[C]\-\-ignore\-config\f[] if you want to disable the
962 configuration file for a particular youtube\-dl run.
963 .PP
964 You can also use \f[C]\-\-config\-location\f[] if you want to use custom
965 configuration file for a particular youtube\-dl run.
966 .SS Authentication with \f[C]\&.netrc\f[] file
967 .PP
968 You may also want to configure automatic credentials storage for
969 extractors that support authentication (by providing login and password
970 with \f[C]\-\-username\f[] and \f[C]\-\-password\f[]) in order not to
971 pass credentials as command line arguments on every youtube\-dl
972 execution and prevent tracking plain text passwords in the shell command
973 history.
974 You can achieve this using a \f[C]\&.netrc\f[]
975 file (https://stackoverflow.com/tags/.netrc/info) on a per extractor
976 basis.
977 For that you will need to create a \f[C]\&.netrc\f[] file in your
978 \f[C]$HOME\f[] and restrict permissions to read/write by only you:
979 .IP
980 .nf
981 \f[C]
982 touch\ $HOME/.netrc
983 chmod\ a\-rwx,u+rw\ $HOME/.netrc
984 \f[]
985 .fi
986 .PP
987 After that you can add credentials for an extractor in the following
988 format, where \f[I]extractor\f[] is the name of the extractor in
989 lowercase:
990 .IP
991 .nf
992 \f[C]
993 machine\ <extractor>\ login\ <login>\ password\ <password>
994 \f[]
995 .fi
996 .PP
997 For example:
998 .IP
999 .nf
1000 \f[C]
1001 machine\ youtube\ login\ myaccount\@gmail.com\ password\ my_youtube_password
1002 machine\ twitch\ login\ my_twitch_account_name\ password\ my_twitch_password
1003 \f[]
1004 .fi
1005 .PP
1006 To activate authentication with the \f[C]\&.netrc\f[] file you should
1007 pass \f[C]\-\-netrc\f[] to youtube\-dl or place it in the configuration
1008 file.
1009 .PP
1010 On Windows you may also need to setup the \f[C]%HOME%\f[] environment
1011 variable manually.
1012 For example:
1013 .IP
1014 .nf
1015 \f[C]
1016 set\ HOME=%USERPROFILE%
1017 \f[]
1018 .fi
1019 .SH OUTPUT TEMPLATE
1020 .PP
1021 The \f[C]\-o\f[] option allows users to indicate a template for the
1022 output file names.
1023 .PP
1024 \f[B]tl;dr:\f[] navigate me to examples.
1025 .PP
1026 The basic usage is not to set any template arguments when downloading a
1027 single file, like in
1028 \f[C]youtube\-dl\ \-o\ funny_video.flv\ "https://some/video"\f[].
1029 However, it may contain special sequences that will be replaced when
1030 downloading each video.
1031 The special sequences may be formatted according to python string
1032 formatting
1033 operations (https://docs.python.org/2/library/stdtypes.html#string-formatting).
1034 For example, \f[C]%(NAME)s\f[] or \f[C]%(NAME)05d\f[].
1035 To clarify, that is a percent symbol followed by a name in parentheses,
1036 followed by formatting operations.
1037 Allowed names along with sequence type are:
1038 .IP \[bu] 2
1039 \f[C]id\f[] (string): Video identifier
1040 .IP \[bu] 2
1041 \f[C]title\f[] (string): Video title
1042 .IP \[bu] 2
1043 \f[C]url\f[] (string): Video URL
1044 .IP \[bu] 2
1045 \f[C]ext\f[] (string): Video filename extension
1046 .IP \[bu] 2
1047 \f[C]alt_title\f[] (string): A secondary title of the video
1048 .IP \[bu] 2
1049 \f[C]display_id\f[] (string): An alternative identifier for the video
1050 .IP \[bu] 2
1051 \f[C]uploader\f[] (string): Full name of the video uploader
1052 .IP \[bu] 2
1053 \f[C]license\f[] (string): License name the video is licensed under
1054 .IP \[bu] 2
1055 \f[C]creator\f[] (string): The creator of the video
1056 .IP \[bu] 2
1057 \f[C]release_date\f[] (string): The date (YYYYMMDD) when the video was
1058 released
1059 .IP \[bu] 2
1060 \f[C]timestamp\f[] (numeric): UNIX timestamp of the moment the video
1061 became available
1062 .IP \[bu] 2
1063 \f[C]upload_date\f[] (string): Video upload date (YYYYMMDD)
1064 .IP \[bu] 2
1065 \f[C]uploader_id\f[] (string): Nickname or id of the video uploader
1066 .IP \[bu] 2
1067 \f[C]channel\f[] (string): Full name of the channel the video is
1068 uploaded on
1069 .IP \[bu] 2
1070 \f[C]channel_id\f[] (string): Id of the channel
1071 .IP \[bu] 2
1072 \f[C]location\f[] (string): Physical location where the video was filmed
1073 .IP \[bu] 2
1074 \f[C]duration\f[] (numeric): Length of the video in seconds
1075 .IP \[bu] 2
1076 \f[C]view_count\f[] (numeric): How many users have watched the video on
1077 the platform
1078 .IP \[bu] 2
1079 \f[C]like_count\f[] (numeric): Number of positive ratings of the video
1080 .IP \[bu] 2
1081 \f[C]dislike_count\f[] (numeric): Number of negative ratings of the
1082 video
1083 .IP \[bu] 2
1084 \f[C]repost_count\f[] (numeric): Number of reposts of the video
1085 .IP \[bu] 2
1086 \f[C]average_rating\f[] (numeric): Average rating give by users, the
1087 scale used depends on the webpage
1088 .IP \[bu] 2
1089 \f[C]comment_count\f[] (numeric): Number of comments on the video
1090 .IP \[bu] 2
1091 \f[C]age_limit\f[] (numeric): Age restriction for the video (years)
1092 .IP \[bu] 2
1093 \f[C]is_live\f[] (boolean): Whether this video is a live stream or a
1094 fixed\-length video
1095 .IP \[bu] 2
1096 \f[C]start_time\f[] (numeric): Time in seconds where the reproduction
1097 should start, as specified in the URL
1098 .IP \[bu] 2
1099 \f[C]end_time\f[] (numeric): Time in seconds where the reproduction
1100 should end, as specified in the URL
1101 .IP \[bu] 2
1102 \f[C]format\f[] (string): A human\-readable description of the format
1103 .IP \[bu] 2
1104 \f[C]format_id\f[] (string): Format code specified by
1105 \f[C]\-\-format\f[]
1106 .IP \[bu] 2
1107 \f[C]format_note\f[] (string): Additional info about the format
1108 .IP \[bu] 2
1109 \f[C]width\f[] (numeric): Width of the video
1110 .IP \[bu] 2
1111 \f[C]height\f[] (numeric): Height of the video
1112 .IP \[bu] 2
1113 \f[C]resolution\f[] (string): Textual description of width and height
1114 .IP \[bu] 2
1115 \f[C]tbr\f[] (numeric): Average bitrate of audio and video in KBit/s
1116 .IP \[bu] 2
1117 \f[C]abr\f[] (numeric): Average audio bitrate in KBit/s
1118 .IP \[bu] 2
1119 \f[C]acodec\f[] (string): Name of the audio codec in use
1120 .IP \[bu] 2
1121 \f[C]asr\f[] (numeric): Audio sampling rate in Hertz
1122 .IP \[bu] 2
1123 \f[C]vbr\f[] (numeric): Average video bitrate in KBit/s
1124 .IP \[bu] 2
1125 \f[C]fps\f[] (numeric): Frame rate
1126 .IP \[bu] 2
1127 \f[C]vcodec\f[] (string): Name of the video codec in use
1128 .IP \[bu] 2
1129 \f[C]container\f[] (string): Name of the container format
1130 .IP \[bu] 2
1131 \f[C]filesize\f[] (numeric): The number of bytes, if known in advance
1132 .IP \[bu] 2
1133 \f[C]filesize_approx\f[] (numeric): An estimate for the number of bytes
1134 .IP \[bu] 2
1135 \f[C]protocol\f[] (string): The protocol that will be used for the
1136 actual download
1137 .IP \[bu] 2
1138 \f[C]extractor\f[] (string): Name of the extractor
1139 .IP \[bu] 2
1140 \f[C]extractor_key\f[] (string): Key name of the extractor
1141 .IP \[bu] 2
1142 \f[C]epoch\f[] (numeric): Unix epoch when creating the file
1143 .IP \[bu] 2
1144 \f[C]autonumber\f[] (numeric): Five\-digit number that will be increased
1145 with each download, starting at zero
1146 .IP \[bu] 2
1147 \f[C]playlist\f[] (string): Name or id of the playlist that contains the
1148 video
1149 .IP \[bu] 2
1150 \f[C]playlist_index\f[] (numeric): Index of the video in the playlist
1151 padded with leading zeros according to the total length of the playlist
1152 .IP \[bu] 2
1153 \f[C]playlist_id\f[] (string): Playlist identifier
1154 .IP \[bu] 2
1155 \f[C]playlist_title\f[] (string): Playlist title
1156 .IP \[bu] 2
1157 \f[C]playlist_uploader\f[] (string): Full name of the playlist uploader
1158 .IP \[bu] 2
1159 \f[C]playlist_uploader_id\f[] (string): Nickname or id of the playlist
1160 uploader
1161 .PP
1162 Available for the video that belongs to some logical chapter or section:
1163 .IP \[bu] 2
1164 \f[C]chapter\f[] (string): Name or title of the chapter the video
1165 belongs to
1166 .IP \[bu] 2
1167 \f[C]chapter_number\f[] (numeric): Number of the chapter the video
1168 belongs to
1169 .IP \[bu] 2
1170 \f[C]chapter_id\f[] (string): Id of the chapter the video belongs to
1171 .PP
1172 Available for the video that is an episode of some series or programme:
1173 .IP \[bu] 2
1174 \f[C]series\f[] (string): Title of the series or programme the video
1175 episode belongs to
1176 .IP \[bu] 2
1177 \f[C]season\f[] (string): Title of the season the video episode belongs
1178 to
1179 .IP \[bu] 2
1180 \f[C]season_number\f[] (numeric): Number of the season the video episode
1181 belongs to
1182 .IP \[bu] 2
1183 \f[C]season_id\f[] (string): Id of the season the video episode belongs
1184 to
1185 .IP \[bu] 2
1186 \f[C]episode\f[] (string): Title of the video episode
1187 .IP \[bu] 2
1188 \f[C]episode_number\f[] (numeric): Number of the video episode within a
1189 season
1190 .IP \[bu] 2
1191 \f[C]episode_id\f[] (string): Id of the video episode
1192 .PP
1193 Available for the media that is a track or a part of a music album:
1194 .IP \[bu] 2
1195 \f[C]track\f[] (string): Title of the track
1196 .IP \[bu] 2
1197 \f[C]track_number\f[] (numeric): Number of the track within an album or
1198 a disc
1199 .IP \[bu] 2
1200 \f[C]track_id\f[] (string): Id of the track
1201 .IP \[bu] 2
1202 \f[C]artist\f[] (string): Artist(s) of the track
1203 .IP \[bu] 2
1204 \f[C]genre\f[] (string): Genre(s) of the track
1205 .IP \[bu] 2
1206 \f[C]album\f[] (string): Title of the album the track belongs to
1207 .IP \[bu] 2
1208 \f[C]album_type\f[] (string): Type of the album
1209 .IP \[bu] 2
1210 \f[C]album_artist\f[] (string): List of all artists appeared on the
1211 album
1212 .IP \[bu] 2
1213 \f[C]disc_number\f[] (numeric): Number of the disc or other physical
1214 medium the track belongs to
1215 .IP \[bu] 2
1216 \f[C]release_year\f[] (numeric): Year (YYYY) when the album was released
1217 .PP
1218 Each aforementioned sequence when referenced in an output template will
1219 be replaced by the actual value corresponding to the sequence name.
1220 Note that some of the sequences are not guaranteed to be present since
1221 they depend on the metadata obtained by a particular extractor.
1222 Such sequences will be replaced with \f[C]NA\f[].
1223 .PP
1224 For example for \f[C]\-o\ %(title)s\-%(id)s.%(ext)s\f[] and an mp4 video
1225 with title \f[C]youtube\-dl\ test\ video\f[] and id
1226 \f[C]BaW_jenozKcj\f[], this will result in a
1227 \f[C]youtube\-dl\ test\ video\-BaW_jenozKcj.mp4\f[] file created in the
1228 current directory.
1229 .PP
1230 For numeric sequences you can use numeric related formatting, for
1231 example, \f[C]%(view_count)05d\f[] will result in a string with view
1232 count padded with zeros up to 5 characters, like in \f[C]00042\f[].
1233 .PP
1234 Output templates can also contain arbitrary hierarchical path, e.g.
1235 \f[C]\-o\ \[aq]%(playlist)s/%(playlist_index)s\ \-\ %(title)s.%(ext)s\[aq]\f[]
1236 which will result in downloading each video in a directory corresponding
1237 to this path template.
1238 Any missing directory will be automatically created for you.
1239 .PP
1240 To use percent literals in an output template use \f[C]%%\f[].
1241 To output to stdout use \f[C]\-o\ \-\f[].
1242 .PP
1243 The current default template is \f[C]%(title)s\-%(id)s.%(ext)s\f[].
1244 .PP
1245 In some cases, you don\[aq]t want special characters such as äø­, spaces,
1246 or &, such as when transferring the downloaded filename to a Windows
1247 system or the filename through an 8bit\-unsafe channel.
1248 In these cases, add the \f[C]\-\-restrict\-filenames\f[] flag to get a
1249 shorter title:
1250 .SS Output template and Windows batch files
1251 .PP
1252 If you are using an output template inside a Windows batch file then you
1253 must escape plain percent characters (\f[C]%\f[]) by doubling, so that
1254 \f[C]\-o\ "%(title)s\-%(id)s.%(ext)s"\f[] should become
1255 \f[C]\-o\ "%%(title)s\-%%(id)s.%%(ext)s"\f[].
1256 However you should not touch \f[C]%\f[]\[aq]s that are not plain
1257 characters, e.g.
1258 environment variables for expansion should stay intact:
1259 \f[C]\-o\ "C:\\%HOMEPATH%\\Desktop\\%%(title)s.%%(ext)s"\f[].
1260 .SS Output template examples
1261 .PP
1262 Note that on Windows you may need to use double quotes instead of
1263 single.
1264 .IP
1265 .nf
1266 \f[C]
1267 $\ youtube\-dl\ \-\-get\-filename\ \-o\ \[aq]%(title)s.%(ext)s\[aq]\ BaW_jenozKc
1268 youtube\-dl\ test\ video\ \[aq]\[aq]_Ƥā†­š•.mp4\ \ \ \ #\ All\ kinds\ of\ weird\ characters
1269
1270 $\ youtube\-dl\ \-\-get\-filename\ \-o\ \[aq]%(title)s.%(ext)s\[aq]\ BaW_jenozKc\ \-\-restrict\-filenames
1271 youtube\-dl_test_video_.mp4\ \ \ \ \ \ \ \ \ \ #\ A\ simple\ file\ name
1272
1273 #\ Download\ YouTube\ playlist\ videos\ in\ separate\ directory\ indexed\ by\ video\ order\ in\ a\ playlist
1274 $\ youtube\-dl\ \-o\ \[aq]%(playlist)s/%(playlist_index)s\ \-\ %(title)s.%(ext)s\[aq]\ https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re
1275
1276 #\ Download\ all\ playlists\ of\ YouTube\ channel/user\ keeping\ each\ playlist\ in\ separate\ directory:
1277 $\ youtube\-dl\ \-o\ \[aq]%(uploader)s/%(playlist)s/%(playlist_index)s\ \-\ %(title)s.%(ext)s\[aq]\ https://www.youtube.com/user/TheLinuxFoundation/playlists
1278
1279 #\ Download\ Udemy\ course\ keeping\ each\ chapter\ in\ separate\ directory\ under\ MyVideos\ directory\ in\ your\ home
1280 $\ youtube\-dl\ \-u\ user\ \-p\ password\ \-o\ \[aq]~/MyVideos/%(playlist)s/%(chapter_number)s\ \-\ %(chapter)s/%(title)s.%(ext)s\[aq]\ https://www.udemy.com/java\-tutorial/
1281
1282 #\ Download\ entire\ series\ season\ keeping\ each\ series\ and\ each\ season\ in\ separate\ directory\ under\ C:/MyVideos
1283 $\ youtube\-dl\ \-o\ "C:/MyVideos/%(series)s/%(season_number)s\ \-\ %(season)s/%(episode_number)s\ \-\ %(episode)s.%(ext)s"\ https://videomore.ru/kino_v_detalayah/5_sezon/367617
1284
1285 #\ Stream\ the\ video\ being\ downloaded\ to\ stdout
1286 $\ youtube\-dl\ \-o\ \-\ BaW_jenozKc
1287 \f[]
1288 .fi
1289 .SH FORMAT SELECTION
1290 .PP
1291 By default youtube\-dl tries to download the best available quality,
1292 i.e.
1293 if you want the best quality you \f[B]don\[aq]t need\f[] to pass any
1294 special options, youtube\-dl will guess it for you by \f[B]default\f[].
1295 .PP
1296 But sometimes you may want to download in a different format, for
1297 example when you are on a slow or intermittent connection.
1298 The key mechanism for achieving this is so\-called \f[I]format
1299 selection\f[] based on which you can explicitly specify desired format,
1300 select formats based on some criterion or criteria, setup precedence and
1301 much more.
1302 .PP
1303 The general syntax for format selection is \f[C]\-\-format\ FORMAT\f[]
1304 or shorter \f[C]\-f\ FORMAT\f[] where \f[C]FORMAT\f[] is a \f[I]selector
1305 expression\f[], i.e.
1306 an expression that describes format or formats you would like to
1307 download.
1308 .PP
1309 \f[B]tl;dr:\f[] navigate me to examples.
1310 .PP
1311 The simplest case is requesting a specific format, for example with
1312 \f[C]\-f\ 22\f[] you can download the format with format code equal to
1313 22.
1314 You can get the list of available format codes for particular video
1315 using \f[C]\-\-list\-formats\f[] or \f[C]\-F\f[].
1316 Note that these format codes are extractor specific.
1317 .PP
1318 You can also use a file extension (currently \f[C]3gp\f[], \f[C]aac\f[],
1319 \f[C]flv\f[], \f[C]m4a\f[], \f[C]mp3\f[], \f[C]mp4\f[], \f[C]ogg\f[],
1320 \f[C]wav\f[], \f[C]webm\f[] are supported) to download the best quality
1321 format of a particular file extension served as a single file, e.g.
1322 \f[C]\-f\ webm\f[] will download the best quality format with the
1323 \f[C]webm\f[] extension served as a single file.
1324 .PP
1325 You can also use special names to select particular edge case formats:
1326 .IP \[bu] 2
1327 \f[C]best\f[]: Select the best quality format represented by a single
1328 file with video and audio.
1329 .IP \[bu] 2
1330 \f[C]worst\f[]: Select the worst quality format represented by a single
1331 file with video and audio.
1332 .IP \[bu] 2
1333 \f[C]bestvideo\f[]: Select the best quality video\-only format (e.g.
1334 DASH video).
1335 May not be available.
1336 .IP \[bu] 2
1337 \f[C]worstvideo\f[]: Select the worst quality video\-only format.
1338 May not be available.
1339 .IP \[bu] 2
1340 \f[C]bestaudio\f[]: Select the best quality audio only\-format.
1341 May not be available.
1342 .IP \[bu] 2
1343 \f[C]worstaudio\f[]: Select the worst quality audio only\-format.
1344 May not be available.
1345 .PP
1346 For example, to download the worst quality video\-only format you can
1347 use \f[C]\-f\ worstvideo\f[].
1348 .PP
1349 If you want to download multiple videos and they don\[aq]t have the same
1350 formats available, you can specify the order of preference using
1351 slashes.
1352 Note that slash is left\-associative, i.e.
1353 formats on the left hand side are preferred, for example
1354 \f[C]\-f\ 22/17/18\f[] will download format 22 if it\[aq]s available,
1355 otherwise it will download format 17 if it\[aq]s available, otherwise it
1356 will download format 18 if it\[aq]s available, otherwise it will
1357 complain that no suitable formats are available for download.
1358 .PP
1359 If you want to download several formats of the same video use a comma as
1360 a separator, e.g.
1361 \f[C]\-f\ 22,17,18\f[] will download all these three formats, of course
1362 if they are available.
1363 Or a more sophisticated example combined with the precedence feature:
1364 \f[C]\-f\ 136/137/mp4/bestvideo,140/m4a/bestaudio\f[].
1365 .PP
1366 You can also filter the video formats by putting a condition in
1367 brackets, as in \f[C]\-f\ "best[height=720]"\f[] (or
1368 \f[C]\-f\ "[filesize>10M]"\f[]).
1369 .PP
1370 The following numeric meta fields can be used with comparisons
1371 \f[C]<\f[], \f[C]<=\f[], \f[C]>\f[], \f[C]>=\f[], \f[C]=\f[] (equals),
1372 \f[C]!=\f[] (not equals):
1373 .IP \[bu] 2
1374 \f[C]filesize\f[]: The number of bytes, if known in advance
1375 .IP \[bu] 2
1376 \f[C]width\f[]: Width of the video, if known
1377 .IP \[bu] 2
1378 \f[C]height\f[]: Height of the video, if known
1379 .IP \[bu] 2
1380 \f[C]tbr\f[]: Average bitrate of audio and video in KBit/s
1381 .IP \[bu] 2
1382 \f[C]abr\f[]: Average audio bitrate in KBit/s
1383 .IP \[bu] 2
1384 \f[C]vbr\f[]: Average video bitrate in KBit/s
1385 .IP \[bu] 2
1386 \f[C]asr\f[]: Audio sampling rate in Hertz
1387 .IP \[bu] 2
1388 \f[C]fps\f[]: Frame rate
1389 .PP
1390 Also filtering work for comparisons \f[C]=\f[] (equals), \f[C]^=\f[]
1391 (starts with), \f[C]$=\f[] (ends with), \f[C]*=\f[] (contains) and
1392 following string meta fields:
1393 .IP \[bu] 2
1394 \f[C]ext\f[]: File extension
1395 .IP \[bu] 2
1396 \f[C]acodec\f[]: Name of the audio codec in use
1397 .IP \[bu] 2
1398 \f[C]vcodec\f[]: Name of the video codec in use
1399 .IP \[bu] 2
1400 \f[C]container\f[]: Name of the container format
1401 .IP \[bu] 2
1402 \f[C]protocol\f[]: The protocol that will be used for the actual
1403 download, lower\-case (\f[C]http\f[], \f[C]https\f[], \f[C]rtsp\f[],
1404 \f[C]rtmp\f[], \f[C]rtmpe\f[], \f[C]mms\f[], \f[C]f4m\f[], \f[C]ism\f[],
1405 \f[C]http_dash_segments\f[], \f[C]m3u8\f[], or \f[C]m3u8_native\f[])
1406 .IP \[bu] 2
1407 \f[C]format_id\f[]: A short description of the format
1408 .PP
1409 Any string comparison may be prefixed with negation \f[C]!\f[] in order
1410 to produce an opposite comparison, e.g.
1411 \f[C]!*=\f[] (does not contain).
1412 .PP
1413 Note that none of the aforementioned meta fields are guaranteed to be
1414 present since this solely depends on the metadata obtained by particular
1415 extractor, i.e.
1416 the metadata offered by the video hoster.
1417 .PP
1418 Formats for which the value is not known are excluded unless you put a
1419 question mark (\f[C]?\f[]) after the operator.
1420 You can combine format filters, so
1421 \f[C]\-f\ "[height\ <=?\ 720][tbr>500]"\f[] selects up to 720p videos
1422 (or videos where the height is not known) with a bitrate of at least 500
1423 KBit/s.
1424 .PP
1425 You can merge the video and audio of two formats into a single file
1426 using \f[C]\-f\ <video\-format>+<audio\-format>\f[] (requires ffmpeg or
1427 avconv installed), for example \f[C]\-f\ bestvideo+bestaudio\f[] will
1428 download the best video\-only format, the best audio\-only format and
1429 mux them together with ffmpeg/avconv.
1430 .PP
1431 Format selectors can also be grouped using parentheses, for example if
1432 you want to download the best mp4 and webm formats with a height lower
1433 than 480 you can use \f[C]\-f\ \[aq](mp4,webm)[height<480]\[aq]\f[].
1434 .PP
1435 Since the end of April 2015 and version 2015.04.26, youtube\-dl uses
1436 \f[C]\-f\ bestvideo+bestaudio/best\f[] as the default format selection
1437 (see #5447 (https://github.com/ytdl-org/youtube-dl/issues/5447),
1438 #5456 (https://github.com/ytdl-org/youtube-dl/issues/5456)).
1439 If ffmpeg or avconv are installed this results in downloading
1440 \f[C]bestvideo\f[] and \f[C]bestaudio\f[] separately and muxing them
1441 together into a single file giving the best overall quality available.
1442 Otherwise it falls back to \f[C]best\f[] and results in downloading the
1443 best available quality served as a single file.
1444 \f[C]best\f[] is also needed for videos that don\[aq]t come from YouTube
1445 because they don\[aq]t provide the audio and video in two different
1446 files.
1447 If you want to only download some DASH formats (for example if you are
1448 not interested in getting videos with a resolution higher than 1080p),
1449 you can add \f[C]\-f\ bestvideo[height<=?1080]+bestaudio/best\f[] to
1450 your configuration file.
1451 Note that if you use youtube\-dl to stream to \f[C]stdout\f[] (and most
1452 likely to pipe it to your media player then), i.e.
1453 you explicitly specify output template as \f[C]\-o\ \-\f[], youtube\-dl
1454 still uses \f[C]\-f\ best\f[] format selection in order to start content
1455 delivery immediately to your player and not to wait until
1456 \f[C]bestvideo\f[] and \f[C]bestaudio\f[] are downloaded and muxed.
1457 .PP
1458 If you want to preserve the old format selection behavior (prior to
1459 youtube\-dl 2015.04.26), i.e.
1460 you want to download the best available quality media served as a single
1461 file, you should explicitly specify your choice with \f[C]\-f\ best\f[].
1462 You may want to add it to the configuration file in order not to type it
1463 every time you run youtube\-dl.
1464 .SS Format selection examples
1465 .PP
1466 Note that on Windows you may need to use double quotes instead of
1467 single.
1468 .IP
1469 .nf
1470 \f[C]
1471 #\ Download\ best\ mp4\ format\ available\ or\ any\ other\ best\ if\ no\ mp4\ available
1472 $\ youtube\-dl\ \-f\ \[aq]bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best\[aq]
1473
1474 #\ Download\ best\ format\ available\ but\ no\ better\ than\ 480p
1475 $\ youtube\-dl\ \-f\ \[aq]bestvideo[height<=480]+bestaudio/best[height<=480]\[aq]
1476
1477 #\ Download\ best\ video\ only\ format\ but\ no\ bigger\ than\ 50\ MB
1478 $\ youtube\-dl\ \-f\ \[aq]best[filesize<50M]\[aq]
1479
1480 #\ Download\ best\ format\ available\ via\ direct\ link\ over\ HTTP/HTTPS\ protocol
1481 $\ youtube\-dl\ \-f\ \[aq](bestvideo+bestaudio/best)[protocol^=http]\[aq]
1482
1483 #\ Download\ the\ best\ video\ format\ and\ the\ best\ audio\ format\ without\ merging\ them
1484 $\ youtube\-dl\ \-f\ \[aq]bestvideo,bestaudio\[aq]\ \-o\ \[aq]%(title)s.f%(format_id)s.%(ext)s\[aq]
1485 \f[]
1486 .fi
1487 .PP
1488 Note that in the last example, an output template is recommended as
1489 bestvideo and bestaudio may have the same file name.
1490 .SH VIDEO SELECTION
1491 .PP
1492 Videos can be filtered by their upload date using the options
1493 \f[C]\-\-date\f[], \f[C]\-\-datebefore\f[] or \f[C]\-\-dateafter\f[].
1494 They accept dates in two formats:
1495 .IP \[bu] 2
1496 Absolute dates: Dates in the format \f[C]YYYYMMDD\f[].
1497 .IP \[bu] 2
1498 Relative dates: Dates in the format
1499 \f[C](now|today)[+\-][0\-9](day|week|month|year)(s)?\f[]
1500 .PP
1501 Examples:
1502 .IP
1503 .nf
1504 \f[C]
1505 #\ Download\ only\ the\ videos\ uploaded\ in\ the\ last\ 6\ months
1506 $\ youtube\-dl\ \-\-dateafter\ now\-6months
1507
1508 #\ Download\ only\ the\ videos\ uploaded\ on\ January\ 1,\ 1970
1509 $\ youtube\-dl\ \-\-date\ 19700101
1510
1511 $\ #\ Download\ only\ the\ videos\ uploaded\ in\ the\ 200x\ decade
1512 $\ youtube\-dl\ \-\-dateafter\ 20000101\ \-\-datebefore\ 20091231
1513 \f[]
1514 .fi
1515 .SH FAQ
1516 .SS How do I update youtube\-dl?
1517 .PP
1518 If you\[aq]ve followed our manual installation
1519 instructions (https://ytdl-org.github.io/youtube-dl/download.html), you
1520 can simply run \f[C]youtube\-dl\ \-U\f[] (or, on Linux,
1521 \f[C]sudo\ youtube\-dl\ \-U\f[]).
1522 .PP
1523 If you have used pip, a simple
1524 \f[C]sudo\ pip\ install\ \-U\ youtube\-dl\f[] is sufficient to update.
1525 .PP
1526 If you have installed youtube\-dl using a package manager like
1527 \f[I]apt\-get\f[] or \f[I]yum\f[], use the standard system update
1528 mechanism to update.
1529 Note that distribution packages are often outdated.
1530 As a rule of thumb, youtube\-dl releases at least once a month, and
1531 often weekly or even daily.
1532 Simply go to https://yt\-dl.org to find out the current version.
1533 Unfortunately, there is nothing we youtube\-dl developers can do if your
1534 distribution serves a really outdated version.
1535 You can (and should) complain to your distribution in their bugtracker
1536 or support forum.
1537 .PP
1538 As a last resort, you can also uninstall the version installed by your
1539 package manager and follow our manual installation instructions.
1540 For that, remove the distribution\[aq]s package, with a line like
1541 .IP
1542 .nf
1543 \f[C]
1544 sudo\ apt\-get\ remove\ \-y\ youtube\-dl
1545 \f[]
1546 .fi
1547 .PP
1548 Afterwards, simply follow our manual installation
1549 instructions (https://ytdl-org.github.io/youtube-dl/download.html):
1550 .IP
1551 .nf
1552 \f[C]
1553 sudo\ wget\ https://yt\-dl.org/downloads/latest/youtube\-dl\ \-O\ /usr/local/bin/youtube\-dl
1554 sudo\ chmod\ a+rx\ /usr/local/bin/youtube\-dl
1555 hash\ \-r
1556 \f[]
1557 .fi
1558 .PP
1559 Again, from then on you\[aq]ll be able to update with
1560 \f[C]sudo\ youtube\-dl\ \-U\f[].
1561 .SS youtube\-dl is extremely slow to start on Windows
1562 .PP
1563 Add a file exclusion for \f[C]youtube\-dl.exe\f[] in Windows Defender
1564 settings.
1565 .SS I\[aq]m getting an error
1566 \f[C]Unable\ to\ extract\ OpenGraph\ title\f[] on YouTube playlists
1567 .PP
1568 YouTube changed their playlist format in March 2014 and later on, so
1569 you\[aq]ll need at least youtube\-dl 2014.07.25 to download all YouTube
1570 videos.
1571 .PP
1572 If you have installed youtube\-dl with a package manager, pip, setup.py
1573 or a tarball, please use that to update.
1574 Note that Ubuntu packages do not seem to get updated anymore.
1575 Since we are not affiliated with Ubuntu, there is little we can do.
1576 Feel free to report
1577 bugs (https://bugs.launchpad.net/ubuntu/+source/youtube-dl/+filebug) to
1578 the Ubuntu packaging
1579 people (mailto:ubuntu-motu@lists.ubuntu.com?subject=outdated%20version%20of%20youtube-dl)
1580 \- all they have to do is update the package to a somewhat recent
1581 version.
1582 See above for a way to update.
1583 .SS I\[aq]m getting an error when trying to use output template:
1584 \f[C]error:\ using\ output\ template\ conflicts\ with\ using\ title,\ video\ ID\ or\ auto\ number\f[]
1585 .PP
1586 Make sure you are not using \f[C]\-o\f[] with any of these options
1587 \f[C]\-t\f[], \f[C]\-\-title\f[], \f[C]\-\-id\f[], \f[C]\-A\f[] or
1588 \f[C]\-\-auto\-number\f[] set in command line or in a configuration
1589 file.
1590 Remove the latter if any.
1591 .SS Do I always have to pass \f[C]\-citw\f[]?
1592 .PP
1593 By default, youtube\-dl intends to have the best options (incidentally,
1594 if you have a convincing case that these should be different, please
1595 file an issue where you explain that (https://yt-dl.org/bug)).
1596 Therefore, it is unnecessary and sometimes harmful to copy long option
1597 strings from webpages.
1598 In particular, the only option out of \f[C]\-citw\f[] that is regularly
1599 useful is \f[C]\-i\f[].
1600 .SS Can you please put the \f[C]\-b\f[] option back?
1601 .PP
1602 Most people asking this question are not aware that youtube\-dl now
1603 defaults to downloading the highest available quality as reported by
1604 YouTube, which will be 1080p or 720p in some cases, so you no longer
1605 need the \f[C]\-b\f[] option.
1606 For some specific videos, maybe YouTube does not report them to be
1607 available in a specific high quality format you\[aq]re interested in.
1608 In that case, simply request it with the \f[C]\-f\f[] option and
1609 youtube\-dl will try to download it.
1610 .SS I get HTTP error 402 when trying to download a video. What\[aq]s
1611 this?
1612 .PP
1613 Apparently YouTube requires you to pass a CAPTCHA test if you download
1614 too much.
1615 We\[aq]re considering to provide a way to let you solve the
1616 CAPTCHA (https://github.com/ytdl-org/youtube-dl/issues/154), but at the
1617 moment, your best course of action is pointing a web browser to the
1618 youtube URL, solving the CAPTCHA, and restart youtube\-dl.
1619 .SS Do I need any other programs?
1620 .PP
1621 youtube\-dl works fine on its own on most sites.
1622 However, if you want to convert video/audio, you\[aq]ll need
1623 avconv (https://libav.org/) or ffmpeg (https://www.ffmpeg.org/).
1624 On some sites \- most notably YouTube \- videos can be retrieved in a
1625 higher quality format without sound.
1626 youtube\-dl will detect whether avconv/ffmpeg is present and
1627 automatically pick the best option.
1628 .PP
1629 Videos or video formats streamed via RTMP protocol can only be
1630 downloaded when rtmpdump (https://rtmpdump.mplayerhq.hu/) is installed.
1631 Downloading MMS and RTSP videos requires either
1632 mplayer (https://mplayerhq.hu/) or mpv (https://mpv.io/) to be
1633 installed.
1634 .SS I have downloaded a video but how can I play it?
1635 .PP
1636 Once the video is fully downloaded, use any video player, such as
1637 mpv (https://mpv.io/), vlc (https://www.videolan.org/) or
1638 mplayer (https://www.mplayerhq.hu/).
1639 .SS I extracted a video URL with \f[C]\-g\f[], but it does not play on
1640 another machine / in my web browser.
1641 .PP
1642 It depends a lot on the service.
1643 In many cases, requests for the video (to download/play it) must come
1644 from the same IP address and with the same cookies and/or HTTP headers.
1645 Use the \f[C]\-\-cookies\f[] option to write the required cookies into a
1646 file, and advise your downloader to read cookies from that file.
1647 Some sites also require a common user agent to be used, use
1648 \f[C]\-\-dump\-user\-agent\f[] to see the one in use by youtube\-dl.
1649 You can also get necessary cookies and HTTP headers from JSON output
1650 obtained with \f[C]\-\-dump\-json\f[].
1651 .PP
1652 It may be beneficial to use IPv6; in some cases, the restrictions are
1653 only applied to IPv4.
1654 Some services (sometimes only for a subset of videos) do not restrict
1655 the video URL by IP address, cookie, or user\-agent, but these are the
1656 exception rather than the rule.
1657 .PP
1658 Please bear in mind that some URL protocols are \f[B]not\f[] supported
1659 by browsers out of the box, including RTMP.
1660 If you are using \f[C]\-g\f[], your own downloader must support these as
1661 well.
1662 .PP
1663 If you want to play the video on a machine that is not running
1664 youtube\-dl, you can relay the video content from the machine that runs
1665 youtube\-dl.
1666 You can use \f[C]\-o\ \-\f[] to let youtube\-dl stream a video to
1667 stdout, or simply allow the player to download the files written by
1668 youtube\-dl in turn.
1669 .SS ERROR: no fmt_url_map or conn information found in video info
1670 .PP
1671 YouTube has switched to a new video info format in July 2011 which is
1672 not supported by old versions of youtube\-dl.
1673 See above for how to update youtube\-dl.
1674 .SS ERROR: unable to download video
1675 .PP
1676 YouTube requires an additional signature since September 2012 which is
1677 not supported by old versions of youtube\-dl.
1678 See above for how to update youtube\-dl.
1679 .SS Video URL contains an ampersand and I\[aq]m getting some strange
1680 output \f[C][1]\ 2839\f[] or
1681 \f[C]\[aq]v\[aq]\ is\ not\ recognized\ as\ an\ internal\ or\ external\ command\f[]
1682 .PP
1683 That\[aq]s actually the output from your shell.
1684 Since ampersand is one of the special shell characters it\[aq]s
1685 interpreted by the shell preventing you from passing the whole URL to
1686 youtube\-dl.
1687 To disable your shell from interpreting the ampersands (or any other
1688 special characters) you have to either put the whole URL in quotes or
1689 escape them with a backslash (which approach will work depends on your
1690 shell).
1691 .PP
1692 For example if your URL is
1693 https://www.youtube.com/watch?t=4&v=BaW_jenozKc you should end up with
1694 following command:
1695 .PP
1696 \f[C]youtube\-dl\ \[aq]https://www.youtube.com/watch?t=4&v=BaW_jenozKc\[aq]\f[]
1697 .PP
1698 or
1699 .PP
1700 \f[C]youtube\-dl\ https://www.youtube.com/watch?t=4\\&v=BaW_jenozKc\f[]
1701 .PP
1702 For Windows you have to use the double quotes:
1703 .PP
1704 \f[C]youtube\-dl\ "https://www.youtube.com/watch?t=4&v=BaW_jenozKc"\f[]
1705 .SS ExtractorError: Could not find JS function u\[aq]OF\[aq]
1706 .PP
1707 In February 2015, the new YouTube player contained a character sequence
1708 in a string that was misinterpreted by old versions of youtube\-dl.
1709 See above for how to update youtube\-dl.
1710 .SS HTTP Error 429: Too Many Requests or 402: Payment Required
1711 .PP
1712 These two error codes indicate that the service is blocking your IP
1713 address because of overuse.
1714 Usually this is a soft block meaning that you can gain access again
1715 after solving CAPTCHA.
1716 Just open a browser and solve a CAPTCHA the service suggests you and
1717 after that pass cookies to youtube\-dl.
1718 Note that if your machine has multiple external IPs then you should also
1719 pass exactly the same IP you\[aq]ve used for solving CAPTCHA with
1720 \f[C]\-\-source\-address\f[].
1721 Also you may need to pass a \f[C]User\-Agent\f[] HTTP header of your
1722 browser with \f[C]\-\-user\-agent\f[].
1723 .PP
1724 If this is not the case (no CAPTCHA suggested to solve by the service)
1725 then you can contact the service and ask them to unblock your IP
1726 address, or \- if you have acquired a whitelisted IP address already \-
1727 use the \f[C]\-\-proxy\f[] or \f[C]\-\-source\-address\f[] options to
1728 select another IP address.
1729 .SS SyntaxError: Non\-ASCII character
1730 .PP
1731 The error
1732 .IP
1733 .nf
1734 \f[C]
1735 File\ "youtube\-dl",\ line\ 2
1736 SyntaxError:\ Non\-ASCII\ character\ \[aq]\\x93\[aq]\ ...
1737 \f[]
1738 .fi
1739 .PP
1740 means you\[aq]re using an outdated version of Python.
1741 Please update to Python 2.6 or 2.7.
1742 .SS What is this binary file? Where has the code gone?
1743 .PP
1744 Since June 2012
1745 (#342 (https://github.com/ytdl-org/youtube-dl/issues/342)) youtube\-dl
1746 is packed as an executable zipfile, simply unzip it (might need renaming
1747 to \f[C]youtube\-dl.zip\f[] first on some systems) or clone the git
1748 repository, as laid out above.
1749 If you modify the code, you can run it by executing the
1750 \f[C]__main__.py\f[] file.
1751 To recompile the executable, run \f[C]make\ youtube\-dl\f[].
1752 .SS The exe throws an error due to missing \f[C]MSVCR100.dll\f[]
1753 .PP
1754 To run the exe you need to install first the Microsoft Visual C++ 2010
1755 Redistributable Package
1756 (x86) (https://www.microsoft.com/en-US/download/details.aspx?id=5555).
1757 .SS On Windows, how should I set up ffmpeg and youtube\-dl? Where should
1758 I put the exe files?
1759 .PP
1760 If you put youtube\-dl and ffmpeg in the same directory that you\[aq]re
1761 running the command from, it will work, but that\[aq]s rather
1762 cumbersome.
1763 .PP
1764 To make a different directory work \- either for ffmpeg, or for
1765 youtube\-dl, or for both \- simply create the directory (say,
1766 \f[C]C:\\bin\f[], or \f[C]C:\\Users\\<User\ name>\\bin\f[]), put all the
1767 executables directly in there, and then set your PATH environment
1768 variable (https://www.java.com/en/download/help/path.xml) to include
1769 that directory.
1770 .PP
1771 From then on, after restarting your shell, you will be able to access
1772 both youtube\-dl and ffmpeg (and youtube\-dl will be able to find
1773 ffmpeg) by simply typing \f[C]youtube\-dl\f[] or \f[C]ffmpeg\f[], no
1774 matter what directory you\[aq]re in.
1775 .SS How do I put downloads into a specific folder?
1776 .PP
1777 Use the \f[C]\-o\f[] to specify an output template, for example
1778 \f[C]\-o\ "/home/user/videos/%(title)s\-%(id)s.%(ext)s"\f[].
1779 If you want this for all of your downloads, put the option into your
1780 configuration file.
1781 .SS How do I download a video starting with a \f[C]\-\f[]?
1782 .PP
1783 Either prepend \f[C]https://www.youtube.com/watch?v=\f[] or separate the
1784 ID from the options with \f[C]\-\-\f[]:
1785 .IP
1786 .nf
1787 \f[C]
1788 youtube\-dl\ \-\-\ \-wNyEUrxzFU
1789 youtube\-dl\ "https://www.youtube.com/watch?v=\-wNyEUrxzFU"
1790 \f[]
1791 .fi
1792 .SS How do I pass cookies to youtube\-dl?
1793 .PP
1794 Use the \f[C]\-\-cookies\f[] option, for example
1795 \f[C]\-\-cookies\ /path/to/cookies/file.txt\f[].
1796 .PP
1797 In order to extract cookies from browser use any conforming browser
1798 extension for exporting cookies.
1799 For example,
1800 cookies.txt (https://chrome.google.com/webstore/detail/cookiestxt/njabckikapfpffapmjgojcnbfjonfjfg)
1801 (for Chrome) or
1802 cookies.txt (https://addons.mozilla.org/en-US/firefox/addon/cookies-txt/)
1803 (for Firefox).
1804 .PP
1805 Note that the cookies file must be in Mozilla/Netscape format and the
1806 first line of the cookies file must be either
1807 \f[C]#\ HTTP\ Cookie\ File\f[] or
1808 \f[C]#\ Netscape\ HTTP\ Cookie\ File\f[].
1809 Make sure you have correct newline
1810 format (https://en.wikipedia.org/wiki/Newline) in the cookies file and
1811 convert newlines if necessary to correspond with your OS, namely
1812 \f[C]CRLF\f[] (\f[C]\\r\\n\f[]) for Windows and \f[C]LF\f[]
1813 (\f[C]\\n\f[]) for Unix and Unix\-like systems (Linux, macOS, etc.).
1814 \f[C]HTTP\ Error\ 400:\ Bad\ Request\f[] when using \f[C]\-\-cookies\f[]
1815 is a good sign of invalid newline format.
1816 .PP
1817 Passing cookies to youtube\-dl is a good way to workaround login when a
1818 particular extractor does not implement it explicitly.
1819 Another use case is working around
1820 CAPTCHA (https://en.wikipedia.org/wiki/CAPTCHA) some websites require
1821 you to solve in particular cases in order to get access (e.g.
1822 YouTube, CloudFlare).
1823 .SS How do I stream directly to media player?
1824 .PP
1825 You will first need to tell youtube\-dl to stream media to stdout with
1826 \f[C]\-o\ \-\f[], and also tell your media player to read from stdin (it
1827 must be capable of this for streaming) and then pipe former to latter.
1828 For example, streaming to vlc (https://www.videolan.org/) can be
1829 achieved with:
1830 .IP
1831 .nf
1832 \f[C]
1833 youtube\-dl\ \-o\ \-\ "https://www.youtube.com/watch?v=BaW_jenozKcj"\ |\ vlc\ \-
1834 \f[]
1835 .fi
1836 .SS How do I download only new videos from a playlist?
1837 .PP
1838 Use download\-archive feature.
1839 With this feature you should initially download the complete playlist
1840 with \f[C]\-\-download\-archive\ /path/to/download/archive/file.txt\f[]
1841 that will record identifiers of all the videos in a special file.
1842 Each subsequent run with the same \f[C]\-\-download\-archive\f[] will
1843 download only new videos and skip all videos that have been downloaded
1844 before.
1845 Note that only successful downloads are recorded in the file.
1846 .PP
1847 For example, at first,
1848 .IP
1849 .nf
1850 \f[C]
1851 youtube\-dl\ \-\-download\-archive\ archive.txt\ "https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re"
1852 \f[]
1853 .fi
1854 .PP
1855 will download the complete \f[C]PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re\f[]
1856 playlist and create a file \f[C]archive.txt\f[].
1857 Each subsequent run will only download new videos if any:
1858 .IP
1859 .nf
1860 \f[C]
1861 youtube\-dl\ \-\-download\-archive\ archive.txt\ "https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re"
1862 \f[]
1863 .fi
1864 .SS Should I add \f[C]\-\-hls\-prefer\-native\f[] into my config?
1865 .PP
1866 When youtube\-dl detects an HLS video, it can download it either with
1867 the built\-in downloader or ffmpeg.
1868 Since many HLS streams are slightly invalid and ffmpeg/youtube\-dl each
1869 handle some invalid cases better than the other, there is an option to
1870 switch the downloader if needed.
1871 .PP
1872 When youtube\-dl knows that one particular downloader works better for a
1873 given website, that downloader will be picked.
1874 Otherwise, youtube\-dl will pick the best downloader for general
1875 compatibility, which at the moment happens to be ffmpeg.
1876 This choice may change in future versions of youtube\-dl, with
1877 improvements of the built\-in downloader and/or ffmpeg.
1878 .PP
1879 In particular, the generic extractor (used when your website is not in
1880 the list of supported sites by
1881 youtube\-dl (https://ytdl-org.github.io/youtube-dl/supportedsites.html)
1882 cannot mandate one specific downloader.
1883 .PP
1884 If you put either \f[C]\-\-hls\-prefer\-native\f[] or
1885 \f[C]\-\-hls\-prefer\-ffmpeg\f[] into your configuration, a different
1886 subset of videos will fail to download correctly.
1887 Instead, it is much better to file an issue (https://yt-dl.org/bug) or a
1888 pull request which details why the native or the ffmpeg HLS downloader
1889 is a better choice for your use case.
1890 .SS Can you add support for this anime video site, or site which shows
1891 current movies for free?
1892 .PP
1893 As a matter of policy (as well as legality), youtube\-dl does not
1894 include support for services that specialize in infringing copyright.
1895 As a rule of thumb, if you cannot easily find a video that the service
1896 is quite obviously allowed to distribute (i.e.
1897 that has been uploaded by the creator, the creator\[aq]s distributor, or
1898 is published under a free license), the service is probably unfit for
1899 inclusion to youtube\-dl.
1900 .PP
1901 A note on the service that they don\[aq]t host the infringing content,
1902 but just link to those who do, is evidence that the service should
1903 \f[B]not\f[] be included into youtube\-dl.
1904 The same goes for any DMCA note when the whole front page of the service
1905 is filled with videos they are not allowed to distribute.
1906 A "fair use" note is equally unconvincing if the service shows
1907 copyright\-protected videos in full without authorization.
1908 .PP
1909 Support requests for services that \f[B]do\f[] purchase the rights to
1910 distribute their content are perfectly fine though.
1911 If in doubt, you can simply include a source that mentions the
1912 legitimate purchase of content.
1913 .SS How can I speed up work on my issue?
1914 .PP
1915 (Also known as: Help, my important issue not being solved!) The
1916 youtube\-dl core developer team is quite small.
1917 While we do our best to solve as many issues as possible, sometimes that
1918 can take quite a while.
1919 To speed up your issue, here\[aq]s what you can do:
1920 .PP
1921 First of all, please do report the issue at our issue
1922 tracker (https://yt-dl.org/bugs).
1923 That allows us to coordinate all efforts by users and developers, and
1924 serves as a unified point.
1925 Unfortunately, the youtube\-dl project has grown too large to use
1926 personal email as an effective communication channel.
1927 .PP
1928 Please read the bug reporting instructions below.
1929 A lot of bugs lack all the necessary information.
1930 If you can, offer proxy, VPN, or shell access to the youtube\-dl
1931 developers.
1932 If you are able to, test the issue from multiple computers in multiple
1933 countries to exclude local censorship or misconfiguration issues.
1934 .PP
1935 If nobody is interested in solving your issue, you are welcome to take
1936 matters into your own hands and submit a pull request (or coerce/pay
1937 somebody else to do so).
1938 .PP
1939 Feel free to bump the issue from time to time by writing a small comment
1940 ("Issue is still present in youtube\-dl version ...from France, but
1941 fixed from Belgium"), but please not more than once a month.
1942 Please do not declare your issue as \f[C]important\f[] or
1943 \f[C]urgent\f[].
1944 .SS How can I detect whether a given URL is supported by youtube\-dl?
1945 .PP
1946 For one, have a look at the list of supported
1947 sites (docs/supportedsites.md).
1948 Note that it can sometimes happen that the site changes its URL scheme
1949 (say, from https://example.com/video/1234567 to
1950 https://example.com/v/1234567 ) and youtube\-dl reports an URL of a
1951 service in that list as unsupported.
1952 In that case, simply report a bug.
1953 .PP
1954 It is \f[I]not\f[] possible to detect whether a URL is supported or not.
1955 That\[aq]s because youtube\-dl contains a generic extractor which
1956 matches \f[B]all\f[] URLs.
1957 You may be tempted to disable, exclude, or remove the generic extractor,
1958 but the generic extractor not only allows users to extract videos from
1959 lots of websites that embed a video from another service, but may also
1960 be used to extract video from a service that it\[aq]s hosting itself.
1961 Therefore, we neither recommend nor support disabling, excluding, or
1962 removing the generic extractor.
1963 .PP
1964 If you want to find out whether a given URL is supported, simply call
1965 youtube\-dl with it.
1966 If you get no videos back, chances are the URL is either not referring
1967 to a video or unsupported.
1968 You can find out which by examining the output (if you run youtube\-dl
1969 on the console) or catching an \f[C]UnsupportedError\f[] exception if
1970 you run it from a Python program.
1971 .SH Why do I need to go through that much red tape when filing bugs?
1972 .PP
1973 Before we had the issue template, despite our extensive bug reporting
1974 instructions, about 80% of the issue reports we got were useless, for
1975 instance because people used ancient versions hundreds of releases old,
1976 because of simple syntactic errors (not in youtube\-dl but in general
1977 shell usage), because the problem was already reported multiple times
1978 before, because people did not actually read an error message, even if
1979 it said "please install ffmpeg", because people did not mention the URL
1980 they were trying to download and many more simple, easy\-to\-avoid
1981 problems, many of whom were totally unrelated to youtube\-dl.
1982 .PP
1983 youtube\-dl is an open\-source project manned by too few volunteers, so
1984 we\[aq]d rather spend time fixing bugs where we are certain none of
1985 those simple problems apply, and where we can be reasonably confident to
1986 be able to reproduce the issue without asking the reporter repeatedly.
1987 As such, the output of \f[C]youtube\-dl\ \-v\ YOUR_URL_HERE\f[] is
1988 really all that\[aq]s required to file an issue.
1989 The issue template also guides you through some basic steps you can do,
1990 such as checking that your version of youtube\-dl is current.
1991 .SH DEVELOPER INSTRUCTIONS
1992 .PP
1993 Most users do not need to build youtube\-dl and can download the
1994 builds (https://ytdl-org.github.io/youtube-dl/download.html) or get them
1995 from their distribution.
1996 .PP
1997 To run youtube\-dl as a developer, you don\[aq]t need to build anything
1998 either.
1999 Simply execute
2000 .IP
2001 .nf
2002 \f[C]
2003 python\ \-m\ youtube_dl
2004 \f[]
2005 .fi
2006 .PP
2007 To run the test, simply invoke your favorite test runner, or execute a
2008 test file directly; any of the following work:
2009 .IP
2010 .nf
2011 \f[C]
2012 python\ \-m\ unittest\ discover
2013 python\ test/test_download.py
2014 nosetests
2015 \f[]
2016 .fi
2017 .PP
2018 See item 6 of new extractor tutorial for how to run extractor specific
2019 test cases.
2020 .PP
2021 If you want to create a build of youtube\-dl yourself, you\[aq]ll need
2022 .IP \[bu] 2
2023 python
2024 .IP \[bu] 2
2025 make (only GNU make is supported)
2026 .IP \[bu] 2
2027 pandoc
2028 .IP \[bu] 2
2029 zip
2030 .IP \[bu] 2
2031 nosetests
2032 .SS Adding support for a new site
2033 .PP
2034 If you want to add support for a new site, first of all \f[B]make
2035 sure\f[] this site is \f[B]not dedicated to copyright
2036 infringement (README.md#can-you-add-support-for-this-anime-video-site-or-site-which-shows-current-movies-for-free)\f[].
2037 youtube\-dl does \f[B]not support\f[] such sites thus pull requests
2038 adding support for them \f[B]will be rejected\f[].
2039 .PP
2040 After you have ensured this site is distributing its content legally,
2041 you can follow this quick list (assuming your service is called
2042 \f[C]yourextractor\f[]):
2043 .IP " 1." 4
2044 Fork this repository (https://github.com/ytdl-org/youtube-dl/fork)
2045 .IP " 2." 4
2046 Check out the source code with:
2047 .RS 4
2048 .IP
2049 .nf
2050 \f[C]
2051 \ git\ clone\ git\@github.com:YOUR_GITHUB_USERNAME/youtube\-dl.git
2052 \f[]
2053 .fi
2054 .RE
2055 .IP " 3." 4
2056 Start a new git branch with
2057 .RS 4
2058 .IP
2059 .nf
2060 \f[C]
2061 \ cd\ youtube\-dl
2062 \ git\ checkout\ \-b\ yourextractor
2063 \f[]
2064 .fi
2065 .RE
2066 .IP " 4." 4
2067 Start with this simple template and save it to
2068 \f[C]youtube_dl/extractor/yourextractor.py\f[]:
2069 .RS 4
2070 .IP
2071 .nf
2072 \f[C]
2073 #\ coding:\ utf\-8
2074 from\ __future__\ import\ unicode_literals
2075
2076 from\ .common\ import\ InfoExtractor
2077
2078
2079 class\ YourExtractorIE(InfoExtractor):
2080 \ \ \ \ _VALID_URL\ =\ r\[aq]https?://(?:www\\.)?yourextractor\\.com/watch/(?P<id>[0\-9]+)\[aq]
2081 \ \ \ \ _TEST\ =\ {
2082 \ \ \ \ \ \ \ \ \[aq]url\[aq]:\ \[aq]https://yourextractor.com/watch/42\[aq],
2083 \ \ \ \ \ \ \ \ \[aq]md5\[aq]:\ \[aq]TODO:\ md5\ sum\ of\ the\ first\ 10241\ bytes\ of\ the\ video\ file\ (use\ \-\-test)\[aq],
2084 \ \ \ \ \ \ \ \ \[aq]info_dict\[aq]:\ {
2085 \ \ \ \ \ \ \ \ \ \ \ \ \[aq]id\[aq]:\ \[aq]42\[aq],
2086 \ \ \ \ \ \ \ \ \ \ \ \ \[aq]ext\[aq]:\ \[aq]mp4\[aq],
2087 \ \ \ \ \ \ \ \ \ \ \ \ \[aq]title\[aq]:\ \[aq]Video\ title\ goes\ here\[aq],
2088 \ \ \ \ \ \ \ \ \ \ \ \ \[aq]thumbnail\[aq]:\ r\[aq]re:^https?://.*\\.jpg$\[aq],
2089 \ \ \ \ \ \ \ \ \ \ \ \ #\ TODO\ more\ properties,\ either\ as:
2090 \ \ \ \ \ \ \ \ \ \ \ \ #\ *\ A\ value
2091 \ \ \ \ \ \ \ \ \ \ \ \ #\ *\ MD5\ checksum;\ start\ the\ string\ with\ md5:
2092 \ \ \ \ \ \ \ \ \ \ \ \ #\ *\ A\ regular\ expression;\ start\ the\ string\ with\ re:
2093 \ \ \ \ \ \ \ \ \ \ \ \ #\ *\ Any\ Python\ type\ (for\ example\ int\ or\ float)
2094 \ \ \ \ \ \ \ \ }
2095 \ \ \ \ }
2096
2097 \ \ \ \ def\ _real_extract(self,\ url):
2098 \ \ \ \ \ \ \ \ video_id\ =\ self._match_id(url)
2099 \ \ \ \ \ \ \ \ webpage\ =\ self._download_webpage(url,\ video_id)
2100
2101 \ \ \ \ \ \ \ \ #\ TODO\ more\ code\ goes\ here,\ for\ example\ ...
2102 \ \ \ \ \ \ \ \ title\ =\ self._html_search_regex(r\[aq]<h1>(.+?)</h1>\[aq],\ webpage,\ \[aq]title\[aq])
2103
2104 \ \ \ \ \ \ \ \ return\ {
2105 \ \ \ \ \ \ \ \ \ \ \ \ \[aq]id\[aq]:\ video_id,
2106 \ \ \ \ \ \ \ \ \ \ \ \ \[aq]title\[aq]:\ title,
2107 \ \ \ \ \ \ \ \ \ \ \ \ \[aq]description\[aq]:\ self._og_search_description(webpage),
2108 \ \ \ \ \ \ \ \ \ \ \ \ \[aq]uploader\[aq]:\ self._search_regex(r\[aq]<div[^>]+id="uploader"[^>]*>([^<]+)<\[aq],\ webpage,\ \[aq]uploader\[aq],\ fatal=False),
2109 \ \ \ \ \ \ \ \ \ \ \ \ #\ TODO\ more\ properties\ (see\ youtube_dl/extractor/common.py)
2110 \ \ \ \ \ \ \ \ }
2111 \f[]
2112 .fi
2113 .RE
2114 .IP " 5." 4
2115 Add an import in
2116 \f[C]youtube_dl/extractor/extractors.py\f[] (https://github.com/ytdl-org/youtube-dl/blob/master/youtube_dl/extractor/extractors.py).
2117 .IP " 6." 4
2118 Run
2119 \f[C]python\ test/test_download.py\ TestDownload.test_YourExtractor\f[].
2120 This \f[I]should fail\f[] at first, but you can continually re\-run it
2121 until you\[aq]re done.
2122 If you decide to add more than one test, then rename \f[C]_TEST\f[] to
2123 \f[C]_TESTS\f[] and make it into a list of dictionaries.
2124 The tests will then be named \f[C]TestDownload.test_YourExtractor\f[],
2125 \f[C]TestDownload.test_YourExtractor_1\f[],
2126 \f[C]TestDownload.test_YourExtractor_2\f[], etc.
2127 Note that tests with \f[C]only_matching\f[] key in test\[aq]s dict are
2128 not counted in.
2129 .IP " 7." 4
2130 Have a look at
2131 \f[C]youtube_dl/extractor/common.py\f[] (https://github.com/ytdl-org/youtube-dl/blob/master/youtube_dl/extractor/common.py)
2132 for possible helper methods and a detailed description of what your
2133 extractor should and may
2134 return (https://github.com/ytdl-org/youtube-dl/blob/7f41a598b3fba1bcab2817de64a08941200aa3c8/youtube_dl/extractor/common.py#L94-L303).
2135 Add tests and code for as many as you want.
2136 .IP " 8." 4
2137 Make sure your code follows youtube\-dl coding conventions and check the
2138 code with
2139 flake8 (https://flake8.pycqa.org/en/latest/index.html#quickstart):
2140 .RS 4
2141 .IP
2142 .nf
2143 \f[C]
2144 \ $\ flake8\ youtube_dl/extractor/yourextractor.py
2145 \f[]
2146 .fi
2147 .RE
2148 .IP " 9." 4
2149 Make sure your code works under all Python (https://www.python.org/)
2150 versions claimed supported by youtube\-dl, namely 2.6, 2.7, and 3.2+.
2151 .IP "10." 4
2152 When the tests pass, add (https://git-scm.com/docs/git-add) the new
2153 files and commit (https://git-scm.com/docs/git-commit) them and
2154 push (https://git-scm.com/docs/git-push) the result, like this:
2155 .RS 4
2156 .IP
2157 .nf
2158 \f[C]
2159 $\ git\ add\ youtube_dl/extractor/extractors.py
2160 $\ git\ add\ youtube_dl/extractor/yourextractor.py
2161 $\ git\ commit\ \-m\ \[aq][yourextractor]\ Add\ new\ extractor\[aq]
2162 $\ git\ push\ origin\ yourextractor
2163 \f[]
2164 .fi
2165 .RE
2166 .IP "11." 4
2167 Finally, create a pull
2168 request (https://help.github.com/articles/creating-a-pull-request).
2169 We\[aq]ll then review and merge it.
2170 .PP
2171 In any case, thank you very much for your contributions!
2172 .SS youtube\-dl coding conventions
2173 .PP
2174 This section introduces a guide lines for writing idiomatic, robust and
2175 future\-proof extractor code.
2176 .PP
2177 Extractors are very fragile by nature since they depend on the layout of
2178 the source data provided by 3rd party media hosters out of your control
2179 and this layout tends to change.
2180 As an extractor implementer your task is not only to write code that
2181 will extract media links and metadata correctly but also to minimize
2182 dependency on the source\[aq]s layout and even to make the code foresee
2183 potential future changes and be ready for that.
2184 This is important because it will allow the extractor not to break on
2185 minor layout changes thus keeping old youtube\-dl versions working.
2186 Even though this breakage issue is easily fixed by emitting a new
2187 version of youtube\-dl with a fix incorporated, all the previous
2188 versions become broken in all repositories and distros\[aq] packages
2189 that may not be so prompt in fetching the update from us.
2190 Needless to say, some non rolling release distros may never receive an
2191 update at all.
2192 .SS Mandatory and optional metafields
2193 .PP
2194 For extraction to work youtube\-dl relies on metadata your extractor
2195 extracts and provides to youtube\-dl expressed by an information
2196 dictionary (https://github.com/ytdl-org/youtube-dl/blob/7f41a598b3fba1bcab2817de64a08941200aa3c8/youtube_dl/extractor/common.py#L94-L303)
2197 or simply \f[I]info dict\f[].
2198 Only the following meta fields in the \f[I]info dict\f[] are considered
2199 mandatory for a successful extraction process by youtube\-dl:
2200 .IP \[bu] 2
2201 \f[C]id\f[] (media identifier)
2202 .IP \[bu] 2
2203 \f[C]title\f[] (media title)
2204 .IP \[bu] 2
2205 \f[C]url\f[] (media download URL) or \f[C]formats\f[]
2206 .PP
2207 In fact only the last option is technically mandatory (i.e.
2208 if you can\[aq]t figure out the download location of the media the
2209 extraction does not make any sense).
2210 But by convention youtube\-dl also treats \f[C]id\f[] and \f[C]title\f[]
2211 as mandatory.
2212 Thus the aforementioned metafields are the critical data that the
2213 extraction does not make any sense without and if any of them fail to be
2214 extracted then the extractor is considered completely broken.
2215 .PP
2216 Any
2217 field (https://github.com/ytdl-org/youtube-dl/blob/7f41a598b3fba1bcab2817de64a08941200aa3c8/youtube_dl/extractor/common.py#L188-L303)
2218 apart from the aforementioned ones are considered \f[B]optional\f[].
2219 That means that extraction should be \f[B]tolerant\f[] to situations
2220 when sources for these fields can potentially be unavailable (even if
2221 they are always available at the moment) and \f[B]future\-proof\f[] in
2222 order not to break the extraction of general purpose mandatory fields.
2223 .SS Example
2224 .PP
2225 Say you have some source dictionary \f[C]meta\f[] that you\[aq]ve
2226 fetched as JSON with HTTP request and it has a key \f[C]summary\f[]:
2227 .IP
2228 .nf
2229 \f[C]
2230 meta\ =\ self._download_json(url,\ video_id)
2231 \f[]
2232 .fi
2233 .PP
2234 Assume at this point \f[C]meta\f[]\[aq]s layout is:
2235 .IP
2236 .nf
2237 \f[C]
2238 {
2239 \ \ \ \ ...
2240 \ \ \ \ "summary":\ "some\ fancy\ summary\ text",
2241 \ \ \ \ ...
2242 }
2243 \f[]
2244 .fi
2245 .PP
2246 Assume you want to extract \f[C]summary\f[] and put it into the
2247 resulting info dict as \f[C]description\f[].
2248 Since \f[C]description\f[] is an optional meta field you should be ready
2249 that this key may be missing from the \f[C]meta\f[] dict, so that you
2250 should extract it like:
2251 .IP
2252 .nf
2253 \f[C]
2254 description\ =\ meta.get(\[aq]summary\[aq])\ \ #\ correct
2255 \f[]
2256 .fi
2257 .PP
2258 and not like:
2259 .IP
2260 .nf
2261 \f[C]
2262 description\ =\ meta[\[aq]summary\[aq]]\ \ #\ incorrect
2263 \f[]
2264 .fi
2265 .PP
2266 The latter will break extraction process with \f[C]KeyError\f[] if
2267 \f[C]summary\f[] disappears from \f[C]meta\f[] at some later time but
2268 with the former approach extraction will just go ahead with
2269 \f[C]description\f[] set to \f[C]None\f[] which is perfectly fine
2270 (remember \f[C]None\f[] is equivalent to the absence of data).
2271 .PP
2272 Similarly, you should pass \f[C]fatal=False\f[] when extracting optional
2273 data from a webpage with \f[C]_search_regex\f[],
2274 \f[C]_html_search_regex\f[] or similar methods, for instance:
2275 .IP
2276 .nf
2277 \f[C]
2278 description\ =\ self._search_regex(
2279 \ \ \ \ r\[aq]<span[^>]+id="title"[^>]*>([^<]+)<\[aq],
2280 \ \ \ \ webpage,\ \[aq]description\[aq],\ fatal=False)
2281 \f[]
2282 .fi
2283 .PP
2284 With \f[C]fatal\f[] set to \f[C]False\f[] if \f[C]_search_regex\f[]
2285 fails to extract \f[C]description\f[] it will emit a warning and
2286 continue extraction.
2287 .PP
2288 You can also pass \f[C]default=<some\ fallback\ value>\f[], for example:
2289 .IP
2290 .nf
2291 \f[C]
2292 description\ =\ self._search_regex(
2293 \ \ \ \ r\[aq]<span[^>]+id="title"[^>]*>([^<]+)<\[aq],
2294 \ \ \ \ webpage,\ \[aq]description\[aq],\ default=None)
2295 \f[]
2296 .fi
2297 .PP
2298 On failure this code will silently continue the extraction with
2299 \f[C]description\f[] set to \f[C]None\f[].
2300 That is useful for metafields that may or may not be present.
2301 .SS Provide fallbacks
2302 .PP
2303 When extracting metadata try to do so from multiple sources.
2304 For example if \f[C]title\f[] is present in several places, try
2305 extracting from at least some of them.
2306 This makes it more future\-proof in case some of the sources become
2307 unavailable.
2308 .SS Example
2309 .PP
2310 Say \f[C]meta\f[] from the previous example has a \f[C]title\f[] and you
2311 are about to extract it.
2312 Since \f[C]title\f[] is a mandatory meta field you should end up with
2313 something like:
2314 .IP
2315 .nf
2316 \f[C]
2317 title\ =\ meta[\[aq]title\[aq]]
2318 \f[]
2319 .fi
2320 .PP
2321 If \f[C]title\f[] disappears from \f[C]meta\f[] in future due to some
2322 changes on the hoster\[aq]s side the extraction would fail since
2323 \f[C]title\f[] is mandatory.
2324 That\[aq]s expected.
2325 .PP
2326 Assume that you have some another source you can extract \f[C]title\f[]
2327 from, for example \f[C]og:title\f[] HTML meta of a \f[C]webpage\f[].
2328 In this case you can provide a fallback scenario:
2329 .IP
2330 .nf
2331 \f[C]
2332 title\ =\ meta.get(\[aq]title\[aq])\ or\ self._og_search_title(webpage)
2333 \f[]
2334 .fi
2335 .PP
2336 This code will try to extract from \f[C]meta\f[] first and if it fails
2337 it will try extracting \f[C]og:title\f[] from a \f[C]webpage\f[].
2338 .SS Regular expressions
2339 .SS Don\[aq]t capture groups you don\[aq]t use
2340 .PP
2341 Capturing group must be an indication that it\[aq]s used somewhere in
2342 the code.
2343 Any group that is not used must be non capturing.
2344 .SS Example
2345 .PP
2346 Don\[aq]t capture id attribute name here since you can\[aq]t use it for
2347 anything anyway.
2348 .PP
2349 Correct:
2350 .IP
2351 .nf
2352 \f[C]
2353 r\[aq](?:id|ID)=(?P<id>\\d+)\[aq]
2354 \f[]
2355 .fi
2356 .PP
2357 Incorrect:
2358 .IP
2359 .nf
2360 \f[C]
2361 r\[aq](id|ID)=(?P<id>\\d+)\[aq]
2362 \f[]
2363 .fi
2364 .SS Make regular expressions relaxed and flexible
2365 .PP
2366 When using regular expressions try to write them fuzzy, relaxed and
2367 flexible, skipping insignificant parts that are more likely to change,
2368 allowing both single and double quotes for quoted values and so on.
2369 .SS Example
2370 .PP
2371 Say you need to extract \f[C]title\f[] from the following HTML code:
2372 .IP
2373 .nf
2374 \f[C]
2375 <span\ style="position:\ absolute;\ left:\ 910px;\ width:\ 90px;\ float:\ right;\ z\-index:\ 9999;"\ class="title">some\ fancy\ title</span>
2376 \f[]
2377 .fi
2378 .PP
2379 The code for that task should look similar to:
2380 .IP
2381 .nf
2382 \f[C]
2383 title\ =\ self._search_regex(
2384 \ \ \ \ r\[aq]<span[^>]+class="title"[^>]*>([^<]+)\[aq],\ webpage,\ \[aq]title\[aq])
2385 \f[]
2386 .fi
2387 .PP
2388 Or even better:
2389 .IP
2390 .nf
2391 \f[C]
2392 title\ =\ self._search_regex(
2393 \ \ \ \ r\[aq]<span[^>]+class=(["\\\[aq]])title\\1[^>]*>(?P<title>[^<]+)\[aq],
2394 \ \ \ \ webpage,\ \[aq]title\[aq],\ group=\[aq]title\[aq])
2395 \f[]
2396 .fi
2397 .PP
2398 Note how you tolerate potential changes in the \f[C]style\f[]
2399 attribute\[aq]s value or switch from using double quotes to single for
2400 \f[C]class\f[] attribute:
2401 .PP
2402 The code definitely should not look like:
2403 .IP
2404 .nf
2405 \f[C]
2406 title\ =\ self._search_regex(
2407 \ \ \ \ r\[aq]<span\ style="position:\ absolute;\ left:\ 910px;\ width:\ 90px;\ float:\ right;\ z\-index:\ 9999;"\ class="title">(.*?)</span>\[aq],
2408 \ \ \ \ webpage,\ \[aq]title\[aq],\ group=\[aq]title\[aq])
2409 \f[]
2410 .fi
2411 .SS Long lines policy
2412 .PP
2413 There is a soft limit to keep lines of code under 80 characters long.
2414 This means it should be respected if possible and if it does not make
2415 readability and code maintenance worse.
2416 .PP
2417 For example, you should \f[B]never\f[] split long string literals like
2418 URLs or some other often copied entities over multiple lines to fit this
2419 limit:
2420 .PP
2421 Correct:
2422 .IP
2423 .nf
2424 \f[C]
2425 \[aq]https://www.youtube.com/watch?v=FqZTN594JQw&list=PLMYEtVRpaqY00V9W81Cwmzp6N6vZqfUKD4\[aq]
2426 \f[]
2427 .fi
2428 .PP
2429 Incorrect:
2430 .IP
2431 .nf
2432 \f[C]
2433 \[aq]https://www.youtube.com/watch?v=FqZTN594JQw&list=\[aq]
2434 \[aq]PLMYEtVRpaqY00V9W81Cwmzp6N6vZqfUKD4\[aq]
2435 \f[]
2436 .fi
2437 .SS Inline values
2438 .PP
2439 Extracting variables is acceptable for reducing code duplication and
2440 improving readability of complex expressions.
2441 However, you should avoid extracting variables used only once and moving
2442 them to opposite parts of the extractor file, which makes reading the
2443 linear flow difficult.
2444 .SS Example
2445 .PP
2446 Correct:
2447 .IP
2448 .nf
2449 \f[C]
2450 title\ =\ self._html_search_regex(r\[aq]<title>([^<]+)</title>\[aq],\ webpage,\ \[aq]title\[aq])
2451 \f[]
2452 .fi
2453 .PP
2454 Incorrect:
2455 .IP
2456 .nf
2457 \f[C]
2458 TITLE_RE\ =\ r\[aq]<title>([^<]+)</title>\[aq]
2459 #\ ...some\ lines\ of\ code...
2460 title\ =\ self._html_search_regex(TITLE_RE,\ webpage,\ \[aq]title\[aq])
2461 \f[]
2462 .fi
2463 .SS Collapse fallbacks
2464 .PP
2465 Multiple fallback values can quickly become unwieldy.
2466 Collapse multiple fallback values into a single expression via a list of
2467 patterns.
2468 .SS Example
2469 .PP
2470 Good:
2471 .IP
2472 .nf
2473 \f[C]
2474 description\ =\ self._html_search_meta(
2475 \ \ \ \ [\[aq]og:description\[aq],\ \[aq]description\[aq],\ \[aq]twitter:description\[aq]],
2476 \ \ \ \ webpage,\ \[aq]description\[aq],\ default=None)
2477 \f[]
2478 .fi
2479 .PP
2480 Unwieldy:
2481 .IP
2482 .nf
2483 \f[C]
2484 description\ =\ (
2485 \ \ \ \ self._og_search_description(webpage,\ default=None)
2486 \ \ \ \ or\ self._html_search_meta(\[aq]description\[aq],\ webpage,\ default=None)
2487 \ \ \ \ or\ self._html_search_meta(\[aq]twitter:description\[aq],\ webpage,\ default=None))
2488 \f[]
2489 .fi
2490 .PP
2491 Methods supporting list of patterns are: \f[C]_search_regex\f[],
2492 \f[C]_html_search_regex\f[], \f[C]_og_search_property\f[],
2493 \f[C]_html_search_meta\f[].
2494 .SS Trailing parentheses
2495 .PP
2496 Always move trailing parentheses after the last argument.
2497 .SS Example
2498 .PP
2499 Correct:
2500 .IP
2501 .nf
2502 \f[C]
2503 \ \ \ \ lambda\ x:\ x[\[aq]ResultSet\[aq]][\[aq]Result\[aq]][0][\[aq]VideoUrlSet\[aq]][\[aq]VideoUrl\[aq]],
2504 \ \ \ \ list)
2505 \f[]
2506 .fi
2507 .PP
2508 Incorrect:
2509 .IP
2510 .nf
2511 \f[C]
2512 \ \ \ \ lambda\ x:\ x[\[aq]ResultSet\[aq]][\[aq]Result\[aq]][0][\[aq]VideoUrlSet\[aq]][\[aq]VideoUrl\[aq]],
2513 \ \ \ \ list,
2514 )
2515 \f[]
2516 .fi
2517 .SS Use convenience conversion and parsing functions
2518 .PP
2519 Wrap all extracted numeric data into safe functions from
2520 \f[C]youtube_dl/utils.py\f[] (https://github.com/ytdl-org/youtube-dl/blob/master/youtube_dl/utils.py):
2521 \f[C]int_or_none\f[], \f[C]float_or_none\f[].
2522 Use them for string to number conversions as well.
2523 .PP
2524 Use \f[C]url_or_none\f[] for safe URL processing.
2525 .PP
2526 Use \f[C]try_get\f[] for safe metadata extraction from parsed JSON.
2527 .PP
2528 Use \f[C]unified_strdate\f[] for uniform \f[C]upload_date\f[] or any
2529 \f[C]YYYYMMDD\f[] meta field extraction, \f[C]unified_timestamp\f[] for
2530 uniform \f[C]timestamp\f[] extraction, \f[C]parse_filesize\f[] for
2531 \f[C]filesize\f[] extraction, \f[C]parse_count\f[] for count meta fields
2532 extraction, \f[C]parse_resolution\f[], \f[C]parse_duration\f[] for
2533 \f[C]duration\f[] extraction, \f[C]parse_age_limit\f[] for
2534 \f[C]age_limit\f[] extraction.
2535 .PP
2536 Explore
2537 \f[C]youtube_dl/utils.py\f[] (https://github.com/ytdl-org/youtube-dl/blob/master/youtube_dl/utils.py)
2538 for more useful convenience functions.
2539 .SS More examples
2540 .SS Safely extract optional description from parsed JSON
2541 .IP
2542 .nf
2543 \f[C]
2544 description\ =\ try_get(response,\ lambda\ x:\ x[\[aq]result\[aq]][\[aq]video\[aq]][0][\[aq]summary\[aq]],\ compat_str)
2545 \f[]
2546 .fi
2547 .SS Safely extract more optional metadata
2548 .IP
2549 .nf
2550 \f[C]
2551 video\ =\ try_get(response,\ lambda\ x:\ x[\[aq]result\[aq]][\[aq]video\[aq]][0],\ dict)\ or\ {}
2552 description\ =\ video.get(\[aq]summary\[aq])
2553 duration\ =\ float_or_none(video.get(\[aq]durationMs\[aq]),\ scale=1000)
2554 view_count\ =\ int_or_none(video.get(\[aq]views\[aq]))
2555 \f[]
2556 .fi
2557 .SH EMBEDDING YOUTUBE\-DL
2558 .PP
2559 youtube\-dl makes the best effort to be a good command\-line program,
2560 and thus should be callable from any programming language.
2561 If you encounter any problems parsing its output, feel free to create a
2562 report (https://github.com/ytdl-org/youtube-dl/issues/new).
2563 .PP
2564 From a Python program, you can embed youtube\-dl in a more powerful
2565 fashion, like this:
2566 .IP
2567 .nf
2568 \f[C]
2569 from\ __future__\ import\ unicode_literals
2570 import\ youtube_dl
2571
2572 ydl_opts\ =\ {}
2573 with\ youtube_dl.YoutubeDL(ydl_opts)\ as\ ydl:
2574 \ \ \ \ ydl.download([\[aq]https://www.youtube.com/watch?v=BaW_jenozKc\[aq]])
2575 \f[]
2576 .fi
2577 .PP
2578 Most likely, you\[aq]ll want to use various options.
2579 For a list of options available, have a look at
2580 \f[C]youtube_dl/YoutubeDL.py\f[] (https://github.com/ytdl-org/youtube-dl/blob/3e4cedf9e8cd3157df2457df7274d0c842421945/youtube_dl/YoutubeDL.py#L137-L312).
2581 For a start, if you want to intercept youtube\-dl\[aq]s output, set a
2582 \f[C]logger\f[] object.
2583 .PP
2584 Here\[aq]s a more complete example of a program that outputs only errors
2585 (and a short message after the download is finished), and
2586 downloads/converts the video to an mp3 file:
2587 .IP
2588 .nf
2589 \f[C]
2590 from\ __future__\ import\ unicode_literals
2591 import\ youtube_dl
2592
2593
2594 class\ MyLogger(object):
2595 \ \ \ \ def\ debug(self,\ msg):
2596 \ \ \ \ \ \ \ \ pass
2597
2598 \ \ \ \ def\ warning(self,\ msg):
2599 \ \ \ \ \ \ \ \ pass
2600
2601 \ \ \ \ def\ error(self,\ msg):
2602 \ \ \ \ \ \ \ \ print(msg)
2603
2604
2605 def\ my_hook(d):
2606 \ \ \ \ if\ d[\[aq]status\[aq]]\ ==\ \[aq]finished\[aq]:
2607 \ \ \ \ \ \ \ \ print(\[aq]Done\ downloading,\ now\ converting\ ...\[aq])
2608
2609
2610 ydl_opts\ =\ {
2611 \ \ \ \ \[aq]format\[aq]:\ \[aq]bestaudio/best\[aq],
2612 \ \ \ \ \[aq]postprocessors\[aq]:\ [{
2613 \ \ \ \ \ \ \ \ \[aq]key\[aq]:\ \[aq]FFmpegExtractAudio\[aq],
2614 \ \ \ \ \ \ \ \ \[aq]preferredcodec\[aq]:\ \[aq]mp3\[aq],
2615 \ \ \ \ \ \ \ \ \[aq]preferredquality\[aq]:\ \[aq]192\[aq],
2616 \ \ \ \ }],
2617 \ \ \ \ \[aq]logger\[aq]:\ MyLogger(),
2618 \ \ \ \ \[aq]progress_hooks\[aq]:\ [my_hook],
2619 }
2620 with\ youtube_dl.YoutubeDL(ydl_opts)\ as\ ydl:
2621 \ \ \ \ ydl.download([\[aq]https://www.youtube.com/watch?v=BaW_jenozKc\[aq]])
2622 \f[]
2623 .fi
2624 .SH BUGS
2625 .PP
2626 Bugs and suggestions should be reported at:
2627 <https://github.com/ytdl-org/youtube-dl/issues>.
2628 Unless you were prompted to or there is another pertinent reason (e.g.
2629 GitHub fails to accept the bug report), please do not send bug reports
2630 via personal email.
2631 For discussions, join us in the IRC channel
2632 #youtube\-dl (irc://chat.freenode.net/#youtube-dl) on freenode
2633 (webchat (https://webchat.freenode.net/?randomnick=1&channels=youtube-dl)).
2634 .PP
2635 \f[B]Please include the full output of youtube\-dl when run with
2636 \f[BC]\-v\f[B]\f[], i.e.
2637 \f[B]add\f[] \f[C]\-v\f[] flag to \f[B]your command line\f[], copy the
2638 \f[B]whole\f[] output and post it in the issue body wrapped in ``` for
2639 better formatting.
2640 It should look similar to this:
2641 .IP
2642 .nf
2643 \f[C]
2644 $\ youtube\-dl\ \-v\ <your\ command\ line>
2645 [debug]\ System\ config:\ []
2646 [debug]\ User\ config:\ []
2647 [debug]\ Command\-line\ args:\ [u\[aq]\-v\[aq],\ u\[aq]https://www.youtube.com/watch?v=BaW_jenozKcj\[aq]]
2648 [debug]\ Encodings:\ locale\ cp1251,\ fs\ mbcs,\ out\ cp866,\ pref\ cp1251
2649 [debug]\ youtube\-dl\ version\ 2015.12.06
2650 [debug]\ Git\ HEAD:\ 135392e
2651 [debug]\ Python\ version\ 2.6.6\ \-\ Windows\-2003Server\-5.2.3790\-SP2
2652 [debug]\ exe\ versions:\ ffmpeg\ N\-75573\-g1d0487f,\ ffprobe\ N\-75573\-g1d0487f,\ rtmpdump\ 2.4
2653 [debug]\ Proxy\ map:\ {}
2654 \&...
2655 \f[]
2656 .fi
2657 .PP
2658 \f[B]Do not post screenshots of verbose logs; only plain text is
2659 acceptable.\f[]
2660 .PP
2661 The output (including the first lines) contains important debugging
2662 information.
2663 Issues without the full output are often not reproducible and therefore
2664 do not get solved in short order, if ever.
2665 .PP
2666 Please re\-read your issue once again to avoid a couple of common
2667 mistakes (you can and should use this as a checklist):
2668 .SS Is the description of the issue itself sufficient?
2669 .PP
2670 We often get issue reports that we cannot really decipher.
2671 While in most cases we eventually get the required information after
2672 asking back multiple times, this poses an unnecessary drain on our
2673 resources.
2674 Many contributors, including myself, are also not native speakers, so we
2675 may misread some parts.
2676 .PP
2677 So please elaborate on what feature you are requesting, or what bug you
2678 want to be fixed.
2679 Make sure that it\[aq]s obvious
2680 .IP \[bu] 2
2681 What the problem is
2682 .IP \[bu] 2
2683 How it could be fixed
2684 .IP \[bu] 2
2685 How your proposed solution would look like
2686 .PP
2687 If your report is shorter than two lines, it is almost certainly missing
2688 some of these, which makes it hard for us to respond to it.
2689 We\[aq]re often too polite to close the issue outright, but the missing
2690 info makes misinterpretation likely.
2691 As a committer myself, I often get frustrated by these issues, since the
2692 only possible way for me to move forward on them is to ask for
2693 clarification over and over.
2694 .PP
2695 For bug reports, this means that your report should contain the
2696 \f[I]complete\f[] output of youtube\-dl when called with the
2697 \f[C]\-v\f[] flag.
2698 The error message you get for (most) bugs even says so, but you would
2699 not believe how many of our bug reports do not contain this information.
2700 .PP
2701 If your server has multiple IPs or you suspect censorship, adding
2702 \f[C]\-\-call\-home\f[] may be a good idea to get more diagnostics.
2703 If the error is \f[C]ERROR:\ Unable\ to\ extract\ ...\f[] and you cannot
2704 reproduce it from multiple countries, add \f[C]\-\-dump\-pages\f[]
2705 (warning: this will yield a rather large output, redirect it to the file
2706 \f[C]log.txt\f[] by adding \f[C]>log.txt\ 2>&1\f[] to your
2707 command\-line) or upload the \f[C]\&.dump\f[] files you get when you add
2708 \f[C]\-\-write\-pages\f[] somewhere (https://gist.github.com/).
2709 .PP
2710 \f[B]Site support requests must contain an example URL\f[].
2711 An example URL is a URL you might want to download, like
2712 \f[C]https://www.youtube.com/watch?v=BaW_jenozKc\f[].
2713 There should be an obvious video present.
2714 Except under very special circumstances, the main page of a video
2715 service (e.g.
2716 \f[C]https://www.youtube.com/\f[]) is \f[I]not\f[] an example URL.
2717 .SS Are you using the latest version?
2718 .PP
2719 Before reporting any issue, type \f[C]youtube\-dl\ \-U\f[].
2720 This should report that you\[aq]re up\-to\-date.
2721 About 20% of the reports we receive are already fixed, but people are
2722 using outdated versions.
2723 This goes for feature requests as well.
2724 .SS Is the issue already documented?
2725 .PP
2726 Make sure that someone has not already opened the issue you\[aq]re
2727 trying to open.
2728 Search at the top of the window or browse the GitHub
2729 Issues (https://github.com/ytdl-org/youtube-dl/search?type=Issues) of
2730 this repository.
2731 If there is an issue, feel free to write something along the lines of
2732 "This affects me as well, with version 2015.01.01.
2733 Here is some more information on the issue: ...".
2734 While some issues may be old, a new post into them often spurs rapid
2735 activity.
2736 .SS Why are existing options not enough?
2737 .PP
2738 Before requesting a new feature, please have a quick peek at the list of
2739 supported
2740 options (https://github.com/ytdl-org/youtube-dl/blob/master/README.md#options).
2741 Many feature requests are for features that actually exist already!
2742 Please, absolutely do show off your work in the issue report and detail
2743 how the existing similar options do \f[I]not\f[] solve your problem.
2744 .SS Is there enough context in your bug report?
2745 .PP
2746 People want to solve problems, and often think they do us a favor by
2747 breaking down their larger problems (e.g.
2748 wanting to skip already downloaded files) to a specific request (e.g.
2749 requesting us to look whether the file exists before downloading the
2750 info page).
2751 However, what often happens is that they break down the problem into two
2752 steps: One simple, and one impossible (or extremely complicated one).
2753 .PP
2754 We are then presented with a very complicated request when the original
2755 problem could be solved far easier, e.g.
2756 by recording the downloaded video IDs in a separate file.
2757 To avoid this, you must include the greater context where it is
2758 non\-obvious.
2759 In particular, every feature request that does not consist of adding
2760 support for a new site should contain a use case scenario that explains
2761 in what situation the missing feature would be useful.
2762 .SS Does the issue involve one problem, and one problem only?
2763 .PP
2764 Some of our users seem to think there is a limit of issues they can or
2765 should open.
2766 There is no limit of issues they can or should open.
2767 While it may seem appealing to be able to dump all your issues into one
2768 ticket, that means that someone who solves one of your issues cannot
2769 mark the issue as closed.
2770 Typically, reporting a bunch of issues leads to the ticket lingering
2771 since nobody wants to attack that behemoth, until someone mercifully
2772 splits the issue into multiple ones.
2773 .PP
2774 In particular, every site support request issue should only pertain to
2775 services at one site (generally under a common domain, but always using
2776 the same backend technology).
2777 Do not request support for vimeo user videos, White house podcasts, and
2778 Google Plus pages in the same issue.
2779 Also, make sure that you don\[aq]t post bug reports alongside feature
2780 requests.
2781 As a rule of thumb, a feature request does not include outputs of
2782 youtube\-dl that are not immediately related to the feature at hand.
2783 Do not post reports of a network error alongside the request for a new
2784 video service.
2785 .SS Is anyone going to need the feature?
2786 .PP
2787 Only post features that you (or an incapacitated friend you can
2788 personally talk to) require.
2789 Do not post features because they seem like a good idea.
2790 If they are really useful, they will be requested by someone who
2791 requires them.
2792 .SS Is your question about youtube\-dl?
2793 .PP
2794 It may sound strange, but some bug reports we receive are completely
2795 unrelated to youtube\-dl and relate to a different, or even the
2796 reporter\[aq]s own, application.
2797 Please make sure that you are actually using youtube\-dl.
2798 If you are using a UI for youtube\-dl, report the bug to the maintainer
2799 of the actual application providing the UI.
2800 On the other hand, if your UI for youtube\-dl fails in some way you
2801 believe is related to youtube\-dl, by all means, go ahead and report the
2802 bug.
2803 .SH COPYRIGHT
2804 .PP
2805 youtube\-dl is released into the public domain by the copyright holders.
2806 .PP
2807 This README file was originally written by Daniel
2808 Bolton (https://github.com/dbbolton) and is likewise released into the
2809 public domain.