1YOUTUBE-DL(1)                                                    YOUTUBE-DL(1)
2
3
4

NAME

6       youtube-dl - download videos from youtube.com or other video platforms
7

SYNOPSIS

9       youtube-dl [OPTIONS] URL [URL...]
10

DESCRIPTION

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

OPTIONS

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,c url,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       --output-na-placeholder PLACEHOLDER
277              Placeholder value for unavailable meta fields in output filename
278              template (default is "NA")
279
280       --autonumber-start NUMBER
281              Specify the start value for %(autonumber)s (default is 1)
282
283       --restrict-filenames
284              Restrict filenames to only ASCII characters, and avoid  "&"  and
285              spaces in filenames
286
287       -w, --no-overwrites
288              Do not overwrite files
289
290       -c, --continue
291              Force   resume  of  partially  downloaded  files.   By  default,
292              youtube-dl will resume downloads if possible.
293
294       --no-continue
295              Do not resume partially downloaded files  (restart  from  begin‐
296              ning)
297
298       --no-part
299              Do not use .part files - write directly into output file
300
301       --no-mtime
302              Do not use the Last-modified header to set the file modification
303              time
304
305       --write-description
306              Write video description to a .description file
307
308       --write-info-json
309              Write video metadata to a .info.json file
310
311       --write-annotations
312              Write video annotations to a .annotations.xml file
313
314       --load-info-json FILE
315              JSON file containing the video  information  (created  with  the
316              "--write- info-json" option)
317
318       --cookies FILE
319              File to read cookies from and dump cookie jar in
320
321       --cache-dir DIR
322              Location in the filesystem where youtube-dl can store some down‐
323              loaded      information      permanently.       By       default
324              $XDG_CACHE_HOME/youtube-dl  or ~/.cache/youtube-dl .  At the mo‐
325              ment, only YouTube player files (for videos with obfuscated sig‐
326              natures) are cached, but that may change.
327
328       --no-cache-dir
329              Disable filesystem caching
330
331       --rm-cache-dir
332              Delete all filesystem cache files
333
334   Thumbnail images:
335       --write-thumbnail
336              Write thumbnail image to disk
337
338       --write-all-thumbnails
339              Write all thumbnail image formats to disk
340
341       --list-thumbnails
342              Simulate and list all available thumbnail formats
343
344   Verbosity / Simulation Options:
345       -q, --quiet
346              Activate quiet mode
347
348       --no-warnings
349              Ignore warnings
350
351       -s, --simulate
352              Do not download the video and do not write anything to disk
353
354       --skip-download
355              Do not download the video
356
357       -g, --get-url
358              Simulate, quiet but print URL
359
360       -e, --get-title
361              Simulate, quiet but print title
362
363       --get-id
364              Simulate, quiet but print id
365
366       --get-thumbnail
367              Simulate, quiet but print thumbnail URL
368
369       --get-description
370              Simulate, quiet but print video description
371
372       --get-duration
373              Simulate, quiet but print video length
374
375       --get-filename
376              Simulate, quiet but print output filename
377
378       --get-format
379              Simulate, quiet but print output format
380
381       -j, --dump-json
382              Simulate,  quiet  but  print  JSON information.  See the "OUTPUT
383              TEMPLATE" for a description of available keys.
384
385       -J, --dump-single-json
386              Simulate, quiet but print JSON information for each command-line
387              argument.   If  the  URL  refers  to  a playlist, dump the whole
388              playlist information in a single line.
389
390       --print-json
391              Be quiet and print the video information as JSON (video is still
392              being downloaded).
393
394       --newline
395              Output progress bar as new lines
396
397       --no-progress
398              Do not print progress bar
399
400       --console-title
401              Display progress in console titlebar
402
403       -v, --verbose
404              Print various debugging information
405
406       --dump-pages
407              Print  downloaded  pages  encoded using base64 to debug problems
408              (very verbose)
409
410       --write-pages
411              Write downloaded intermediary pages to files in the current  di‐
412              rectory to debug problems
413
414       --print-traffic
415              Display sent and read HTTP traffic
416
417       -C, --call-home
418              Contact the youtube-dl server for debugging
419
420       --no-call-home
421              Do NOT contact the youtube-dl server for debugging
422
423   Workarounds:
424       --encoding ENCODING
425              Force the specified encoding (experimental)
426
427       --no-check-certificate
428              Suppress HTTPS certificate validation
429
430       --prefer-insecure
431              Use  an unencrypted connection to retrieve information about the
432              video.  (Currently supported only for YouTube)
433
434       --user-agent UA
435              Specify a custom user agent
436
437       --referer URL
438              Specify a custom referer, use if the video access is  restricted
439              to one domain
440
441       --add-header FIELD:VALUE
442              Specify a custom HTTP header and its value, separated by a colon
443              ':'.  You can use this option multiple times
444
445       --bidi-workaround
446              Work around terminals that lack bidirectional text support.  Re‐
447              quires bidiv or fribidi executable in PATH
448
449       --sleep-interval SECONDS
450              Number  of seconds to sleep before each download when used alone
451              or a lower bound of a range for  randomized  sleep  before  each
452              download (minimum possible number of seconds to sleep) when used
453              along with --max-sleep-interval.
454
455       --max-sleep-interval SECONDS
456              Upper bound of a range for randomized sleep before each download
457              (maximum  possible  number  of  seconds to sleep).  Must only be
458              used along with --min- sleep-interval.
459
460   Video Format Options:
461       -f, --format FORMAT
462              Video format code, see the "FORMAT SELECTION" for all the info
463
464       --all-formats
465              Download all available video formats
466
467       --prefer-free-formats
468              Prefer free video formats unless a specific one is requested
469
470       -F, --list-formats
471              List all available formats of requested videos
472
473       --youtube-skip-dash-manifest
474              Do not download the DASH manifests and related data  on  YouTube
475              videos
476
477       --merge-output-format FORMAT
478              If  a  merge  is required (e.g.  bestvideo+bestaudio), output to
479              given container format.  One of mkv, mp4, ogg, webm,  flv.   Ig‐
480              nored if no merge is required
481
482   Subtitle Options:
483       --write-sub
484              Write subtitle file
485
486       --write-auto-sub
487              Write automatically generated subtitle file (YouTube only)
488
489       --all-subs
490              Download all the available subtitles of the video
491
492       --list-subs
493              List all available subtitles for the video
494
495       --sub-format FORMAT
496              Subtitle  format, accepts formats preference, for example: "srt"
497              or "ass/srt/best"
498
499       --sub-lang LANGS
500              Languages of the subtitles to download (optional)  separated  by
501              commas, use --list-subs for available language tags
502
503   Authentication Options:
504       -u, --username USERNAME
505              Login with this account ID
506
507       -p, --password PASSWORD
508              Account  password.   If this option is left out, youtube-dl will
509              ask interactively.
510
511       -2, --twofactor TWOFACTOR
512              Two-factor authentication code
513
514       -n, --netrc
515              Use .netrc authentication data
516
517       --video-password PASSWORD
518              Video password (vimeo, youku)
519
520   Adobe Pass Options:
521       --ap-mso MSO
522              Adobe Pass multiple-system operator  (TV  provider)  identifier,
523              use --ap-list-mso for a list of available MSOs
524
525       --ap-username USERNAME
526              Multiple-system operator account login
527
528       --ap-password PASSWORD
529              Multiple-system  operator  account  password.  If this option is
530              left out, youtube-dl will ask interactively.
531
532       --ap-list-mso
533              List all supported multiple-system operators
534
535   Post-processing Options:
536       -x, --extract-audio
537              Convert video files to audio-only files (requires  ffmpeg/avconv
538              and ffprobe/avprobe)
539
540       --audio-format FORMAT
541              Specify  audio  format:  "best",  "aac",  "flac",  "mp3", "m4a",
542              "opus", "vorbis", or "wav"; "best" by default; No effect without
543              -x
544
545       --audio-quality QUALITY
546              Specify  ffmpeg/avconv  audio  quality, insert a value between 0
547              (better) and 9 (worse) for VBR or a specific bitrate  like  128K
548              (default 5)
549
550       --recode-video FORMAT
551              Encode  the video to another format if necessary (currently sup‐
552              ported: mp4|flv|ogg|webm|mkv|avi)
553
554       --postprocessor-args ARGS
555              Give these arguments to the postprocessor
556
557       -k, --keep-video
558              Keep the video file on disk after the post-processing; the video
559              is erased by default
560
561       --no-post-overwrites
562              Do  not overwrite post-processed files; the post-processed files
563              are overwritten by default
564
565       --embed-subs
566              Embed subtitles in the video (only for mp4, webm and mkv videos)
567
568       --embed-thumbnail
569              Embed thumbnail in the audio as cover art
570
571       --add-metadata
572              Write metadata to the video file
573
574       --metadata-from-title FORMAT
575              Parse additional metadata like song  title  /  artist  from  the
576              video  title.  The format syntax is the same as --output.  Regu‐
577              lar expression with named capture groups may also be used.   The
578              parsed  parameters  replace existing values.  Example: --metada‐
579              ta-from-title "%(artist)s -  %(title)s"  matches  a  title  like
580              "Coldplay  -  Paradise".  Example (regex): --metadata-from-title
581              "(?P.+?) - (?P
582              .+)"
583
584       --xattrs
585              Write metadata to the video file's xattrs (using dublin core and
586              xdg standards)
587
588       --fixup POLICY
589              Automatically  correct  known  faults of the file.  One of never
590              (do nothing), warn (only emit a  warning),  detect_or_warn  (the
591              default; fix file if we can, warn otherwise)
592
593       --prefer-avconv
594              Prefer avconv over ffmpeg for running the postprocessors
595
596       --prefer-ffmpeg
597              Prefer  ffmpeg  over  avconv for running the postprocessors (de‐
598              fault)
599
600       --ffmpeg-location PATH
601              Location of the ffmpeg/avconv binary; either the path to the bi‐
602              nary or its containing directory.
603
604       --exec CMD
605              Execute  a  command  on the file after downloading and post-pro‐
606              cessing, similar to find's -exec syntax.  Example:  --exec  'adb
607              push {} /sdcard/Music/ && rm {}'
608
609       --convert-subs FORMAT
610              Convert  the  subtitles  to  other  format (currently supported:
611              srt|ass|vtt|lrc)
612

CONFIGURATION

614       You can configure youtube-dl by placing any supported command line  op‐
615       tion to a configuration file.  On Linux and macOS, the system wide con‐
616       figuration file is located at /etc/youtube-dl.conf and  the  user  wide
617       configuration file at ~/.config/youtube-dl/config.  On Windows, the us‐
618       er wide  configuration  file  locations  are  %APPDATA%\youtube-dl\con‐
619       fig.txt  or C:\Users\<user name>\youtube-dl.conf.  Note that by default
620       configuration file may not exist so you may need to create it yourself.
621
622       For example, with the following configuration file youtube-dl will  al‐
623       ways  extract  the  audio, not copy the mtime, use a proxy and save all
624       videos under Movies directory in your home directory:
625
626              # Lines starting with # are comments
627
628              # Always extract audio
629              -x
630
631              # Do not copy the mtime
632              --no-mtime
633
634              # Use this proxy
635              --proxy 127.0.0.1:3128
636
637              # Save all videos under Movies directory in your home directory
638              -o ~/Movies/%(title)s.%(ext)s
639
640       Note that options in configuration file are just the same  options  aka
641       switches  used  in  regular  command  line  calls thus there must be no
642       whitespace after - or --, e.g.  -o or --proxy but not - o or -- proxy.
643
644       You can use --ignore-config if you want to  disable  the  configuration
645       file for a particular youtube-dl run.
646
647       You can also use --config-location if you want to use custom configura‐
648       tion file for a particular youtube-dl run.
649
650   Authentication with .netrc file
651       You may also want to configure automatic credentials  storage  for  ex‐
652       tractors  that  support authentication (by providing login and password
653       with --username and --password) in order not  to  pass  credentials  as
654       command line arguments on every youtube-dl execution and prevent track‐
655       ing plain text passwords in the shell command history.  You can achieve
656       this  using  a .netrc file (https://stackoverflow.com/tags/.netrc/info)
657       on a per extractor basis.  For that you will need to  create  a  .netrc
658       file in your $HOME and restrict permissions to read/write by only you:
659
660              touch $HOME/.netrc
661              chmod a-rwx,u+rw $HOME/.netrc
662
663       After  that  you  can add credentials for an extractor in the following
664       format, where extractor is the name of the extractor in lowercase:
665
666              machine <extractor> login <login> password <password>
667
668       For example:
669
670              machine youtube login myaccount@gmail.com password my_youtube_password
671              machine twitch login my_twitch_account_name password my_twitch_password
672
673       To activate authentication with the .netrc file you should pass --netrc
674       to youtube-dl or place it in the configuration file.
675
676       On  Windows  you may also need to setup the %HOME% environment variable
677       manually.  For example:
678
679              set HOME=%USERPROFILE%
680

OUTPUT TEMPLATE

682       The -o option allows users to indicate a template for the  output  file
683       names.
684
685       tl;dr: navigate me to examples.
686
687       The basic usage is not to set any template arguments when downloading a
688       single         file,         like         in         youtube-dl -o fun‐
689       ny_video.flv "https://some/video".  However, it may contain special se‐
690       quences that will be replaced when downloading each video.  The special
691       sequences may be formatted according to python string formatting opera‐
692       tions   (https://docs.python.org/2/library/stdtypes.html#string-format‐
693       ting).   For  example,  %(NAME)s  or %(NAME)05d.  To clarify, that is a
694       percent symbol followed by a name in parentheses, followed  by  format‐
695       ting operations.  Allowed names along with sequence type are:
696
697       · id (string): Video identifier
698
699       · title (string): Video title
700
701       · url (string): Video URL
702
703       · ext (string): Video filename extension
704
705       · alt_title (string): A secondary title of the video
706
707       · display_id (string): An alternative identifier for the video
708
709       · uploader (string): Full name of the video uploader
710
711       · license (string): License name the video is licensed under
712
713       · creator (string): The creator of the video
714
715       · release_date  (string):  The  date  (YYYYMMDD) when the video was re‐
716         leased
717
718       · timestamp (numeric): UNIX timestamp of the moment  the  video  became
719         available
720
721       · upload_date (string): Video upload date (YYYYMMDD)
722
723       · uploader_id (string): Nickname or id of the video uploader
724
725       · channel (string): Full name of the channel the video is uploaded on
726
727       · channel_id (string): Id of the channel
728
729       · location (string): Physical location where the video was filmed
730
731       · duration (numeric): Length of the video in seconds
732
733       · view_count  (numeric):  How  many users have watched the video on the
734         platform
735
736       · like_count (numeric): Number of positive ratings of the video
737
738       · dislike_count (numeric): Number of negative ratings of the video
739
740       · repost_count (numeric): Number of reposts of the video
741
742       · average_rating (numeric): Average rating give  by  users,  the  scale
743         used depends on the webpage
744
745       · comment_count (numeric): Number of comments on the video
746
747       · age_limit (numeric): Age restriction for the video (years)
748
749       · is_live  (boolean):  Whether  this  video  is  a  live  stream  or  a
750         fixed-length video
751
752       · start_time (numeric): Time in seconds where the  reproduction  should
753         start, as specified in the URL
754
755       · end_time  (numeric):  Time  in  seconds where the reproduction should
756         end, as specified in the URL
757
758       · format (string): A human-readable description of the format
759
760       · format_id (string): Format code specified by --format
761
762       · format_note (string): Additional info about the format
763
764       · width (numeric): Width of the video
765
766       · height (numeric): Height of the video
767
768       · resolution (string): Textual description of width and height
769
770       · tbr (numeric): Average bitrate of audio and video in KBit/s
771
772       · abr (numeric): Average audio bitrate in KBit/s
773
774       · acodec (string): Name of the audio codec in use
775
776       · asr (numeric): Audio sampling rate in Hertz
777
778       · vbr (numeric): Average video bitrate in KBit/s
779
780       · fps (numeric): Frame rate
781
782       · vcodec (string): Name of the video codec in use
783
784       · container (string): Name of the container format
785
786       · filesize (numeric): The number of bytes, if known in advance
787
788       · filesize_approx (numeric): An estimate for the number of bytes
789
790       · protocol (string): The protocol that will  be  used  for  the  actual
791         download
792
793       · extractor (string): Name of the extractor
794
795       · extractor_key (string): Key name of the extractor
796
797       · epoch (numeric): Unix epoch when creating the file
798
799       · autonumber  (numeric):  Number that will be increased with each down‐
800         load, starting at --autonumber-start
801
802       · playlist (string): Name or id of the playlist that contains the video
803
804       · playlist_index (numeric): Index of the video in the  playlist  padded
805         with leading zeros according to the total length of the playlist
806
807       · playlist_id (string): Playlist identifier
808
809       · playlist_title (string): Playlist title
810
811       · playlist_uploader (string): Full name of the playlist uploader
812
813       · playlist_uploader_id (string): Nickname or id of the playlist upload‐
814         er
815
816       Available for the video that belongs to some logical  chapter  or  sec‐
817       tion:
818
819       · chapter (string): Name or title of the chapter the video belongs to
820
821       · chapter_number (numeric): Number of the chapter the video belongs to
822
823       · chapter_id (string): Id of the chapter the video belongs to
824
825       Available for the video that is an episode of some series or programme:
826
827       · series  (string):  Title of the series or programme the video episode
828         belongs to
829
830       · season (string): Title of the season the video episode belongs to
831
832       · season_number (numeric): Number of the season the video  episode  be‐
833         longs to
834
835       · season_id (string): Id of the season the video episode belongs to
836
837       · episode (string): Title of the video episode
838
839       · episode_number (numeric): Number of the video episode within a season
840
841       · episode_id (string): Id of the video episode
842
843       Available for the media that is a track or a part of a music album:
844
845       · track (string): Title of the track
846
847       · track_number (numeric): Number of the track within an album or a disc
848
849       · track_id (string): Id of the track
850
851       · artist (string): Artist(s) of the track
852
853       · genre (string): Genre(s) of the track
854
855       · album (string): Title of the album the track belongs to
856
857       · album_type (string): Type of the album
858
859       · album_artist (string): List of all artists appeared on the album
860
861       · disc_number  (numeric):  Number  of the disc or other physical medium
862         the track belongs to
863
864       · release_year (numeric): Year (YYYY) when the album was released
865
866       Each aforementioned sequence when referenced in an output template will
867       be  replaced  by  the  actual value corresponding to the sequence name.
868       Note that some of the sequences are not guaranteed to be present  since
869       they  depend  on the metadata obtained by a particular extractor.  Such
870       sequences will be replaced with placeholder value provided with  --out‐
871       put-na-placeholder (NA by default).
872
873       For example for -o %(title)s-%(id)s.%(ext)s and an mp4 video with title
874       youtube-dl test video and  id  BaW_jenozKcj,  this  will  result  in  a
875       youtube-dl test video-BaW_jenozKcj.mp4  file created in the current di‐
876       rectory.
877
878       For numeric sequences you can use numeric related formatting, for exam‐
879       ple,  %(view_count)05d  will  result in a string with view count padded
880       with zeros up to 5 characters, like in 00042.
881
882       Output templates can also contain  arbitrary  hierarchical  path,  e.g.
883       -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' which will re‐
884       sult in downloading each video in a  directory  corresponding  to  this
885       path template.  Any missing directory will be automatically created for
886       you.
887
888       To use percent literals in an output template use  %%.   To  output  to
889       stdout use -o -.
890
891       The current default template is %(title)s-%(id)s.%(ext)s.
892
893       In some cases, you don't want special characters such as 中, spaces, or
894       &, such as when transferring the downloaded filename to a Windows  sys‐
895       tem  or  the  filename through an 8bit-unsafe channel.  In these cases,
896       add the --restrict-filenames flag to get a shorter title:
897
898   Output template and Windows batch files
899       If you are using an output template inside a Windows  batch  file  then
900       you  must  escape  plain  percent  characters  (%) by doubling, so that
901       -o "%(title)s-%(id)s.%(ext)s"      should       become       -o "%%(ti‐
902       tle)s-%%(id)s.%%(ext)s".  However you should not touch %'s that are not
903       plain characters, e.g.  environment variables for expansion should stay
904       intact: -o "C:\%HOMEPATH%\Desktop\%%(title)s.%%(ext)s".
905
906   Output template examples
907       Note  that on Windows you may need to use double quotes instead of sin‐
908       gle.
909
910              $ youtube-dl --get-filename -o '%(title)s.%(ext)s' BaW_jenozKc
911              youtube-dl test video ''_ä↭𝕐.mp4    # All kinds of weird characters
912
913              $ youtube-dl --get-filename -o '%(title)s.%(ext)s' BaW_jenozKc --restrict-filenames
914              youtube-dl_test_video_.mp4          # A simple file name
915
916              # Download YouTube playlist videos in separate directory indexed by video order in a playlist
917              $ youtube-dl -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re
918
919              # Download all playlists of YouTube channel/user keeping each playlist in separate directory:
920              $ youtube-dl -o '%(uploader)s/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' https://www.youtube.com/user/TheLinuxFoundation/playlists
921
922              # Download Udemy course keeping each chapter in separate directory under MyVideos directory in your home
923              $ 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/
924
925              # Download entire series season keeping each series and each season in separate directory under C:/MyVideos
926              $ 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
927
928              # Stream the video being downloaded to stdout
929              $ youtube-dl -o - BaW_jenozKc
930

FORMAT SELECTION

932       By default youtube-dl tries to download  the  best  available  quality,
933       i.e.   if  you want the best quality you don't need to pass any special
934       options, youtube-dl will guess it for you by default.
935
936       But sometimes you may want to download in a different format, for exam‐
937       ple  when you are on a slow or intermittent connection.  The key mecha‐
938       nism for achieving this is so-called format selection  based  on  which
939       you can explicitly specify desired format, select formats based on some
940       criterion or criteria, setup precedence and much more.
941
942       The general syntax for format selection is --format FORMAT  or  shorter
943       -f FORMAT  where  FORMAT  is a selector expression, i.e.  an expression
944       that describes format or formats you would like to download.
945
946       tl;dr: navigate me to examples.
947
948       The simplest case is requesting a specific  format,  for  example  with
949       -f 22  you  can  download the format with format code equal to 22.  You
950       can get the list of available format codes for particular  video  using
951       --list-formats  or -F.  Note that these format codes are extractor spe‐
952       cific.
953
954       You can also use a file extension (currently 3gp, aac, flv,  m4a,  mp3,
955       mp4,  ogg, wav, webm are supported) to download the best quality format
956       of a particular file extension served as a single file,  e.g.   -f webm
957       will download the best quality format with the webm extension served as
958       a single file.
959
960       You can also use special names to select particular edge case formats:
961
962       · best: Select the best quality format represented  by  a  single  file
963         with video and audio.
964
965       · worst:  Select  the worst quality format represented by a single file
966         with video and audio.
967
968       · bestvideo: Select the best  quality  video-only  format  (e.g.   DASH
969         video).  May not be available.
970
971       · worstvideo:  Select  the worst quality video-only format.  May not be
972         available.
973
974       · bestaudio: Select the best quality audio  only-format.   May  not  be
975         available.
976
977       · worstaudio:  Select  the worst quality audio only-format.  May not be
978         available.
979
980       For example, to download the worst quality video-only  format  you  can
981       use -f worstvideo.
982
983       If  you  want  to download multiple videos and they don't have the same
984       formats available, you can specify the order of preference using slash‐
985       es.   Note  that  slash  is left-associative, i.e.  formats on the left
986       hand side are preferred, for example -f 22/17/18 will  download  format
987       22  if  it's  available,  otherwise  it will download format 17 if it's
988       available, otherwise it will download format 18 if it's available, oth‐
989       erwise  it  will  complain  that  no suitable formats are available for
990       download.
991
992       If you want to download several formats of the same video use  a  comma
993       as  a  separator,  e.g.  -f 22,17,18 will download all these three for‐
994       mats, of course if they are available.  Or a more sophisticated example
995       combined          with          the         precedence         feature:
996       -f 136/137/mp4/bestvideo,140/m4a/bestaudio.
997
998       You can also filter the video formats by putting a condition in  brack‐
999       ets, as in -f "best[height=720]" (or -f "[filesize>10M]").
1000
1001       The  following  numeric meta fields can be used with comparisons <, <=,
1002       >, >=, = (equals), != (not equals):
1003
1004       · filesize: The number of bytes, if known in advance
1005
1006       · width: Width of the video, if known
1007
1008       · height: Height of the video, if known
1009
1010       · tbr: Average bitrate of audio and video in KBit/s
1011
1012       · abr: Average audio bitrate in KBit/s
1013
1014       · vbr: Average video bitrate in KBit/s
1015
1016       · asr: Audio sampling rate in Hertz
1017
1018       · fps: Frame rate
1019
1020       Also filtering work for comparisons = (equals), ^=  (starts  with),  $=
1021       (ends with), *= (contains) and following string meta fields:
1022
1023       · ext: File extension
1024
1025       · acodec: Name of the audio codec in use
1026
1027       · vcodec: Name of the video codec in use
1028
1029       · container: Name of the container format
1030
1031       · protocol:  The  protocol  that  will be used for the actual download,
1032         lower-case  (http,  https,  rtsp,  rtmp,  rtmpe,   mms,   f4m,   ism,
1033         http_dash_segments, m3u8, or m3u8_native)
1034
1035       · format_id: A short description of the format
1036
1037       · language: Language code
1038
1039       Any  string comparison may be prefixed with negation ! in order to pro‐
1040       duce an opposite comparison, e.g.  !*= (does not contain).
1041
1042       Note that none of the aforementioned meta fields are guaranteed  to  be
1043       present  since this solely depends on the metadata obtained by particu‐
1044       lar extractor, i.e.  the metadata offered by the video hoster.
1045
1046       Formats for which the value is not known are excluded unless you put  a
1047       question  mark (?) after the operator.  You can combine format filters,
1048       so -f "[height <=? 720][tbr>500]" selects up to 720p videos (or  videos
1049       where the height is not known) with a bitrate of at least 500 KBit/s.
1050
1051       You can merge the video and audio of two formats into a single file us‐
1052       ing -f <video-format>+<audio-format> (requires  ffmpeg  or  avconv  in‐
1053       stalled),  for  example  -f bestvideo+bestaudio  will download the best
1054       video-only format, the best audio-only format  and  mux  them  together
1055       with ffmpeg/avconv.
1056
1057       Format  selectors can also be grouped using parentheses, for example if
1058       you want to download the best mp4 and webm formats with a height  lower
1059       than 480 you can use -f '(mp4,webm)[height<480]'.
1060
1061       Since  the  end  of  April 2015 and version 2015.04.26, youtube-dl uses
1062       -f bestvideo+bestaudio/best as the default format selection (see  #5447
1063       (https://github.com/ytdl-org/youtube-dl/issues/5447),             #5456
1064       (https://github.com/ytdl-org/youtube-dl/issues/5456)).   If  ffmpeg  or
1065       avconv  are installed this results in downloading bestvideo and bestau‐
1066       dio separately and muxing them together into a single file  giving  the
1067       best  overall  quality  available.  Otherwise it falls back to best and
1068       results in downloading the best available quality served  as  a  single
1069       file.   best is also needed for videos that don't come from YouTube be‐
1070       cause they don't provide the audio and video in  two  different  files.
1071       If  you want to only download some DASH formats (for example if you are
1072       not interested in getting videos with a resolution higher than  1080p),
1073       you can add -f bestvideo[height<=?1080]+bestaudio/best to your configu‐
1074       ration file.  Note that if you use youtube-dl to stream to stdout  (and
1075       most likely to pipe it to your media player then), i.e.  you explicitly
1076       specify output template as -o -, youtube-dl still uses  -f best  format
1077       selection in order to start content delivery immediately to your player
1078       and not to wait until bestvideo and bestaudio are downloaded and muxed.
1079
1080       If you want to preserve the old format  selection  behavior  (prior  to
1081       youtube-dl  2015.04.26),  i.e.  you want to download the best available
1082       quality media served as a single file, you  should  explicitly  specify
1083       your  choice with -f best.  You may want to add it to the configuration
1084       file in order not to type it every time you run youtube-dl.
1085
1086   Format selection examples
1087       Note that on Windows you may need to use double quotes instead of  sin‐
1088       gle.
1089
1090              # Download best mp4 format available or any other best if no mp4 available
1091              $ youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best'
1092
1093              # Download best format available but no better than 480p
1094              $ youtube-dl -f 'bestvideo[height<=480]+bestaudio/best[height<=480]'
1095
1096              # Download best video only format but no bigger than 50 MB
1097              $ youtube-dl -f 'best[filesize<50M]'
1098
1099              # Download best format available via direct link over HTTP/HTTPS protocol
1100              $ youtube-dl -f '(bestvideo+bestaudio/best)[protocol^=http]'
1101
1102              # Download the best video format and the best audio format without merging them
1103              $ youtube-dl -f 'bestvideo,bestaudio' -o '%(title)s.f%(format_id)s.%(ext)s'
1104
1105       Note  that  in  the  last example, an output template is recommended as
1106       bestvideo and bestaudio may have the same file name.
1107

VIDEO SELECTION

1109       Videos can be filtered by their upload date using the  options  --date,
1110       --datebefore or --dateafter.  They accept dates in two formats:
1111
1112       · Absolute dates: Dates in the format YYYYMMDD.
1113
1114       · Relative      dates:     Dates     in     the     format     (now|to‐
1115         day)[+-][0-9](day|week|month|year)(s)?
1116
1117       Examples:
1118
1119              # Download only the videos uploaded in the last 6 months
1120              $ youtube-dl --dateafter now-6months
1121
1122              # Download only the videos uploaded on January 1, 1970
1123              $ youtube-dl --date 19700101
1124
1125              $ # Download only the videos uploaded in the 200x decade
1126              $ youtube-dl --dateafter 20000101 --datebefore 20091231
1127

FAQ

1129   How do I update youtube-dl?
1130       If you've followed our manual installation instructions  (https://ytdl-
1131       org.github.io/youtube-dl/download.html),    you    can    simply    run
1132       youtube-dl -U (or, on Linux, sudo youtube-dl -U).
1133
1134       If you have used pip, a simple sudo pip install -U youtube-dl is suffi‐
1135       cient to update.
1136
1137       If  you  have installed youtube-dl using a package manager like apt-get
1138       or yum, use the standard system update mechanism to update.  Note  that
1139       distribution  packages  are  often  outdated.   As  a  rule  of  thumb,
1140       youtube-dl releases at least once a month, and  often  weekly  or  even
1141       daily.  Simply go to https://yt-dl.org to find out the current version.
1142       Unfortunately, there is nothing we youtube-dl developers can do if your
1143       distribution  serves  a  really outdated version.  You can (and should)
1144       complain to your distribution in their bugtracker or support forum.
1145
1146       As a last resort, you can also uninstall the version installed by  your
1147       package  manager  and follow our manual installation instructions.  For
1148       that, remove the distribution's package, with a line like
1149
1150              sudo apt-get remove -y youtube-dl
1151
1152       Afterwards,  simply  follow  our   manual   installation   instructions
1153       (https://ytdl-org.github.io/youtube-dl/download.html):
1154
1155              sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
1156              sudo chmod a+rx /usr/local/bin/youtube-dl
1157              hash -r
1158
1159       Again, from then on you'll be able to update with sudo youtube-dl -U.
1160
1161   youtube-dl is extremely slow to start on Windows
1162       Add a file exclusion for youtube-dl.exe in Windows Defender settings.
1163
1164   I'm getting an error
1165       Unable to extract OpenGraph title on YouTube playlists
1166
1167       YouTube  changed  their  playlist format in March 2014 and later on, so
1168       you'll need at least youtube-dl  2014.07.25  to  download  all  YouTube
1169       videos.
1170
1171       If  you have installed youtube-dl with a package manager, pip, setup.py
1172       or a tarball, please use that to update.  Note that Ubuntu packages  do
1173       not  seem  to  get  updated  anymore.  Since we are not affiliated with
1174       Ubuntu,  there  is  little  we  can  do.   Feel  free  to  report  bugs
1175       (https://bugs.launchpad.net/ubuntu/+source/youtube-dl/+filebug)  to the
1176       Ubuntu   packaging   people   (mailto:ubuntu-motu@lists.ubuntu.com?sub‐
1177       ject=outdated%20version%20of%20youtube-dl) - all they have to do is up‐
1178       date the package to a somewhat recent version.  See above for a way  to
1179       update.
1180
1181   I'm getting an error when trying to use output template:
1182       error: using output template conflicts with using ti‐
1183       tle, video ID or auto number
1184
1185       Make sure you are not using -o with any of these options  -t,  --title,
1186       --id,  -A  or  --auto-number  set in command line or in a configuration
1187       file.  Remove the latter if any.
1188
1189   Do I always have to pass -citw?
1190       By default, youtube-dl intends to have the best options  (incidentally,
1191       if  you  have  a convincing case that these should be different, please
1192       file an issue where you explain that (https://yt-dl.org/bug)).   There‐
1193       fore,  it  is  unnecessary  and  sometimes  harmful to copy long option
1194       strings from webpages.  In particular, the only  option  out  of  -citw
1195       that is regularly useful is -i.
1196
1197   Can you please put the -b option back?
1198       Most  people asking this question are not aware that youtube-dl now de‐
1199       faults to downloading the highest  available  quality  as  reported  by
1200       YouTube,  which  will  be 1080p or 720p in some cases, so you no longer
1201       need the -b option.  For some specific videos, maybe YouTube  does  not
1202       report  them  to  be available in a specific high quality format you're
1203       interested in.  In that case, simply request it with the -f option  and
1204       youtube-dl will try to download it.
1205
1206   I get HTTP error 402 when trying to download a video. What's
1207       this?
1208
1209       Apparently  YouTube requires you to pass a CAPTCHA test if you download
1210       too much.  We're considering to provide a way  to  let  you  solve  the
1211       CAPTCHA (https://github.com/ytdl-org/youtube-dl/issues/154), but at the
1212       moment, your best course of action is pointing a  web  browser  to  the
1213       youtube URL, solving the CAPTCHA, and restart youtube-dl.
1214
1215   Do I need any other programs?
1216       youtube-dl  works  fine on its own on most sites.  However, if you want
1217       to convert video/audio, you'll need avconv (https://libav.org/) or ffm‐
1218       peg  (https://www.ffmpeg.org/).  On some sites - most notably YouTube -
1219       videos can be retrieved in  a  higher  quality  format  without  sound.
1220       youtube-dl  will  detect whether avconv/ffmpeg is present and automati‐
1221       cally pick the best option.
1222
1223       Videos or video formats streamed via RTMP protocol can  only  be  down‐
1224       loaded  when  rtmpdump  (https://rtmpdump.mplayerhq.hu/)  is installed.
1225       Downloading MMS and RTSP videos requires either mplayer (https://mplay
1226       erhq.hu/) or mpv (https://mpv.io/) to be installed.
1227
1228   I have downloaded a video but how can I play it?
1229       Once  the  video is fully downloaded, use any video player, such as mpv
1230       (https://mpv.io/),   vlc   (https://www.videolan.org/)    or    mplayer
1231       (https://www.mplayerhq.hu/).
1232
1233   I extracted a video URL with -g, but it does not play on
1234       another machine / in my web browser.
1235
1236       It depends a lot on the service.  In many cases, requests for the video
1237       (to download/play it) must come from the same IP address and  with  the
1238       same  cookies  and/or  HTTP headers.  Use the --cookies option to write
1239       the required cookies into a file, and advise your  downloader  to  read
1240       cookies from that file.  Some sites also require a common user agent to
1241       be used, use --dump-user-agent to see the one  in  use  by  youtube-dl.
1242       You  can  also  get necessary cookies and HTTP headers from JSON output
1243       obtained with --dump-json.
1244
1245       It may be beneficial to use IPv6; in some cases, the  restrictions  are
1246       only  applied  to  IPv4.  Some services (sometimes only for a subset of
1247       videos) do not restrict the video URL by IP  address,  cookie,  or  us‐
1248       er-agent, but these are the exception rather than the rule.
1249
1250       Please  bear  in  mind  that  some  URL  protocols are not supported by
1251       browsers out of the box, including RTMP.  If you are using -g, your own
1252       downloader must support these as well.
1253
1254       If  you  want  to  play  the  video  on  a  machine that is not running
1255       youtube-dl, you can relay the video content from the machine that  runs
1256       youtube-dl.   You can use -o - to let youtube-dl stream a video to std‐
1257       out, or simply allow the  player  to  download  the  files  written  by
1258       youtube-dl in turn.
1259
1260   ERROR: no fmt_url_map or conn information found in video info
1261       YouTube  has  switched to a new video info format in July 2011 which is
1262       not supported by old versions of youtube-dl.  See above for how to  up‐
1263       date youtube-dl.
1264
1265   ERROR: unable to download video
1266       YouTube  requires an additional signature since September 2012 which is
1267       not supported by old versions of youtube-dl.  See above for how to  up‐
1268       date youtube-dl.
1269
1270   Video URL contains an ampersand and I'm getting some strange
1271       output   [1] 2839   or   'v' is not recognized as an internal or exter‐
1272       nal command
1273
1274       That's actually the output from your shell.  Since ampersand is one  of
1275       the  special  shell characters it's interpreted by the shell preventing
1276       you from passing the whole URL to youtube-dl.  To  disable  your  shell
1277       from  interpreting the ampersands (or any other special characters) you
1278       have to either put the whole URL in quotes or escape them with a  back‐
1279       slash (which approach will work depends on your shell).
1280
1281       For          example          if          your          URL          is
1282       https://www.youtube.com/watch?t=4&v=BaW_jenozKc you should end up  with
1283       following command:
1284
1285       youtube-dl 'https://www.youtube.com/watch?t=4&v=BaW_jenozKc'
1286
1287       or
1288
1289       youtube-dl https://www.youtube.com/watch?t=4\&v=BaW_jenozKc
1290
1291       For Windows you have to use the double quotes:
1292
1293       youtube-dl "https://www.youtube.com/watch?t=4&v=BaW_jenozKc"
1294
1295   ExtractorError: Could not find JS function u'OF'
1296       In February 2015, the new YouTube player contained a character sequence
1297       in a string that was misinterpreted by old versions of youtube-dl.  See
1298       above for how to update youtube-dl.
1299
1300   HTTP Error 429: Too Many Requests or 402: Payment Required
1301       These two error codes indicate that the service is blocking your IP ad‐
1302       dress because of overuse.  Usually this is a soft  block  meaning  that
1303       you  can  gain access again after solving CAPTCHA.  Just open a browser
1304       and solve a CAPTCHA the service suggests you and after that pass  cook‐
1305       ies to youtube-dl.  Note that if your machine has multiple external IPs
1306       then you should also pass exactly the same IP you've used  for  solving
1307       CAPTCHA  with --source-address.  Also you may need to pass a User-Agent
1308       HTTP header of your browser with --user-agent.
1309
1310       If this is not the case (no CAPTCHA suggested to solve by the  service)
1311       then  you  can  contact the service and ask them to unblock your IP ad‐
1312       dress, or - if you have acquired a whitelisted IP address already - use
1313       the --proxy or --source-address options to select another IP address.
1314
1315   SyntaxError: Non-ASCII character
1316       The error
1317
1318              File "youtube-dl", line 2
1319              SyntaxError: Non-ASCII character '\x93' ...
1320
1321       means  you're  using  an  outdated version of Python.  Please update to
1322       Python 2.6 or 2.7.
1323
1324   What is this binary file? Where has the code gone?
1325       Since  June  2012   (#342   (https://github.com/ytdl-org/youtube-dl/is
1326       sues/342))  youtube-dl is packed as an executable zipfile, simply unzip
1327       it (might need renaming to youtube-dl.zip first  on  some  systems)  or
1328       clone  the  git repository, as laid out above.  If you modify the code,
1329       you can run it by executing the __main__.py file.  To recompile the ex‐
1330       ecutable, run make youtube-dl.
1331
1332   The exe throws an error due to missing MSVCR100.dll
1333       To  run the exe you need to install first the Microsoft Visual C++ 2010
1334       Redistributable  Package  (x86)  (https://www.microsoft.com/en-US/down
1335       load/details.aspx?id=5555).
1336
1337   On Windows, how should I set up ffmpeg and youtube-dl? Where should
1338       I put the exe files?
1339
1340       If you put youtube-dl and ffmpeg in the same directory that you're run‐
1341       ning the command from, it will work, but that's rather cumbersome.
1342
1343       To make a  different  directory  work  -  either  for  ffmpeg,  or  for
1344       youtube-dl,  or for both - simply create the directory (say, C:\bin, or
1345       C:\Users\<User name>\bin), put all the executables directly  in  there,
1346       and   then   set   your   PATH  environment  variable  (https://www.ja
1347       va.com/en/download/help/path.xml) to include that directory.
1348
1349       From then on, after restarting your shell, you will be able  to  access
1350       both youtube-dl and ffmpeg (and youtube-dl will be able to find ffmpeg)
1351       by simply typing youtube-dl or ffmpeg, no matter what directory  you're
1352       in.
1353
1354   How do I put downloads into a specific folder?
1355       Use  the  -o  to  specify an output template, for example -o "/home/us‐
1356       er/videos/%(title)s-%(id)s.%(ext)s".  If you want this for all of  your
1357       downloads, put the option into your configuration file.
1358
1359   How do I download a video starting with a -?
1360       Either prepend https://www.youtube.com/watch?v= or separate the ID from
1361       the options with --:
1362
1363              youtube-dl -- -wNyEUrxzFU
1364              youtube-dl "https://www.youtube.com/watch?v=-wNyEUrxzFU"
1365
1366   How do I pass cookies to youtube-dl?
1367       Use  the  --cookies  option,   for   example   --cookies /path/to/cook‐
1368       ies/file.txt.
1369
1370       In order to extract cookies from browser use any conforming browser ex‐
1371       tension  for  exporting  cookies.    For   example,   Get   cookies.txt
1372       (https://chrome.google.com/webstore/detail/get-cookiestxt/bgaddhkodda
1373       jcdgocldbbfleckgcbcid/)  (for  Chrome)  or   cookies.txt   (https://ad
1374       dons.mozilla.org/en-US/firefox/addon/cookies-txt/) (for Firefox).
1375
1376       Note  that  the cookies file must be in Mozilla/Netscape format and the
1377       first line of the cookies file must  be  either  # HTTP Cookie File  or
1378       # Netscape HTTP Cookie File.  Make sure you have correct newline format
1379       (https://en.wikipedia.org/wiki/Newline) in the cookies file and convert
1380       newlines  if  necessary  to correspond with your OS, namely CRLF (\r\n)
1381       for Windows and LF (\n) for Unix and Unix-like systems  (Linux,  macOS,
1382       etc.).  HTTP Error 400: Bad Request when using --cookies is a good sign
1383       of invalid newline format.
1384
1385       Passing cookies to youtube-dl is a good way to workaround login when  a
1386       particular  extractor  does  not  implement it explicitly.  Another use
1387       case is working around CAPTCHA  (https://en.wikipedia.org/wiki/CAPTCHA)
1388       some  websites require you to solve in particular cases in order to get
1389       access (e.g.  YouTube, CloudFlare).
1390
1391   How do I stream directly to media player?
1392       You will first need to tell youtube-dl to stream media to  stdout  with
1393       -o -,  and  also  tell your media player to read from stdin (it must be
1394       capable of this for streaming) and then pipe former to latter.  For ex‐
1395       ample,  streaming  to  vlc  (https://www.videolan.org/) can be achieved
1396       with:
1397
1398              youtube-dl -o - "https://www.youtube.com/watch?v=BaW_jenozKcj" | vlc -
1399
1400   How do I download only new videos from a playlist?
1401       Use download-archive feature.  With this feature you  should  initially
1402       download  the  complete playlist with --download-archive /path/to/down‐
1403       load/archive/file.txt that will record identifiers of all the videos in
1404       a  special  file.  Each subsequent run with the same --download-archive
1405       will download only new videos and skip all videos that have been  down‐
1406       loaded before.  Note that only successful downloads are recorded in the
1407       file.
1408
1409       For example, at first,
1410
1411              youtube-dl --download-archive archive.txt "https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re"
1412
1413       will download the complete PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re  playlist
1414       and  create a file archive.txt.  Each subsequent run will only download
1415       new videos if any:
1416
1417              youtube-dl --download-archive archive.txt "https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re"
1418
1419   Should I add --hls-prefer-native into my config?
1420       When youtube-dl detects an HLS video, it can download  it  either  with
1421       the built-in downloader or ffmpeg.  Since many HLS streams are slightly
1422       invalid and ffmpeg/youtube-dl each handle  some  invalid  cases  better
1423       than the other, there is an option to switch the downloader if needed.
1424
1425       When youtube-dl knows that one particular downloader works better for a
1426       given website, that downloader will be picked.   Otherwise,  youtube-dl
1427       will  pick  the best downloader for general compatibility, which at the
1428       moment happens to be ffmpeg.  This choice may change in future versions
1429       of youtube-dl, with improvements of the built-in downloader and/or ffm‐
1430       peg.
1431
1432       In particular, the generic extractor (used when your website is not  in
1433       the    list   of   supported   sites   by   youtube-dl   (https://ytdl-
1434       org.github.io/youtube-dl/supportedsites.html) cannot mandate  one  spe‐
1435       cific downloader.
1436
1437       If  you put either --hls-prefer-native or --hls-prefer-ffmpeg into your
1438       configuration, a different subset of videos will fail to download  cor‐
1439       rectly.   Instead,  it  is  much  better  to file an issue (https://yt-
1440       dl.org/bug) or a pull request which details why the native or the  ffm‐
1441       peg HLS downloader is a better choice for your use case.
1442
1443   Can you add support for this anime video site, or site which shows
1444       current movies for free?
1445
1446       As  a  matter  of policy (as well as legality), youtube-dl does not in‐
1447       clude support for services that specialize in infringing copyright.  As
1448       a  rule of thumb, if you cannot easily find a video that the service is
1449       quite obviously allowed to distribute (i.e.  that has been uploaded  by
1450       the  creator,  the  creator's distributor, or is published under a free
1451       license), the service is probably unfit for inclusion to youtube-dl.
1452
1453       A note on the service that they don't host the infringing content,  but
1454       just  link  to those who do, is evidence that the service should not be
1455       included into youtube-dl.  The same goes for any  DMCA  note  when  the
1456       whole  front page of the service is filled with videos they are not al‐
1457       lowed to distribute.  A "fair use" note is equally unconvincing if  the
1458       service shows copyright-protected videos in full without authorization.
1459
1460       Support requests for services that do purchase the rights to distribute
1461       their content are perfectly fine though.  If in doubt, you  can  simply
1462       include a source that mentions the legitimate purchase of content.
1463
1464   How can I speed up work on my issue?
1465       (Also  known  as:  Help,  my  important  issue  not  being solved!) The
1466       youtube-dl core developer team is quite small.  While we do our best to
1467       solve  as  many  issues  as  possible,  sometimes that can take quite a
1468       while.  To speed up your issue, here's what you can do:
1469
1470       First of  all,  please  do  report  the  issue  at  our  issue  tracker
1471       (https://yt-dl.org/bugs).   That allows us to coordinate all efforts by
1472       users and developers, and serves as a  unified  point.   Unfortunately,
1473       the  youtube-dl project has grown too large to use personal email as an
1474       effective communication channel.
1475
1476       Please read the bug reporting instructions below.  A lot of  bugs  lack
1477       all  the necessary information.  If you can, offer proxy, VPN, or shell
1478       access to the youtube-dl developers.  If you are able to, test the  is‐
1479       sue from multiple computers in multiple countries to exclude local cen‐
1480       sorship or misconfiguration issues.
1481
1482       If nobody is interested in solving your issue, you are welcome to  take
1483       matters  into  your  own hands and submit a pull request (or coerce/pay
1484       somebody else to do so).
1485
1486       Feel free to bump the issue from time to time by writing a  small  com‐
1487       ment ("Issue is still present in youtube-dl version ...from France, but
1488       fixed from Belgium"), but please not more than once a month.  Please do
1489       not declare your issue as important or urgent.
1490
1491   How can I detect whether a given URL is supported by youtube-dl?
1492       For  one,  have  a look at the list of supported sites (docs/supported‐
1493       sites.md).  Note that it can sometimes happen that the site changes its
1494       URL  scheme (say, from https://example.com/video/1234567 to https://ex
1495       ample.com/v/1234567 ) and youtube-dl reports an URL  of  a  service  in
1496       that list as unsupported.  In that case, simply report a bug.
1497
1498       It is not possible to detect whether a URL is supported or not.  That's
1499       because youtube-dl contains a generic extractor which matches all URLs.
1500       You  may  be tempted to disable, exclude, or remove the generic extrac‐
1501       tor, but the generic extractor not only allows users to extract  videos
1502       from  lots of websites that embed a video from another service, but may
1503       also be used to extract video from a service that it's hosting  itself.
1504       Therefore,  we  neither  recommend nor support disabling, excluding, or
1505       removing the generic extractor.
1506
1507       If you want to find out whether a given URL is supported,  simply  call
1508       youtube-dl  with it.  If you get no videos back, chances are the URL is
1509       either not referring to a video or unsupported.  You can find out which
1510       by  examining  the  output  (if  you  run youtube-dl on the console) or
1511       catching an UnsupportedError exception if you run it from a Python pro‐
1512       gram.
1513

Why do I need to go through that much red tape when filing bugs?

1515       Before  we  had the issue template, despite our extensive bug reporting
1516       instructions, about 80% of the issue reports we got were  useless,  for
1517       instance because people used ancient versions hundreds of releases old,
1518       because of simple syntactic errors (not in youtube-dl  but  in  general
1519       shell  usage),  because the problem was already reported multiple times
1520       before, because people did not actually read an error message, even  if
1521       it said "please install ffmpeg", because people did not mention the URL
1522       they were trying to download and many more simple, easy-to-avoid  prob‐
1523       lems, many of whom were totally unrelated to youtube-dl.
1524
1525       youtube-dl  is  an open-source project manned by too few volunteers, so
1526       we'd rather spend time fixing bugs where we are certain none  of  those
1527       simple  problems  apply, and where we can be reasonably confident to be
1528       able to reproduce the issue without asking the reporter repeatedly.  As
1529       such,  the  output  of youtube-dl -v YOUR_URL_HERE is really all that's
1530       required to file an issue.  The issue template also guides you  through
1531       some  basic  steps  you  can  do, such as checking that your version of
1532       youtube-dl is current.
1533

DEVELOPER INSTRUCTIONS

1535       Most users do not need to build youtube-dl and can download the  builds
1536       (https://ytdl-org.github.io/youtube-dl/download.html)  or get them from
1537       their distribution.
1538
1539       To run youtube-dl as a developer, you don't need to build anything  ei‐
1540       ther.  Simply execute
1541
1542              python -m youtube_dl
1543
1544       To  run the test, simply invoke your favorite test runner, or execute a
1545       test file directly; any of the following work:
1546
1547              python -m unittest discover
1548              python test/test_download.py
1549              nosetests
1550
1551       See item 6 of new extractor tutorial for how to run extractor  specific
1552       test cases.
1553
1554       If you want to create a build of youtube-dl yourself, you'll need
1555
1556       · python
1557
1558       · make (only GNU make is supported)
1559
1560       · pandoc
1561
1562       · zip
1563
1564       · nosetests
1565
1566   Adding support for a new site
1567       If  you want to add support for a new site, first of all make sure this
1568       site is not dedicated to copyright infringement (README.md#can-you-add-
1569       support-for-this-anime-video-site-or-site-which-shows-current-movies-
1570       for-free).  youtube-dl does not support such sites thus  pull  requests
1571       adding support for them will be rejected.
1572
1573       After  you  have ensured this site is distributing its content legally,
1574       you can follow this quick list (assuming your service is called yourex‐
1575       tractor):
1576
1577        1. Fork this repository (https://github.com/ytdl-org/youtube-dl/fork)
1578
1579        2. Check out the source code with:
1580
1581                   git clone git@github.com:YOUR_GITHUB_USERNAME/youtube-dl.git
1582
1583        3. Start a new git branch with
1584
1585                   cd youtube-dl
1586                   git checkout -b yourextractor
1587
1588        4. Start  with  this simple template and save it to youtube_dl/extrac‐
1589           tor/yourextractor.py:
1590
1591                  # coding: utf-8
1592                  from __future__ import unicode_literals
1593
1594                  from .common import InfoExtractor
1595
1596
1597                  class YourExtractorIE(InfoExtractor):
1598                      _VALID_URL = r'https?://(?:www\.)?yourextractor\.com/watch/(?P<id>[0-9]+)'
1599                      _TEST = {
1600                          'url': 'https://yourextractor.com/watch/42',
1601                          'md5': 'TODO: md5 sum of the first 10241 bytes of the video file (use --test)',
1602                          'info_dict': {
1603                              'id': '42',
1604                              'ext': 'mp4',
1605                              'title': 'Video title goes here',
1606                              'thumbnail': r're:^https?://.*\.jpg$',
1607                              # TODO more properties, either as:
1608                              # * A value
1609                              # * MD5 checksum; start the string with md5:
1610                              # * A regular expression; start the string with re:
1611                              # * Any Python type (for example int or float)
1612                          }
1613                      }
1614
1615                      def _real_extract(self, url):
1616                          video_id = self._match_id(url)
1617                          webpage = self._download_webpage(url, video_id)
1618
1619                          # TODO more code goes here, for example ...
1620                          title = self._html_search_regex(r'<h1>(.+?)</h1>', webpage, 'title')
1621
1622                          return {
1623                              'id': video_id,
1624                              'title': title,
1625                              'description': self._og_search_description(webpage),
1626                              'uploader': self._search_regex(r'<div[^>]+id="uploader"[^>]*>([^<]+)<', webpage, 'uploader', fatal=False),
1627                              # TODO more properties (see youtube_dl/extractor/common.py)
1628                          }
1629
1630        5. Add     an     import     in     youtube_dl/extractor/extractors.py
1631           (https://github.com/ytdl-org/youtube-dl/blob/master/youtube_dl/ex
1632           tractor/extractors.py).
1633
1634        6. Run   python test/test_download.py TestDownload.test_YourExtractor.
1635           This  should fail at first, but you can continually re-run it until
1636           you're done.  If you decide to add more than one test, then  rename
1637           _TEST to _TESTS and make it into a list of dictionaries.  The tests
1638           will  then  be  named  TestDownload.test_YourExtractor,   TestDown‐
1639           load.test_YourExtractor_1,  TestDownload.test_YourExtractor_2, etc.
1640           Note that tests with only_matching  key  in  test's  dict  are  not
1641           counted in.
1642
1643        7. Have       a       look      at      youtube_dl/extractor/common.py
1644           (https://github.com/ytdl-org/youtube-dl/blob/master/youtube_dl/ex
1645           tractor/common.py)  for  possible helper methods and a detailed de‐
1646           scription  of  what  your   extractor   should   and   may   return
1647           (https://github.com/ytdl-org/youtube-
1648           dl/blob/7f41a598b3fba1bcab2817de64a08941200aa3c8/youtube_dl/extrac‐
1649           tor/common.py#L94-L303).   Add  tests  and  code for as many as you
1650           want.
1651
1652        8. Make sure your code follows youtube-dl coding conventions and check
1653           the   code   with   flake8  (https://flake8.pycqa.org/en/latest/in
1654           dex.html#quickstart):
1655
1656                   $ flake8 youtube_dl/extractor/yourextractor.py
1657
1658        9. Make    sure    your    code     works     under     all     Python
1659           (https://www.python.org/) versions claimed supported by youtube-dl,
1660           namely 2.6, 2.7, and 3.2+.
1661
1662       10. When the tests pass, add (https://git-scm.com/docs/git-add) the new
1663           files  and  commit  (https://git-scm.com/docs/git-commit)  them and
1664           push (https://git-scm.com/docs/git-push) the result, like this:
1665
1666                  $ git add youtube_dl/extractor/extractors.py
1667                  $ git add youtube_dl/extractor/yourextractor.py
1668                  $ git commit -m '[yourextractor] Add new extractor'
1669                  $ git push origin yourextractor
1670
1671       11. Finally,  create  a  pull  request   (https://help.github.com/arti
1672           cles/creating-a-pull-request).  We'll then review and merge it.
1673
1674       In any case, thank you very much for your contributions!
1675
1676   youtube-dl coding conventions
1677       This section introduces a guide lines for writing idiomatic, robust and
1678       future-proof extractor code.
1679
1680       Extractors are very fragile by nature since they depend on  the  layout
1681       of the source data provided by 3rd party media hosters out of your con‐
1682       trol and this layout tends to change.  As an extractor implementer your
1683       task  is not only to write code that will extract media links and meta‐
1684       data correctly but also to minimize dependency on the  source's  layout
1685       and even to make the code foresee potential future changes and be ready
1686       for that.  This is important because it will allow the extractor not to
1687       break  on  minor  layout  changes  thus keeping old youtube-dl versions
1688       working.  Even though this breakage issue is easily fixed by emitting a
1689       new  version  of  youtube-dl  with a fix incorporated, all the previous
1690       versions become broken in all repositories and distros'  packages  that
1691       may  not be so prompt in fetching the update from us.  Needless to say,
1692       some non rolling release distros may never receive an update at all.
1693
1694   Mandatory and optional metafields
1695       For extraction to work youtube-dl relies on metadata your extractor ex‐
1696       tracts  and  provides to youtube-dl expressed by an information dictio‐
1697       nary                              (https://github.com/ytdl-org/youtube-
1698       dl/blob/7f41a598b3fba1bcab2817de64a08941200aa3c8/youtube_dl/extrac‐
1699       tor/common.py#L94-L303) or simply info dict.  Only the  following  meta
1700       fields  in  the info dict are considered mandatory for a successful ex‐
1701       traction process by youtube-dl:
1702
1703       · id (media identifier)
1704
1705       · title (media title)
1706
1707       · url (media download URL) or formats
1708
1709       In fact only the last option is technically  mandatory  (i.e.   if  you
1710       can't figure out the download location of the media the extraction does
1711       not make any sense).  But by convention youtube-dl also treats  id  and
1712       title  as mandatory.  Thus the aforementioned metafields are the criti‐
1713       cal data that the extraction does not make any sense without and if any
1714       of them fail to be extracted then the extractor is considered complete‐
1715       ly broken.
1716
1717       Any             field             (https://github.com/ytdl-org/youtube-
1718       dl/blob/7f41a598b3fba1bcab2817de64a08941200aa3c8/youtube_dl/extrac‐
1719       tor/common.py#L188-L303) apart from the aforementioned ones are consid‐
1720       ered optional.  That means that extraction should be tolerant to situa‐
1721       tions when sources for these  fields  can  potentially  be  unavailable
1722       (even  if  they are always available at the moment) and future-proof in
1723       order not to break the extraction of general purpose mandatory fields.
1724
1725   Example
1726       Say you have some source dictionary meta that you've  fetched  as  JSON
1727       with HTTP request and it has a key summary:
1728
1729              meta = self._download_json(url, video_id)
1730
1731       Assume at this point meta's layout is:
1732
1733              {
1734                  ...
1735                  "summary": "some fancy summary text",
1736                  ...
1737              }
1738
1739       Assume  you  want to extract summary and put it into the resulting info
1740       dict as description.  Since description is an optional meta  field  you
1741       should  be  ready  that  this key may be missing from the meta dict, so
1742       that you should extract it like:
1743
1744              description = meta.get('summary')  # correct
1745
1746       and not like:
1747
1748              description = meta['summary']  # incorrect
1749
1750       The latter will break extraction process with KeyError if summary  dis‐
1751       appears  from  meta at some later time but with the former approach ex‐
1752       traction will just go ahead with description set to None which is  per‐
1753       fectly fine (remember None is equivalent to the absence of data).
1754
1755       Similarly,  you  should  pass fatal=False when extracting optional data
1756       from a webpage with _search_regex, _html_search_regex or similar  meth‐
1757       ods, for instance:
1758
1759              description = self._search_regex(
1760                  r'<span[^>]+id="title"[^>]*>([^<]+)<',
1761                  webpage, 'description', fatal=False)
1762
1763       With  fatal  set to False if _search_regex fails to extract description
1764       it will emit a warning and continue extraction.
1765
1766       You can also pass default=<some fallback value>, for example:
1767
1768              description = self._search_regex(
1769                  r'<span[^>]+id="title"[^>]*>([^<]+)<',
1770                  webpage, 'description', default=None)
1771
1772       On failure this code will silently continue  the  extraction  with  de‐
1773       scription  set  to None.  That is useful for metafields that may or may
1774       not be present.
1775
1776   Provide fallbacks
1777       When extracting metadata try to do so from multiple sources.  For exam‐
1778       ple if title is present in several places, try extracting from at least
1779       some of them.  This makes it more future-proof  in  case  some  of  the
1780       sources become unavailable.
1781
1782   Example
1783       Say meta from the previous example has a title and you are about to ex‐
1784       tract it.  Since title is a mandatory meta field you should end up with
1785       something like:
1786
1787              title = meta['title']
1788
1789       If  title  disappears  from  meta  in future due to some changes on the
1790       hoster's side the extraction  would  fail  since  title  is  mandatory.
1791       That's expected.
1792
1793       Assume  that  you  have some another source you can extract title from,
1794       for example og:title HTML meta of a webpage.  In this case you can pro‐
1795       vide a fallback scenario:
1796
1797              title = meta.get('title') or self._og_search_title(webpage)
1798
1799       This  code  will try to extract from meta first and if it fails it will
1800       try extracting og:title from a webpage.
1801
1802   Regular expressions
1803   Don't capture groups you don't use
1804       Capturing group must be an indication that it's used somewhere  in  the
1805       code.  Any group that is not used must be non capturing.
1806
1807   Example
1808       Don't  capture  id  attribute name here since you can't use it for any‐
1809       thing anyway.
1810
1811       Correct:
1812
1813              r'(?:id|ID)=(?P<id>\d+)'
1814
1815       Incorrect:
1816
1817              r'(id|ID)=(?P<id>\d+)'
1818
1819   Make regular expressions relaxed and flexible
1820       When using regular expressions try to write  them  fuzzy,  relaxed  and
1821       flexible,  skipping insignificant parts that are more likely to change,
1822       allowing both single and double quotes for quoted values and so on.
1823
1824   Example
1825       Say you need to extract title from the following HTML code:
1826
1827              <span style="position: absolute; left: 910px; width: 90px; float: right; z-index: 9999;" class="title">some fancy title</span>
1828
1829       The code for that task should look similar to:
1830
1831              title = self._search_regex(
1832                  r'<span[^>]+class="title"[^>]*>([^<]+)', webpage, 'title')
1833
1834       Or even better:
1835
1836              title = self._search_regex(
1837                  r'<span[^>]+class=(["\'])title\1[^>]*>(?P<title>[^<]+)',
1838                  webpage, 'title', group='title')
1839
1840       Note how you tolerate potential changes in the style attribute's  value
1841       or switch from using double quotes to single for class attribute:
1842
1843       The code definitely should not look like:
1844
1845              title = self._search_regex(
1846                  r'<span style="position: absolute; left: 910px; width: 90px; float: right; z-index: 9999;" class="title">(.*?)</span>',
1847                  webpage, 'title', group='title')
1848
1849   Long lines policy
1850       There  is  a soft limit to keep lines of code under 80 characters long.
1851       This means it should be respected if possible and if it does  not  make
1852       readability and code maintenance worse.
1853
1854       For  example,  you should never split long string literals like URLs or
1855       some other often copied entities over multiple lines to fit this limit:
1856
1857       Correct:
1858
1859              'https://www.youtube.com/watch?v=FqZTN594JQw&list=PLMYEtVRpaqY00V9W81Cwmzp6N6vZqfUKD4'
1860
1861       Incorrect:
1862
1863              'https://www.youtube.com/watch?v=FqZTN594JQw&list='
1864              'PLMYEtVRpaqY00V9W81Cwmzp6N6vZqfUKD4'
1865
1866   Inline values
1867       Extracting variables is acceptable for reducing  code  duplication  and
1868       improving  readability  of  complex  expressions.   However, you should
1869       avoid extracting variables used only once and moving them  to  opposite
1870       parts of the extractor file, which makes reading the linear flow diffi‐
1871       cult.
1872
1873   Example
1874       Correct:
1875
1876              title = self._html_search_regex(r'<title>([^<]+)</title>', webpage, 'title')
1877
1878       Incorrect:
1879
1880              TITLE_RE = r'<title>([^<]+)</title>'
1881              # ...some lines of code...
1882              title = self._html_search_regex(TITLE_RE, webpage, 'title')
1883
1884   Collapse fallbacks
1885       Multiple fallback values can quickly become unwieldy.  Collapse  multi‐
1886       ple fallback values into a single expression via a list of patterns.
1887
1888   Example
1889       Good:
1890
1891              description = self._html_search_meta(
1892                  ['og:description', 'description', 'twitter:description'],
1893                  webpage, 'description', default=None)
1894
1895       Unwieldy:
1896
1897              description = (
1898                  self._og_search_description(webpage, default=None)
1899                  or self._html_search_meta('description', webpage, default=None)
1900                  or self._html_search_meta('twitter:description', webpage, default=None))
1901
1902       Methods    supporting    list    of    patterns   are:   _search_regex,
1903       _html_search_regex, _og_search_property, _html_search_meta.
1904
1905   Trailing parentheses
1906       Always move trailing parentheses after the last argument.
1907
1908   Example
1909       Correct:
1910
1911                  lambda x: x['ResultSet']['Result'][0]['VideoUrlSet']['VideoUrl'],
1912                  list)
1913
1914       Incorrect:
1915
1916                  lambda x: x['ResultSet']['Result'][0]['VideoUrlSet']['VideoUrl'],
1917                  list,
1918              )
1919
1920   Use convenience conversion and parsing functions
1921       Wrap  all   extracted   numeric   data   into   safe   functions   from
1922       youtube_dl/utils.py   (https://github.com/ytdl-org/youtube-dl/blob/mas
1923       ter/youtube_dl/utils.py): int_or_none,  float_or_none.   Use  them  for
1924       string to number conversions as well.
1925
1926       Use url_or_none for safe URL processing.
1927
1928       Use try_get for safe metadata extraction from parsed JSON.
1929
1930       Use  unified_strdate for uniform upload_date or any YYYYMMDD meta field
1931       extraction,  unified_timestamp  for   uniform   timestamp   extraction,
1932       parse_filesize  for  filesize  extraction,  parse_count  for count meta
1933       fields extraction, parse_resolution, parse_duration  for  duration  ex‐
1934       traction, parse_age_limit for age_limit extraction.
1935
1936       Explore    youtube_dl/utils.py    (https://github.com/ytdl-org/youtube-
1937       dl/blob/master/youtube_dl/utils.py) for more useful  convenience  func‐
1938       tions.
1939
1940   More examples
1941   Safely extract optional description from parsed JSON
1942              description = try_get(response, lambda x: x['result']['video'][0]['summary'], compat_str)
1943
1944   Safely extract more optional metadata
1945              video = try_get(response, lambda x: x['result']['video'][0], dict) or {}
1946              description = video.get('summary')
1947              duration = float_or_none(video.get('durationMs'), scale=1000)
1948              view_count = int_or_none(video.get('views'))
1949

EMBEDDING YOUTUBE-DL

1951       youtube-dl makes the best effort to be a good command-line program, and
1952       thus should be callable from any  programming  language.   If  you  en‐
1953       counter  any  problems parsing its output, feel free to create a report
1954       (https://github.com/ytdl-org/youtube-dl/issues/new).
1955
1956       From a Python program, you can embed  youtube-dl  in  a  more  powerful
1957       fashion, like this:
1958
1959              from __future__ import unicode_literals
1960              import youtube_dl
1961
1962              ydl_opts = {}
1963              with youtube_dl.YoutubeDL(ydl_opts) as ydl:
1964                  ydl.download(['https://www.youtube.com/watch?v=BaW_jenozKc'])
1965
1966       Most likely, you'll want to use various options.  For a list of options
1967       available,     have     a     look      at      youtube_dl/YoutubeDL.py
1968       (https://github.com/ytdl-org/youtube-
1969       dl/blob/3e4cedf9e8cd3157df2457df7274d0c842421945/youtube_dl/YoutubeDL.py#L137-L312).
1970       For a start, if you want to intercept youtube-dl's output, set a logger
1971       object.
1972
1973       Here's a more complete example of a program that  outputs  only  errors
1974       (and  a  short  message  after  the  download  is  finished), and down‐
1975       loads/converts the video to an mp3 file:
1976
1977              from __future__ import unicode_literals
1978              import youtube_dl
1979
1980
1981              class MyLogger(object):
1982                  def debug(self, msg):
1983                      pass
1984
1985                  def warning(self, msg):
1986                      pass
1987
1988                  def error(self, msg):
1989                      print(msg)
1990
1991
1992              def my_hook(d):
1993                  if d['status'] == 'finished':
1994                      print('Done downloading, now converting ...')
1995
1996
1997              ydl_opts = {
1998                  'format': 'bestaudio/best',
1999                  'postprocessors': [{
2000                      'key': 'FFmpegExtractAudio',
2001                      'preferredcodec': 'mp3',
2002                      'preferredquality': '192',
2003                  }],
2004                  'logger': MyLogger(),
2005                  'progress_hooks': [my_hook],
2006              }
2007              with youtube_dl.YoutubeDL(ydl_opts) as ydl:
2008                  ydl.download(['https://www.youtube.com/watch?v=BaW_jenozKc'])
2009

BUGS

2011       Bugs and suggestions should be reported  at:  <https://github.com/ytdl-
2012       org/youtube-dl/issues>.  Unless you were prompted to or there is anoth‐
2013       er pertinent reason (e.g.  GitHub fails  to  accept  the  bug  report),
2014       please  do  not  send bug reports via personal email.  For discussions,
2015       join   us   in   the   IRC   channel   #youtube-dl   (irc://chat.freen‐
2016       ode.net/#youtube-dl)   on   freenode  (webchat  (https://webchat.freen
2017       ode.net/?randomnick=1&channels=youtube-dl)).
2018
2019       Please include the full output of youtube-dl when  run  with  -v,  i.e.
2020       add  -v flag to your command line, copy the whole output and post it in
2021       the issue body wrapped in ``` for better formatting.   It  should  look
2022       similar to this:
2023
2024              $ youtube-dl -v <your command line>
2025              [debug] System config: []
2026              [debug] User config: []
2027              [debug] Command-line args: [u'-v', u'https://www.youtube.com/watch?v=BaW_jenozKcj']
2028              [debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251
2029              [debug] youtube-dl version 2015.12.06
2030              [debug] Git HEAD: 135392e
2031              [debug] Python version 2.6.6 - Windows-2003Server-5.2.3790-SP2
2032              [debug] exe versions: ffmpeg N-75573-g1d0487f, ffprobe N-75573-g1d0487f, rtmpdump 2.4
2033              [debug] Proxy map: {}
2034              ...
2035
2036       Do not post screenshots of verbose logs; only plain text is acceptable.
2037
2038       The output (including the first lines) contains important debugging in‐
2039       formation.  Issues without the full output are often  not  reproducible
2040       and therefore do not get solved in short order, if ever.
2041
2042       Please  re-read  your issue once again to avoid a couple of common mis‐
2043       takes (you can and should use this as a checklist):
2044
2045   Is the description of the issue itself sufficient?
2046       We often get issue reports that we cannot really  decipher.   While  in
2047       most cases we eventually get the required information after asking back
2048       multiple times, this poses an unnecessary drain on our resources.  Many
2049       contributors, including myself, are also not native speakers, so we may
2050       misread some parts.
2051
2052       So please elaborate on what feature you are requesting, or what bug you
2053       want to be fixed.  Make sure that it's obvious
2054
2055       · What the problem is
2056
2057       · How it could be fixed
2058
2059       · How your proposed solution would look like
2060
2061       If  your report is shorter than two lines, it is almost certainly miss‐
2062       ing some of these, which makes it hard for us to respond to it.   We're
2063       often  too  polite  to  close  the issue outright, but the missing info
2064       makes misinterpretation likely.  As a committer  myself,  I  often  get
2065       frustrated  by these issues, since the only possible way for me to move
2066       forward on them is to ask for clarification over and over.
2067
2068       For bug reports, this means that your report should  contain  the  com‐
2069       plete  output  of  youtube-dl  when called with the -v flag.  The error
2070       message you get for (most) bugs even says so, but you would not believe
2071       how many of our bug reports do not contain this information.
2072
2073       If  your  server  has  multiple  IPs  or you suspect censorship, adding
2074       --call-home may be a good idea to get more diagnostics.  If  the  error
2075       is ERROR: Unable to extract ... and you cannot reproduce it from multi‐
2076       ple countries, add --dump-pages (warning:  this  will  yield  a  rather
2077       large  output,  redirect it to the file log.txt by adding >log.txt 2>&1
2078       to your command-line) or upload the .dump files you get  when  you  add
2079       --write-pages somewhere (https://gist.github.com/).
2080
2081       Site support requests must contain an example URL.  An example URL is a
2082       URL      you       might       want       to       download,       like
2083       https://www.youtube.com/watch?v=BaW_jenozKc.   There should be an obvi‐
2084       ous video present.  Except under very special circumstances,  the  main
2085       page  of a video service (e.g.  https://www.youtube.com/) is not an ex‐
2086       ample URL.
2087
2088   Are you using the latest version?
2089       Before reporting any issue, type  youtube-dl -U.   This  should  report
2090       that  you're  up-to-date.   About 20% of the reports we receive are al‐
2091       ready fixed, but people are using outdated  versions.   This  goes  for
2092       feature requests as well.
2093
2094   Is the issue already documented?
2095       Make  sure  that someone has not already opened the issue you're trying
2096       to open.  Search at the top of the window or browse the  GitHub  Issues
2097       (https://github.com/ytdl-org/youtube-dl/search?type=Issues)   of   this
2098       repository.  If there is an issue, feel free to write  something  along
2099       the  lines  of "This affects me as well, with version 2015.01.01.  Here
2100       is some more information on the issue: ...".  While some issues may  be
2101       old, a new post into them often spurs rapid activity.
2102
2103   Why are existing options not enough?
2104       Before  requesting  a new feature, please have a quick peek at the list
2105       of supported options  (https://github.com/ytdl-org/youtube-dl/blob/mas
2106       ter/README.md#options).   Many  feature  requests are for features that
2107       actually exist already!  Please, absolutely do show off  your  work  in
2108       the  issue  report  and  detail how the existing similar options do not
2109       solve your problem.
2110
2111   Is there enough context in your bug report?
2112       People want to solve problems, and often think they do us  a  favor  by
2113       breaking  down  their  larger  problems  (e.g.  wanting to skip already
2114       downloaded files) to a specific request (e.g.  requesting  us  to  look
2115       whether  the  file  exists before downloading the info page).  However,
2116       what often happens is that they break down the problem into two  steps:
2117       One simple, and one impossible (or extremely complicated one).
2118
2119       We are then presented with a very complicated request when the original
2120       problem could be solved far easier, e.g.  by recording  the  downloaded
2121       video  IDs  in  a  separate  file.  To avoid this, you must include the
2122       greater context where it is non-obvious.  In particular, every  feature
2123       request  that  does not consist of adding support for a new site should
2124       contain a use case scenario that explains in what situation the missing
2125       feature would be useful.
2126
2127   Does the issue involve one problem, and one problem only?
2128       Some  of our users seem to think there is a limit of issues they can or
2129       should open.  There is no limit of issues  they  can  or  should  open.
2130       While it may seem appealing to be able to dump all your issues into one
2131       ticket, that means that someone who solves one of  your  issues  cannot
2132       mark the issue as closed.  Typically, reporting a bunch of issues leads
2133       to the ticket lingering since nobody wants to attack that behemoth, un‐
2134       til someone mercifully splits the issue into multiple ones.
2135
2136       In  particular, every site support request issue should only pertain to
2137       services at one site (generally under a common domain, but always using
2138       the  same  backend  technology).  Do not request support for vimeo user
2139       videos, White house podcasts, and Google Plus pages in the same  issue.
2140       Also,  make  sure that you don't post bug reports alongside feature re‐
2141       quests.  As a rule of thumb, a feature request does not include outputs
2142       of  youtube-dl that are not immediately related to the feature at hand.
2143       Do not post reports of a network error alongside the request for a  new
2144       video service.
2145
2146   Is anyone going to need the feature?
2147       Only post features that you (or an incapacitated friend you can person‐
2148       ally talk to) require.  Do not post features because they seem  like  a
2149       good  idea.  If they are really useful, they will be requested by some‐
2150       one who requires them.
2151
2152   Is your question about youtube-dl?
2153       It may sound strange, but some bug reports we  receive  are  completely
2154       unrelated  to  youtube-dl  and  relate  to a different, or even the re‐
2155       porter's own, application.  Please make sure that you are actually  us‐
2156       ing  youtube-dl.   If you are using a UI for youtube-dl, report the bug
2157       to the maintainer of the actual application providing the UI.   On  the
2158       other  hand, if your UI for youtube-dl fails in some way you believe is
2159       related to youtube-dl, by all means, go ahead and report the bug.
2160
2162       youtube-dl is released into the public domain by the copyright holders.
2163
2164       This  README   file   was   originally   written   by   Daniel   Bolton
2165       (https://github.com/dbbolton)  and is likewise released into the public
2166       domain.
2167
2168
2169
2170                                                                 YOUTUBE-DL(1)
Impressum