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 Options:
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       Service Pack 1 Redistributable Package  (x86)  (https://download.micro
1335       soft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcre‐
1336       dist_x86.exe).
1337
1338   On Windows, how should I set up ffmpeg and youtube-dl? Where should
1339       I put the exe files?
1340
1341       If you put youtube-dl and ffmpeg in the same directory that you're run‐
1342       ning the command from, it will work, but that's rather cumbersome.
1343
1344       To  make  a  different  directory  work  -  either  for  ffmpeg, or for
1345       youtube-dl, or for both - simply create the directory (say, C:\bin,  or
1346       C:\Users\<User name>\bin),  put  all the executables directly in there,
1347       and  then  set  your   PATH   environment   variable   (https://www.ja
1348       va.com/en/download/help/path.xml) to include that directory.
1349
1350       From  then  on, after restarting your shell, you will be able to access
1351       both youtube-dl and ffmpeg (and youtube-dl will be able to find ffmpeg)
1352       by  simply typing youtube-dl or ffmpeg, no matter what directory you're
1353       in.
1354
1355   How do I put downloads into a specific folder?
1356       Use the -o to specify an output  template,  for  example  -o "/home/us‐
1357       er/videos/%(title)s-%(id)s.%(ext)s".   If you want this for all of your
1358       downloads, put the option into your configuration file.
1359
1360   How do I download a video starting with a -?
1361       Either prepend https://www.youtube.com/watch?v= or separate the ID from
1362       the options with --:
1363
1364              youtube-dl -- -wNyEUrxzFU
1365              youtube-dl "https://www.youtube.com/watch?v=-wNyEUrxzFU"
1366
1367   How do I pass cookies to youtube-dl?
1368       Use   the   --cookies   option,  for  example  --cookies /path/to/cook‐
1369       ies/file.txt.
1370
1371       In order to extract cookies from browser use any conforming browser ex‐
1372       tension   for   exporting   cookies.    For  example,  Get  cookies.txt
1373       (https://chrome.google.com/webstore/detail/get-cookiestxt/bgaddhkodda
1374       jcdgocldbbfleckgcbcid/)   (for   Chrome)  or  cookies.txt  (https://ad
1375       dons.mozilla.org/en-US/firefox/addon/cookies-txt/) (for Firefox).
1376
1377       Note that the cookies file must be in Mozilla/Netscape format  and  the
1378       first  line  of  the  cookies file must be either # HTTP Cookie File or
1379       # Netscape HTTP Cookie File.  Make sure you have correct newline format
1380       (https://en.wikipedia.org/wiki/Newline) in the cookies file and convert
1381       newlines if necessary to correspond with your OS,  namely  CRLF  (\r\n)
1382       for  Windows  and LF (\n) for Unix and Unix-like systems (Linux, macOS,
1383       etc.).  HTTP Error 400: Bad Request when using --cookies is a good sign
1384       of invalid newline format.
1385
1386       Passing  cookies to youtube-dl is a good way to workaround login when a
1387       particular extractor does not implement  it  explicitly.   Another  use
1388       case  is working around CAPTCHA (https://en.wikipedia.org/wiki/CAPTCHA)
1389       some websites require you to solve in particular cases in order to  get
1390       access (e.g.  YouTube, CloudFlare).
1391
1392   How do I stream directly to media player?
1393       You  will  first need to tell youtube-dl to stream media to stdout with
1394       -o -, and also tell your media player to read from stdin  (it  must  be
1395       capable of this for streaming) and then pipe former to latter.  For ex‐
1396       ample, streaming to vlc  (https://www.videolan.org/)  can  be  achieved
1397       with:
1398
1399              youtube-dl -o - "https://www.youtube.com/watch?v=BaW_jenozKcj" | vlc -
1400
1401   How do I download only new videos from a playlist?
1402       Use  download-archive  feature.  With this feature you should initially
1403       download the complete playlist  with  --download-archive /path/to/down‐
1404       load/archive/file.txt that will record identifiers of all the videos in
1405       a special file.  Each subsequent run with the  same  --download-archive
1406       will  download only new videos and skip all videos that have been down‐
1407       loaded before.  Note that only successful downloads are recorded in the
1408       file.
1409
1410       For example, at first,
1411
1412              youtube-dl --download-archive archive.txt "https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re"
1413
1414       will  download the complete PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re playlist
1415       and create a file archive.txt.  Each subsequent run will only  download
1416       new videos if any:
1417
1418              youtube-dl --download-archive archive.txt "https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re"
1419
1420   Should I add --hls-prefer-native into my config?
1421       When  youtube-dl  detects  an HLS video, it can download it either with
1422       the built-in downloader or ffmpeg.  Since many HLS streams are slightly
1423       invalid  and  ffmpeg/youtube-dl  each  handle some invalid cases better
1424       than the other, there is an option to switch the downloader if needed.
1425
1426       When youtube-dl knows that one particular downloader works better for a
1427       given  website,  that downloader will be picked.  Otherwise, youtube-dl
1428       will pick the best downloader for general compatibility, which  at  the
1429       moment happens to be ffmpeg.  This choice may change in future versions
1430       of youtube-dl, with improvements of the built-in downloader and/or ffm‐
1431       peg.
1432
1433       In  particular, the generic extractor (used when your website is not in
1434       the   list   of   supported   sites   by   youtube-dl    (https://ytdl-
1435       org.github.io/youtube-dl/supportedsites.html)  cannot  mandate one spe‐
1436       cific downloader.
1437
1438       If you put either --hls-prefer-native or --hls-prefer-ffmpeg into  your
1439       configuration,  a different subset of videos will fail to download cor‐
1440       rectly.  Instead, it is much  better  to  file  an  issue  (https://yt-
1441       dl.org/bug)  or a pull request which details why the native or the ffm‐
1442       peg HLS downloader is a better choice for your use case.
1443
1444   Can you add support for this anime video site, or site which shows
1445       current movies for free?
1446
1447       As a matter of policy (as well as legality), youtube-dl  does  not  in‐
1448       clude support for services that specialize in infringing copyright.  As
1449       a rule of thumb, if you cannot easily find a video that the service  is
1450       quite  obviously allowed to distribute (i.e.  that has been uploaded by
1451       the creator, the creator's distributor, or is published  under  a  free
1452       license), the service is probably unfit for inclusion to youtube-dl.
1453
1454       A  note on the service that they don't host the infringing content, but
1455       just link to those who do, is evidence that the service should  not  be
1456       included  into  youtube-dl.   The  same goes for any DMCA note when the
1457       whole front page of the service is filled with videos they are not  al‐
1458       lowed  to distribute.  A "fair use" note is equally unconvincing if the
1459       service shows copyright-protected videos in full without authorization.
1460
1461       Support requests for services that do purchase the rights to distribute
1462       their  content  are perfectly fine though.  If in doubt, you can simply
1463       include a source that mentions the legitimate purchase of content.
1464
1465   How can I speed up work on my issue?
1466       (Also known as:  Help,  my  important  issue  not  being  solved!)  The
1467       youtube-dl core developer team is quite small.  While we do our best to
1468       solve as many issues as possible,  sometimes  that  can  take  quite  a
1469       while.  To speed up your issue, here's what you can do:
1470
1471       First  of  all,  please  do  report  the  issue  at  our  issue tracker
1472       (https://yt-dl.org/bugs).  That allows us to coordinate all efforts  by
1473       users  and  developers,  and serves as a unified point.  Unfortunately,
1474       the youtube-dl project has grown too large to use personal email as  an
1475       effective communication channel.
1476
1477       Please  read  the bug reporting instructions below.  A lot of bugs lack
1478       all the necessary information.  If you can, offer proxy, VPN, or  shell
1479       access  to the youtube-dl developers.  If you are able to, test the is‐
1480       sue from multiple computers in multiple countries to exclude local cen‐
1481       sorship or misconfiguration issues.
1482
1483       If  nobody is interested in solving your issue, you are welcome to take
1484       matters into your own hands and submit a pull  request  (or  coerce/pay
1485       somebody else to do so).
1486
1487       Feel  free  to bump the issue from time to time by writing a small com‐
1488       ment ("Issue is still present in youtube-dl version ...from France, but
1489       fixed from Belgium"), but please not more than once a month.  Please do
1490       not declare your issue as important or urgent.
1491
1492   How can I detect whether a given URL is supported by youtube-dl?
1493       For one, have a look at the list of  supported  sites  (docs/supported‐
1494       sites.md).  Note that it can sometimes happen that the site changes its
1495       URL scheme (say, from https://example.com/video/1234567 to  https://ex
1496       ample.com/v/1234567  )  and  youtube-dl  reports an URL of a service in
1497       that list as unsupported.  In that case, simply report a bug.
1498
1499       It is not possible to detect whether a URL is supported or not.  That's
1500       because youtube-dl contains a generic extractor which matches all URLs.
1501       You may be tempted to disable, exclude, or remove the  generic  extrac‐
1502       tor,  but the generic extractor not only allows users to extract videos
1503       from lots of websites that embed a video from another service, but  may
1504       also  be used to extract video from a service that it's hosting itself.
1505       Therefore, we neither recommend nor support  disabling,  excluding,  or
1506       removing the generic extractor.
1507
1508       If  you  want to find out whether a given URL is supported, simply call
1509       youtube-dl with it.  If you get no videos back, chances are the URL  is
1510       either not referring to a video or unsupported.  You can find out which
1511       by examining the output (if you  run  youtube-dl  on  the  console)  or
1512       catching an UnsupportedError exception if you run it from a Python pro‐
1513       gram.
1514

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

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

DEVELOPER INSTRUCTIONS

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

EMBEDDING YOUTUBE-DL

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

BUGS

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