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