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