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