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  (%APPDATA%/youtube-
63              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 (case- insensitive regex or al‐
139              phanumeric sub- string)
140
141       –reject-title REGEX
142              Skip download for matching titles (case-insensitive regex or al‐
143              phanumeric sub-string)
144
145       –max-downloads NUMBER
146              Abort after downloading NUMBER files
147
148       –min-filesize SIZE
149              Do not download any videos smaller than SIZE (e.g. 50k or 44.6m)
150
151       –max-filesize SIZE
152              Do not download any videos larger than SIZE (e.g. 50k or 44.6m)
153
154       –date DATE
155              Download only videos uploaded in this date
156
157       –datebefore DATE
158              Download  only  videos uploaded on or before this date (i.e. in‐
159              clusive)
160
161       –dateafter DATE
162              Download only videos uploaded on or after this date (i.e. inclu‐
163              sive)
164
165       –min-views COUNT
166              Do not download any videos with less than COUNT views
167
168       –max-views COUNT
169              Do not download any videos with more than COUNT views
170
171       –match-filter FILTER
172              Generic  video  filter.   Specify  any key (see the “OUTPUT TEM‐
173              PLATE” for a list of available keys) to  match  if  the  key  is
174              present,  !key  to check if the key is not present, key > NUMBER
175              (like “comment_count > 12”, also works with >=, <, <=, !=, =) to
176              compare  against  a  number,  key  = `LITERAL' (like “uploader =
177              `Mike Smith'”, also works with !=) to  match  against  a  string
178              literal and & to require multiple matches.  Values which are not
179              known are excluded unless you put a question mark (?)  after the
180              operator.   For  example,  to  only  match videos that have been
181              liked more than 100 times and disliked less than  50  times  (or
182              the  dislike  functionality  is  not available at the given ser‐
183              vice), but  who  also  have  a  description,  use  –match-filter
184              “like_count > 100 & dislike_count <?  50 & description” .
185
186       –no-playlist
187              Download  only  the  video,  if  the URL refers to a video and a
188              playlist.
189
190       –yes-playlist
191              Download the playlist, if the  URL  refers  to  a  video  and  a
192              playlist.
193
194       –age-limit YEARS
195              Download only videos suitable for the given age
196
197       –download-archive FILE
198              Download only videos not listed in the archive file.  Record the
199              IDs of all downloaded videos in it.
200
201       –include-ads
202              Download advertisements as well (experimental)
203
204   Download Options:
205       -r, –limit-rate RATE
206              Maximum download rate in bytes per second (e.g. 50K or 4.2M)
207
208       -R, –retries RETRIES
209              Number of retries (default is 10), or “infinite”.
210
211       –fragment-retries RETRIES
212              Number of retries for a fragment (default is 10), or  “infinite”
213              (DASH, hlsnative and ISM)
214
215       –skip-unavailable-fragments
216              Skip unavailable fragments (DASH, hlsnative and ISM)
217
218       –abort-on-unavailable-fragment
219              Abort downloading when some fragment is not available
220
221       –keep-fragments
222              Keep downloaded fragments on disk after downloading is finished;
223              fragments are erased by default
224
225       –buffer-size SIZE
226              Size of download buffer (e.g. 1024 or 16K) (default is 1024)
227
228       –no-resize-buffer
229              Do not automatically adjust the buffer size.   By  default,  the
230              buffer  size  is  automatically resized from an initial value of
231              SIZE.
232
233       –http-chunk-size SIZE
234              Size of a chunk for chunk-based HTTP downloading  (e.g. 10485760
235              or  10M)  (default  is  disabled).   May be useful for bypassing
236              bandwidth throttling imposed by a webserver (experimental)
237
238       –playlist-reverse
239              Download playlist videos in reverse order
240
241       –playlist-random
242              Download playlist videos in random order
243
244       –xattr-set-filesize
245              Set file xattribute ytdl.filesize with expected file size
246
247       –hls-prefer-native
248              Use the native HLS downloader instead of ffmpeg
249
250       –hls-prefer-ffmpeg
251              Use ffmpeg instead of the native HLS downloader
252
253       –hls-use-mpegts
254              Use the mpegts container for HLS videos, allowing  to  play  the
255              video  while  downloading  (some players may not be able to play
256              it)
257
258       –external-downloader COMMAND
259              Use  the  specified  external  downloader.   Currently  supports
260              aria2c,aria2p,avconv ,axel,curl,ffmpeg,httpie,wget
261
262       –external-downloader-args ARGS
263              Give these arguments to the external downloader
264
265   Filesystem Options:
266       -a, –batch-file FILE
267              File  containing  URLs  to download (`-' for stdin), one URL per
268              line.  Lines starting with `#', `;' or  `]'  are  considered  as
269              comments and ignored.
270
271       –id    Use only video ID in file name
272
273       -o, –output TEMPLATE
274              Output  filename template, see the “OUTPUT TEMPLATE” for all the
275              info
276
277       –output-na-placeholder PLACEHOLDER
278              Placeholder value for unavailable meta fields in output filename
279              template (default is “NA”)
280
281       –autonumber-start NUMBER
282              Specify the start value for %(autonumber)s (default is 1)
283
284       –restrict-filenames
285              Restrict  filenames  to only ASCII characters, and avoid “&” and
286              spaces in filenames
287
288       -w, –no-overwrites
289              Do not overwrite files
290
291       -c, –continue
292              Force  resume  of  partially  downloaded  files.   By   default,
293              youtube-dl will resume downloads if possible.
294
295       –no-continue
296              Do  not  resume  partially downloaded files (restart from begin‐
297              ning)
298
299       –no-part
300              Do not use .part files - write directly into output file
301
302       –mtime Use the Last-modified header to set the file  modification  time
303              (default)
304
305       –no-mtime
306              Do not use the Last-modified header to set the file modification
307              time
308
309       –write-description
310              Write video description to a .description file
311
312       –write-info-json
313              Write video metadata to a .info.json file
314
315       –write-annotations
316              Write video annotations to a .annotations.xml file
317
318       –load-info-json FILE
319              JSON file containing the video  information  (created  with  the
320              “–write- info-json” option)
321
322       –cookies FILE
323              File to read cookies from and dump cookie jar in
324
325       –cache-dir DIR
326              Location in the filesystem where youtube-dl can store some down‐
327              loaded      information      permanently.       By       default
328              $XDG_CACHE_HOME/youtube-dl  or ~/.cache/youtube-dl .  At the mo‐
329              ment, only YouTube player files (for videos with obfuscated sig‐
330              natures) are cached, but that may change.
331
332       –no-cache-dir
333              Disable filesystem caching
334
335       –rm-cache-dir
336              Delete all filesystem cache files
337
338   Thumbnail Options:
339       –write-thumbnail
340              Write thumbnail image to disk
341
342       –write-all-thumbnails
343              Write all thumbnail image formats to disk
344
345       –list-thumbnails
346              Simulate and list all available thumbnail formats
347
348   Verbosity / Simulation Options:
349       -q, –quiet
350              Activate quiet mode
351
352       –no-warnings
353              Ignore warnings
354
355       -s, –simulate
356              Do not download the video and do not write anything to disk
357
358       –skip-download
359              Do not download the video
360
361       -g, –get-url
362              Simulate, quiet but print URL
363
364       -e, –get-title
365              Simulate, quiet but print title
366
367       –get-id
368              Simulate, quiet but print id
369
370       –get-thumbnail
371              Simulate, quiet but print thumbnail URL
372
373       –get-description
374              Simulate, quiet but print video description
375
376       –get-duration
377              Simulate, quiet but print video length
378
379       –get-filename
380              Simulate, quiet but print output filename
381
382       –get-format
383              Simulate, quiet but print output format
384
385       -j, –dump-json
386              Simulate,  quiet  but  print  JSON information.  See the “OUTPUT
387              TEMPLATE” for a description of available keys.
388
389       -J, –dump-single-json
390              Simulate, quiet but print JSON information for each command-line
391              argument.   If  the  URL  refers  to  a playlist, dump the whole
392              playlist information in a single line.
393
394       –print-json
395              Be quiet and print the video information as JSON (video is still
396              being downloaded).
397
398       –newline
399              Output progress bar as new lines
400
401       –no-progress
402              Do not print progress bar
403
404       –console-title
405              Display progress in console titlebar
406
407       -v, –verbose
408              Print various debugging information
409
410       –dump-pages
411              Print  downloaded  pages  encoded using base64 to debug problems
412              (very verbose)
413
414       –write-pages
415              Write downloaded intermediary pages to files in the current  di‐
416              rectory to debug problems
417
418       –print-traffic
419              Display sent and read HTTP traffic
420
421       -C, –call-home
422              Contact the youtube-dl server for debugging
423
424       –no-call-home
425              Do NOT contact the youtube-dl server for debugging
426
427   Workarounds:
428       –encoding ENCODING
429              Force the specified encoding (experimental)
430
431       –no-check-certificate
432              Suppress HTTPS certificate validation
433
434       –prefer-insecure
435              Use  an unencrypted connection to retrieve information about the
436              video.  (Currently supported only for YouTube)
437
438       –user-agent UA
439              Specify a custom user agent
440
441       –referer URL
442              Specify a custom Referer: use if the video access is  restricted
443              to one domain
444
445       –add-header FIELD:VALUE
446              Specify a custom HTTP header and its value, separated by a colon
447              `:'.  You can use this option multiple times.  NB  Use  –cookies
448              rather than adding a Cookie header if its contents may be sensi‐
449              tive; data from a Cookie header will be sent to all domains, not
450              just the one intended
451
452       –bidi-workaround
453              Work around terminals that lack bidirectional text support.  Re‐
454              quires bidiv or fribidi executable in PATH
455
456       –sleep-interval SECONDS
457              Number of seconds to sleep before each download when used  alone
458              or  a  lower  bound  of a range for randomized sleep before each
459              download (minimum possible number of seconds to sleep) when used
460              along with –max-sleep-interval.
461
462       –max-sleep-interval SECONDS
463              Upper bound of a range for randomized sleep before each download
464              (maximum possible number of seconds to  sleep).   Must  only  be
465              used along with –min- sleep-interval.
466
467   Video Format Options:
468       -f, –format FORMAT
469              Video format code, see the “FORMAT SELECTION” for all the info
470
471       –all-formats
472              Download all available video formats
473
474       –prefer-free-formats
475              Prefer free video formats unless a specific one is requested
476
477       -F, –list-formats
478              List all available formats of requested videos
479
480       –youtube-skip-dash-manifest
481              Do  not  download the DASH manifests and related data on YouTube
482              videos
483
484       –merge-output-format FORMAT
485              If a merge is required (e.g.   bestvideo+bestaudio),  output  to
486              given  container  format.  One of mkv, mp4, ogg, webm, flv.  Ig‐
487              nored if no merge is required
488
489   Subtitle Options:
490       –write-sub
491              Write subtitle file
492
493       –write-auto-sub
494              Write automatically generated subtitle file (YouTube only)
495
496       –all-subs
497              Download all the available subtitles of the video
498
499       –list-subs
500              List all available subtitles for the video
501
502       –sub-format FORMAT
503              Subtitle format, accepts formats preference, for example:  “srt”
504              or “ass/srt/best”
505
506       –sub-lang LANGS
507              Languages  of  the subtitles to download (optional) separated by
508              commas, use –list-subs for available language tags
509
510   Authentication Options:
511       -u, –username USERNAME
512              Login with this account ID
513
514       -p, –password PASSWORD
515              Account password.  If this option is left out,  youtube-dl  will
516              ask interactively.
517
518       -2, –twofactor TWOFACTOR
519              Two-factor authentication code
520
521       -n, –netrc
522              Use .netrc authentication data
523
524       –video-password PASSWORD
525              Video password (vimeo, youku)
526
527   Adobe Pass Options:
528       –ap-mso MSO
529              Adobe  Pass  multiple-system  operator (TV provider) identifier,
530              use –ap-list-mso for a list of available MSOs
531
532       –ap-username USERNAME
533              Multiple-system operator account login
534
535       –ap-password PASSWORD
536              Multiple-system operator account password.  If  this  option  is
537              left out, youtube-dl will ask interactively.
538
539       –ap-list-mso
540              List all supported multiple-system operators
541
542   Post-processing Options:
543       -x, –extract-audio
544              Convert  video files to audio-only files (requires ffmpeg/avconv
545              and ffprobe/avprobe)
546
547       –audio-format FORMAT
548              Specify audio  format:  “best”,  “aac”,  “flac”,  “mp3”,  “m4a”,
549              “opus”, “vorbis”, or “wav”; “best” by default; No effect without
550              -x
551
552       –audio-quality QUALITY
553              Specify ffmpeg/avconv audio quality, insert a  value  between  0
554              (better)  and  9 (worse) for VBR or a specific bitrate like 128K
555              (default 5)
556
557       –recode-video FORMAT
558              Encode the video to another format if necessary (currently  sup‐
559              ported: mp4|flv|ogg|webm|mkv|avi)
560
561       –postprocessor-args ARGS
562              Give  these arguments to the postprocessor (if postprocessing is
563              required)
564
565       -k, –keep-video
566              Keep the video file on disk after the post-processing; the video
567              is erased by default
568
569       –no-post-overwrites
570              Do  not overwrite post-processed files; the post-processed files
571              are overwritten by default
572
573       –embed-subs
574              Embed subtitles in the video (only for mp4, webm and mkv videos)
575
576       –embed-thumbnail
577              Embed thumbnail in the audio as cover art
578
579       –add-metadata
580              Write metadata to the video file
581
582       –metadata-from-title FORMAT
583              Parse additional metadata like song  title  /  artist  from  the
584              video title.  The format syntax is the same as –output.  Regular
585              expression with named capture groups  may  also  be  used.   The
586              parsed  parameters replace existing values.  Example: –metadata-
587              from-title “%(artist)s - %(title)s” matches a title like  “Cold‐
588              play   -   Paradise”.    Example  (regex):  –metadata-from-title
589              “(?P.+?)  - (?P
590              .+)”
591
592       –xattrs
593              Write metadata to the video file’s xattrs (using dublin core and
594              xdg standards)
595
596       –fixup POLICY
597              Automatically  correct  known  faults of the file.  One of never
598              (do nothing), warn (only emit a  warning),  detect_or_warn  (the
599              default; fix file if we can, warn otherwise)
600
601       –prefer-avconv
602              Prefer avconv over ffmpeg for running the postprocessors
603
604       –prefer-ffmpeg
605              Prefer  ffmpeg  over  avconv for running the postprocessors (de‐
606              fault)
607
608       –ffmpeg-location PATH
609              Location of the ffmpeg/avconv binary; either the path to the bi‐
610              nary or its containing directory.
611
612       –exec CMD
613              Execute  a  command  on the file after downloading and post-pro‐
614              cessing, similar to find’s -exec syntax.   Example:  –exec  `adb
615              push {} /sdcard/Music/ && rm {}'
616
617       –convert-subs FORMAT
618              Convert  the  subtitles  to  other  format (currently supported:
619              srt|ass|vtt|lrc)
620

CONFIGURATION

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

OUTPUT TEMPLATE

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

FORMAT SELECTION

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

VIDEO SELECTION

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

FAQ

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

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

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

DEVELOPER INSTRUCTIONS

1532       Most  users do not need to build youtube-dl and can download the builds
1533       (https://ytdl-org.github.io/youtube-dl/download.html) or get them  from
1534       their distribution.
1535
1536       To  run youtube-dl as a developer, you don’t need to build anything ei‐
1537       ther.  Simply execute
1538
1539              python -m youtube_dl
1540
1541       To run the test, simply invoke your favorite test runner, or execute  a
1542       test file directly; any of the following work:
1543
1544              python -m unittest discover
1545              python test/test_download.py
1546              nosetests
1547
1548       For   Python   versions   3.6   and   later,   you   can   use   pynose
1549       (https://pypi.org/project/pynose/) to implement nosetests.  The  origi‐
1550       nal  nose  (https://pypi.org/project/nose/)  has  not been upgraded for
1551       3.10 and later.
1552
1553       See item 6 of new extractor tutorial for how to run extractor  specific
1554       test cases.
1555
1556       If you want to create a build of youtube-dl yourself, you’ll need
1557
1558       • python
1559
1560       • make (only GNU make is supported)
1561
1562       • pandoc
1563
1564       • zip
1565
1566       • nosetests
1567
1568   Adding support for a new site
1569       If  you want to add support for a new site, first of all make sure this
1570       site is not dedicated to copyright infringement.  youtube-dl  does  not
1571       support  such  sites thus pull requests adding support for them will be
1572       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 (actually,
1638           test case) then rename _TEST to _TESTS and make it into a  list  of
1639           dictionaries.    The   tests   will   then   be   named   TestDown‐
1640           load.test_YourExtractor,  TestDownload.test_YourExtractor_1,  Test‐
1641           Download.test_YourExtractor_2, etc.  Note:
1642
1643           • the  test names use the extractor class name without the trailing
1644             IE
1645
1646           • tests with only_matching key in test’s dict are not counted.
1647
1648        7. Have      a      look       at       youtube_dl/extractor/common.py
1649           (https://github.com/ytdl-org/youtube-dl/blob/master/youtube_dl/ex
1650           tractor/common.py) for possible helper methods and a  detailed  de‐
1651           scription   of   what   your   extractor   should  and  may  return
1652           (https://github.com/ytdl-org/youtube-
1653           dl/blob/7f41a598b3fba1bcab2817de64a08941200aa3c8/youtube_dl/extrac‐
1654           tor/common.py#L94-L303).  Add tests and code for  as  many  as  you
1655           want.
1656
1657        8. Make sure your code follows youtube-dl coding conventions and check
1658           the  code   with   flake8   (https://flake8.pycqa.org/en/latest/in
1659           dex.html#quickstart):
1660
1661                   $ flake8 youtube_dl/extractor/yourextractor.py
1662
1663        9. Make     sure     your     code     works    under    all    Python
1664           (https://www.python.org/) versions claimed supported by youtube-dl,
1665           namely 2.6, 2.7, and 3.2+.
1666
1667       10. When the tests pass, add (https://git-scm.com/docs/git-add) the new
1668           files and  commit  (https://git-scm.com/docs/git-commit)  them  and
1669           push (https://git-scm.com/docs/git-push) the result, like this:
1670
1671                  $ git add youtube_dl/extractor/extractors.py
1672                  $ git add youtube_dl/extractor/yourextractor.py
1673                  $ git commit -m '[yourextractor] Add new extractor'
1674                  $ git push origin yourextractor
1675
1676       11. Finally,   create  a  pull  request  (https://help.github.com/arti
1677           cles/creating-a-pull-request).  We’ll then review and merge it.
1678
1679       In any case, thank you very much for your contributions!
1680
1681   youtube-dl coding conventions
1682       This section introduces guidelines for writing  idiomatic,  robust  and
1683       future-proof extractor code.
1684
1685       Extractors  are  very fragile by nature since they depend on the layout
1686       of the source data provided by 3rd party media hosters out of your con‐
1687       trol and this layout tends to change.  As an extractor implementer your
1688       task is not only to write code that will extract media links and  meta‐
1689       data  correctly  but also to minimize dependency on the source’s layout
1690       and even to make the code foresee potential future changes and be ready
1691       for that.  This is important because it will allow the extractor not to
1692       break on minor layout changes  thus  keeping  old  youtube-dl  versions
1693       working.  Even though this breakage issue is easily fixed by emitting a
1694       new version of youtube-dl with a fix  incorporated,  all  the  previous
1695       versions  become  broken in all repositories and distros’ packages that
1696       may not be so prompt in fetching the update from us.  Needless to  say,
1697       some non rolling release distros may never receive an update at all.
1698
1699   Mandatory and optional metafields
1700       For extraction to work youtube-dl relies on metadata your extractor ex‐
1701       tracts and provides to youtube-dl expressed by an  information  dictio‐
1702       nary                              (https://github.com/ytdl-org/youtube-
1703       dl/blob/7f41a598b3fba1bcab2817de64a08941200aa3c8/youtube_dl/extrac‐
1704       tor/common.py#L94-L303)  or  simply info dict.  Only the following meta
1705       fields in the info dict are considered mandatory for a  successful  ex‐
1706       traction process by youtube-dl:
1707
1708id (media identifier)
1709
1710title (media title)
1711
1712url (media download URL) or formats
1713
1714       In  fact  only  the  last  option is technically mandatory (i.e. if you
1715       can’t figure out the download location of the media the extraction does
1716       not  make  any sense).  But by convention youtube-dl also treats id and
1717       title as mandatory.  Thus the aforementioned metafields are the  criti‐
1718       cal data that the extraction does not make any sense without and if any
1719       of them fail to be extracted then the extractor is considered complete‐
1720       ly broken.
1721
1722       Any             field             (https://github.com/ytdl-org/youtube-
1723       dl/blob/7f41a598b3fba1bcab2817de64a08941200aa3c8/youtube_dl/extrac‐
1724       tor/common.py#L188-L303) apart from the aforementioned ones are consid‐
1725       ered optional.  That means that extraction should be tolerant to situa‐
1726       tions  when  sources  for  these  fields can potentially be unavailable
1727       (even if they are always available at the moment) and  future-proof  in
1728       order not to break the extraction of general purpose mandatory fields.
1729
1730   Example
1731       Say  you  have  some source dictionary meta that you’ve fetched as JSON
1732       with HTTP request and it has a key summary:
1733
1734              meta = self._download_json(url, video_id)
1735
1736       Assume at this point meta’s layout is:
1737
1738              {
1739                  ...
1740                  "summary": "some fancy summary text",
1741                  ...
1742              }
1743
1744       Assume you want to extract summary and put it into the  resulting  info
1745       dict  as  description.  Since description is an optional meta field you
1746       should be ready that this key may be missing from  the  meta  dict,  so
1747       that you should extract it like:
1748
1749              description = meta.get('summary')  # correct
1750
1751       and not like:
1752
1753              description = meta['summary']  # incorrect
1754
1755       The  latter will break extraction process with KeyError if summary dis‐
1756       appears from meta at some later time but with the former  approach  ex‐
1757       traction  will just go ahead with description set to None which is per‐
1758       fectly fine (remember None is equivalent to the absence of data).
1759
1760       Similarly, you should pass fatal=False when  extracting  optional  data
1761       from  a webpage with _search_regex, _html_search_regex or similar meth‐
1762       ods, for instance:
1763
1764              description = self._search_regex(
1765                  r'<span[^>]+id="title"[^>]*>([^<]+)<',
1766                  webpage, 'description', fatal=False)
1767
1768       With fatal set to False if _search_regex fails to  extract  description
1769       it will emit a warning and continue extraction.
1770
1771       You can also pass default=<some fallback value>, for example:
1772
1773              description = self._search_regex(
1774                  r'<span[^>]+id="title"[^>]*>([^<]+)<',
1775                  webpage, 'description', default=None)
1776
1777       On  failure  this  code  will silently continue the extraction with de‐
1778       scription set to None.  That is useful for metafields that may  or  may
1779       not be present.
1780
1781   Provide fallbacks
1782       When extracting metadata try to do so from multiple sources.  For exam‐
1783       ple if title is present in several places, try extracting from at least
1784       some  of  them.   This  makes  it more future-proof in case some of the
1785       sources become unavailable.
1786
1787   Example
1788       Say meta from the previous example has a title and you are about to ex‐
1789       tract it.  Since title is a mandatory meta field you should end up with
1790       something like:
1791
1792              title = meta['title']
1793
1794       If title disappears from meta in future due  to  some  changes  on  the
1795       hoster’s  side  the  extraction  would  fail  since title is mandatory.
1796       That’s expected.
1797
1798       Assume that you have some another source you can  extract  title  from,
1799       for example og:title HTML meta of a webpage.  In this case you can pro‐
1800       vide a fallback scenario:
1801
1802              title = meta.get('title') or self._og_search_title(webpage)
1803
1804       This code will try to extract from meta first and if it fails  it  will
1805       try extracting og:title from a webpage.
1806
1807   Regular expressions
1808   Don’t capture groups you don’t use
1809       Capturing  group  must be an indication that it’s used somewhere in the
1810       code.  Any group that is not used must be non capturing.
1811
1812   Example
1813       Don’t capture id attribute name here since you can’t use  it  for  any‐
1814       thing anyway.
1815
1816       Correct:
1817
1818              r'(?:id|ID)=(?P<id>\d+)'
1819
1820       Incorrect:
1821
1822              r'(id|ID)=(?P<id>\d+)'
1823
1824   Make regular expressions relaxed and flexible
1825       When  using  regular  expressions  try to write them fuzzy, relaxed and
1826       flexible, skipping insignificant parts that are more likely to  change,
1827       allowing both single and double quotes for quoted values and so on.
1828
1829   Example
1830       Say you need to extract title from the following HTML code:
1831
1832              <span style="position: absolute; left: 910px; width: 90px; float: right; z-index: 9999;" class="title">some fancy title</span>
1833
1834       The code for that task should look similar to:
1835
1836              title = self._search_regex(
1837                  r'<span[^>]+class="title"[^>]*>([^<]+)', webpage, 'title')
1838
1839       Or even better:
1840
1841              title = self._search_regex(
1842                  r'<span[^>]+class=(["\'])title\1[^>]*>(?P<title>[^<]+)',
1843                  webpage, 'title', group='title')
1844
1845       Note  how you tolerate potential changes in the style attribute’s value
1846       or switch from using double quotes to single for class attribute:
1847
1848       The code definitely should not look like:
1849
1850              title = self._search_regex(
1851                  r'<span style="position: absolute; left: 910px; width: 90px; float: right; z-index: 9999;" class="title">(.*?)</span>',
1852                  webpage, 'title', group='title')
1853
1854   Long lines policy
1855       There is a soft limit to keep lines of code under 80  characters  long.
1856       This  means  it should be respected if possible and if it does not make
1857       readability and code maintenance worse.
1858
1859       For example, you should never split long string literals like  URLs  or
1860       some other often copied entities over multiple lines to fit this limit:
1861
1862       Correct:
1863
1864              'https://www.youtube.com/watch?v=FqZTN594JQw&list=PLMYEtVRpaqY00V9W81Cwmzp6N6vZqfUKD4'
1865
1866       Incorrect:
1867
1868              'https://www.youtube.com/watch?v=FqZTN594JQw&list='
1869              'PLMYEtVRpaqY00V9W81Cwmzp6N6vZqfUKD4'
1870
1871   Inline values
1872       Extracting  variables  is  acceptable for reducing code duplication and
1873       improving readability of  complex  expressions.   However,  you  should
1874       avoid  extracting  variables used only once and moving them to opposite
1875       parts of the extractor file, which makes reading the linear flow diffi‐
1876       cult.
1877
1878   Example
1879       Correct:
1880
1881              title = self._html_search_regex(r'<title>([^<]+)</title>', webpage, 'title')
1882
1883       Incorrect:
1884
1885              TITLE_RE = r'<title>([^<]+)</title>'
1886              # ...some lines of code...
1887              title = self._html_search_regex(TITLE_RE, webpage, 'title')
1888
1889   Collapse fallbacks
1890       Multiple  fallback values can quickly become unwieldy.  Collapse multi‐
1891       ple fallback values into a single expression via a list of patterns.
1892
1893   Example
1894       Good:
1895
1896              description = self._html_search_meta(
1897                  ['og:description', 'description', 'twitter:description'],
1898                  webpage, 'description', default=None)
1899
1900       Unwieldy:
1901
1902              description = (
1903                  self._og_search_description(webpage, default=None)
1904                  or self._html_search_meta('description', webpage, default=None)
1905                  or self._html_search_meta('twitter:description', webpage, default=None))
1906
1907       Methods   supporting   list    of    patterns    are:    _search_regex,
1908       _html_search_regex, _og_search_property, _html_search_meta.
1909
1910   Trailing parentheses
1911       Always move trailing parentheses after the last argument.
1912
1913   Example
1914       Correct:
1915
1916                  lambda x: x['ResultSet']['Result'][0]['VideoUrlSet']['VideoUrl'],
1917                  list)
1918
1919       Incorrect:
1920
1921                  lambda x: x['ResultSet']['Result'][0]['VideoUrlSet']['VideoUrl'],
1922                  list,
1923              )
1924
1925   Use convenience conversion and parsing functions
1926       Wrap   all   extracted   numeric   data   into   safe   functions  from
1927       youtube_dl/utils.py   (https://github.com/ytdl-org/youtube-dl/blob/mas
1928       ter/youtube_dl/utils.py):  int_or_none,  float_or_none.   Use  them for
1929       string to number conversions as well.
1930
1931       Use url_or_none for safe URL processing.
1932
1933       Use traverse_obj for safe metadata extraction from parsed JSON.
1934
1935       Use unified_strdate for uniform upload_date or any YYYYMMDD meta  field
1936       extraction,   unified_timestamp   for   uniform  timestamp  extraction,
1937       parse_filesize for filesize  extraction,  parse_count  for  count  meta
1938       fields  extraction,  parse_resolution,  parse_duration for duration ex‐
1939       traction, parse_age_limit for age_limit extraction.
1940
1941       Explore    youtube_dl/utils.py    (https://github.com/ytdl-org/youtube-
1942       dl/blob/master/youtube_dl/utils.py)  for  more useful convenience func‐
1943       tions.
1944
1945   More examples
1946   Safely extract optional description from parsed JSON
1947       When processing complex JSON, as often returned by site API requests or
1948       stashed  in  web  pages for “hydration”, you can use the traverse_obj()
1949       utility function to handle multiple fallback values and to  ensure  the
1950       expected  type of metadata items.  The function’s docstring defines how
1951       the function works: also review usage in the codebase  for  more  exam‐
1952       ples.
1953
1954       In  this  example, a text description, or None, is pulled from the .re‐
1955       sult.video[0].summary member of the parsed JSON response, if available.
1956
1957              description = traverse_obj(response, ('result', 'video', 0, 'summary', T(compat_str)))
1958
1959       T(...) is a shorthand for a set literal; if you hate people  who  still
1960       run  Python  2.6,  T(type_or_transformation)  could be written as a set
1961       literal {type_or_transformation}.
1962
1963       Some extractors use the older and less capable  try_get()  function  in
1964       the same way.
1965
1966              description = try_get(response, lambda x: x['result']['video'][0]['summary'], compat_str)
1967
1968   Safely extract more optional metadata
1969       In  this  example,  various optional metadata values are extracted from
1970       the .result.video[0] member of the parsed JSON response, which  is  ex‐
1971       pected  to  be  a  JS object, parsed into a dict, with no crash if that
1972       isn’t so, or if any of the target values are missing or invalid.
1973
1974              video = traverse_obj(response, ('result', 'video', 0, T(dict))) or {}
1975              # formerly:
1976              # video = try_get(response, lambda x: x['result']['video'][0], dict) or {}
1977              description = video.get('summary')
1978              duration = float_or_none(video.get('durationMs'), scale=1000)
1979              view_count = int_or_none(video.get('views'))
1980
1981   Safely extract nested lists
1982       Suppose you’ve extracted JSON like this into a  Python  data  structure
1983       named  media_json  using,  say,  the  _download_json() or _parse_json()
1984       methods of InfoExtractor:
1985
1986              {
1987                  "title": "Example video",
1988                  "comment": "try extracting this",
1989                  "media": [{
1990                      "type": "bad",
1991                      "size": 320,
1992                      "url": "https://some.cdn.site/bad.mp4"
1993                  }, {
1994                      "type": "streaming",
1995                      "url": "https://some.cdn.site/hls.m3u8"
1996                  }, {
1997                      "type": "super",
1998                      "size": 1280,
1999                      "url": "https://some.cdn.site/good.webm"
2000                  }],
2001                  "moreStuff": "more values",
2002                  ...
2003              }
2004
2005       Then extractor code like this can collect the  various  fields  of  the
2006       JSON:
2007
2008              ...
2009              from ..utils import (
2010                  determine_ext,
2011                  int_or_none,
2012                  T,
2013                  traverse_obj,
2014                  txt_or_none,
2015                  url_or_none,
2016              )
2017              ...
2018                      ...
2019                      info_dict = {}
2020                      # extract title and description if valid and not empty
2021                      info_dict.update(traverse_obj(media_json, {
2022                          'title': ('title', T(txt_or_none)),
2023                          'description': ('comment', T(txt_or_none)),
2024                      }))
2025
2026                      # extract any recognisable media formats
2027                      fmts = []
2028                      # traverse into "media" list, extract `dict`s with desired keys
2029                      for fmt in traverse_obj(media_json, ('media', Ellipsis, {
2030                              'format_id': ('type', T(txt_or_none)),
2031                              'url': ('url', T(url_or_none)),
2032                              'width': ('size', T(int_or_none)), })):
2033                          # bad `fmt` values were `None` and removed
2034                          if 'url' not in fmt:
2035                              continue
2036                          fmt_url = fmt['url']  # known to be valid URL
2037                          ext = determine_ext(fmt_url)
2038                          if ext == 'm3u8':
2039                              fmts.extend(self._extract_m3u8_formats(fmt_url, video_id, 'mp4', fatal=False))
2040                          else:
2041                              fmt['ext'] = ext
2042                              fmts.append(fmt)
2043
2044                      # sort, raise if no formats
2045                      self._sort_formats(fmts)
2046
2047                      info_dict['formats'] = fmts
2048                      ...
2049
2050       The  extractor  raises  an  exception rather than random crashes if the
2051       JSON structure changes so that no formats are found.
2052

EMBEDDING YOUTUBE-DL

2054       youtube-dl makes the best effort to be a good command-line program, and
2055       thus  should  be  callable  from  any programming language.  If you en‐
2056       counter any problems parsing its output, feel free to create  a  report
2057       (https://github.com/ytdl-org/youtube-dl/issues/new).
2058
2059       From  a  Python  program,  you  can embed youtube-dl in a more powerful
2060       fashion, like this:
2061
2062              from __future__ import unicode_literals
2063              import youtube_dl
2064
2065              ydl_opts = {}
2066              with youtube_dl.YoutubeDL(ydl_opts) as ydl:
2067                  ydl.download(['https://www.youtube.com/watch?v=BaW_jenozKc'])
2068
2069       Most likely, you’ll want to use various options.  For a list of options
2070       available,      have      a     look     at     youtube_dl/YoutubeDL.py
2071       (https://github.com/ytdl-org/youtube-
2072       dl/blob/3e4cedf9e8cd3157df2457df7274d0c842421945/youtube_dl/YoutubeDL.py#L137-L312).
2073       For a start, if you want to intercept youtube-dl’s output, set a logger
2074       object.
2075
2076       Here’s  a  more  complete example of a program that outputs only errors
2077       (and a short  message  after  the  download  is  finished),  and  down‐
2078       loads/converts the video to an mp3 file:
2079
2080              from __future__ import unicode_literals
2081              import youtube_dl
2082
2083
2084              class MyLogger(object):
2085                  def debug(self, msg):
2086                      pass
2087
2088                  def warning(self, msg):
2089                      pass
2090
2091                  def error(self, msg):
2092                      print(msg)
2093
2094
2095              def my_hook(d):
2096                  if d['status'] == 'finished':
2097                      print('Done downloading, now converting ...')
2098
2099
2100              ydl_opts = {
2101                  'format': 'bestaudio/best',
2102                  'postprocessors': [{
2103                      'key': 'FFmpegExtractAudio',
2104                      'preferredcodec': 'mp3',
2105                      'preferredquality': '192',
2106                  }],
2107                  'logger': MyLogger(),
2108                  'progress_hooks': [my_hook],
2109              }
2110              with youtube_dl.YoutubeDL(ydl_opts) as ydl:
2111                  ydl.download(['https://www.youtube.com/watch?v=BaW_jenozKc'])
2112

BUGS

2114       Bugs   and  suggestions  should  be  reported  in  the  issue  tracker:
2115       <https://github.com/ytdl-org/youtube-dl/issues>           (<https://yt-
2116       dl.org/bug>  is  an  alias  for  this).  Unless you were prompted to or
2117       there is another pertinent reason (e.g. GitHub fails to accept the  bug
2118       report),  please  do not send bug reports via personal email.  For dis‐
2119       cussions, join us in the  IRC  channel  #youtube-dl  (irc://chat.freen‐
2120       ode.net/#youtube-dl)   on   freenode  (webchat  (https://webchat.freen
2121       ode.net/?randomnick=1&channels=youtube-dl)).
2122
2123   Opening a bug report or suggestion
2124       Be sure to follow instructions provided below and in the issue tracker.
2125       Complete  the  appropriate issue template fully.  Consider whether your
2126       problem is covered by an existing issue: if so, follow  the  discussion
2127       there.   Avoid commenting on existing duplicate issues as such comments
2128       do not add to the discussion of the issue and are liable to be  treated
2129       as spam.
2130
2131       Please include the full output of youtube-dl when run with -v, i.e. add
2132       -v flag to your command line, copy the whole output and post it in  the
2133       issue  body wrapped in ``` for better formatting.  It should look simi‐
2134       lar to this:
2135
2136              $ youtube-dl -v <your command line>
2137              [debug] System config: []
2138              [debug] User config: []
2139              [debug] Command-line args: [u'-v', u'https://www.youtube.com/watch?v=BaW_jenozKcj']
2140              [debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251
2141              [debug] youtube-dl version 2015.12.06
2142              [debug] Git HEAD: 135392e
2143              [debug] Python version 2.6.6 - Windows-2003Server-5.2.3790-SP2
2144              [debug] exe versions: ffmpeg N-75573-g1d0487f, ffprobe N-75573-g1d0487f, rtmpdump 2.4
2145              [debug] Proxy map: {}
2146              ...
2147
2148       Do not post screenshots of verbose logs; only plain text is acceptable.
2149
2150       The output (including the first lines) contains important debugging in‐
2151       formation.   Issues  without the full output are often not reproducible
2152       and therefore do not get solved in short order, if ever.
2153
2154       Finally please review your issue to avoid various common mistakes  (you
2155       can and should use this as a checklist) listed below.
2156
2157   Is the description of the issue itself sufficient?
2158       We  often get issue reports that are hard to understand.  To avoid sub‐
2159       sequent clarifications, and to assist participants who are  not  native
2160       English  speakers, please elaborate on what feature you are requesting,
2161       or what bug you want to be fixed.
2162
2163       Make sure that it’s obvious
2164
2165       • What the problem is
2166
2167       • How it could be fixed
2168
2169       • How your proposed solution would look
2170
2171       If your report is shorter than two lines, it is almost certainly  miss‐
2172       ing  some of these, which makes it hard for us to respond to it.  We’re
2173       often too polite to close the issue  outright,  but  the  missing  info
2174       makes  misinterpretation  likely.   As  a committer myself, I often get
2175       frustrated by these issues, since the only possible way for me to  move
2176       forward on them is to ask for clarification over and over.
2177
2178       For  bug  reports,  this means that your report should contain the com‐
2179       plete output of youtube-dl when called with the  -v  flag.   The  error
2180       message you get for (most) bugs even says so, but you would not believe
2181       how many of our bug reports do not contain this information.
2182
2183       If your server has multiple  IPs  or  you  suspect  censorship,  adding
2184       --call-home  may  be a good idea to get more diagnostics.  If the error
2185       is ERROR: Unable to extract ... and you cannot reproduce it from multi‐
2186       ple  countries,  add  --dump-pages  (warning:  this will yield a rather
2187       large output, redirect it to the file log.txt by adding  >log.txt  2>&1
2188       to  your  command-line)  or upload the .dump files you get when you add
2189       --write-pages somewhere (https://gist.github.com/).
2190
2191       Site support requests must contain an example URL.  An example URL is a
2192       URL       you       might       want       to       download,      like
2193       https://www.youtube.com/watch?v=BaW_jenozKc.  There should be an  obvi‐
2194       ous  video  present.  Except under very special circumstances, the main
2195       page of a video service (e.g. https://www.youtube.com/) is not an exam‐
2196       ple URL.
2197
2198   Is the issue already documented?
2199       Make  sure  that someone has not already opened the issue you’re trying
2200       to open.  Search at the top of the window or browse the  GitHub  Issues
2201       (https://github.com/ytdl-org/youtube-dl/search?type=Issues)   of   this
2202       repository.  Initially, at least, use the search term  -label:duplicate
2203       to  focus  on  active issues.  If there is an issue, feel free to write
2204       something along the lines of “This affects me  as  well,  with  version
2205       2015.01.01.   Here  is some more information on the issue: ...”.  While
2206       some issues may be old, a new post into them often spurs rapid  activi‐
2207       ty.
2208
2209   Are you using the latest version?
2210       Before  reporting  any  issue,  type youtube-dl -U.  This should report
2211       that you’re up-to-date.  About 20% of the reports we  receive  are  al‐
2212       ready  fixed,  but  people  are using outdated versions.  This goes for
2213       feature requests as well.
2214
2215   Why are existing options not enough?
2216       Before requesting a new feature, please have a quick peek at  the  list
2217       of  supported options (https://github.com/ytdl-org/youtube-dl/blob/mas
2218       ter/README.md#options).  Many feature requests are  for  features  that
2219       actually  exist  already!   Please, absolutely do show off your work in
2220       the issue report and detail how the existing  similar  options  do  not
2221       solve your problem.
2222
2223   Is there enough context in your bug report?
2224       People  want  to  solve problems, and often think they do us a favor by
2225       breaking down their larger problems (e.g. wanting to skip already down‐
2226       loaded files) to a specific request (e.g. requesting us to look whether
2227       the file exists before downloading the info page).  However, what often
2228       happens is that they break down the problem into two steps: One simple,
2229       and one impossible (or extremely complicated one).
2230
2231       We are then presented with a very complicated request when the original
2232       problem  could  be  solved far easier, e.g. by recording the downloaded
2233       video IDs in a separate file.  To avoid  this,  you  must  include  the
2234       greater  context where it is non-obvious.  In particular, every feature
2235       request that does not consist of adding support for a new  site  should
2236       contain a use case scenario that explains in what situation the missing
2237       feature would be useful.
2238
2239   Does the issue involve one problem, and one problem only?
2240       Some of our users seem to think there is a limit of issues they can  or
2241       should  open.   There  is  no  limit of issues they can or should open.
2242       While it may seem appealing to be able to dump all your issues into one
2243       ticket,  that  means  that someone who solves one of your issues cannot
2244       mark the issue as closed.  Typically, reporting a bunch of issues leads
2245       to the ticket lingering since nobody wants to attack that behemoth, un‐
2246       til someone mercifully splits the issue into multiple ones.
2247
2248       In particular, every site support request issue should only pertain  to
2249       services at one site (generally under a common domain, but always using
2250       the same backend technology).  Do not request support  for  vimeo  user
2251       videos,  White house podcasts, and Google Plus pages in the same issue.
2252       Also, make sure that you don’t post bug reports alongside  feature  re‐
2253       quests.  As a rule of thumb, a feature request does not include outputs
2254       of youtube-dl that are not immediately related to the feature at  hand.
2255       Do  not post reports of a network error alongside the request for a new
2256       video service.
2257
2258   Is anyone going to need the feature?
2259       Only post features that you (or an incapacitated friend you can person‐
2260       ally  talk  to) require.  Do not post features because they seem like a
2261       good idea.  If they are really useful, they will be requested by  some‐
2262       one who requires them.
2263
2264   Is your question about youtube-dl?
2265       It  may  sound  strange, but some bug reports we receive are completely
2266       unrelated to youtube-dl and relate to a  different,  or  even  the  re‐
2267       porter’s  own, application.  Please make sure that you are actually us‐
2268       ing youtube-dl.  If you are using a UI for youtube-dl, report  the  bug
2269       to  the  maintainer of the actual application providing the UI.  On the
2270       other hand, if your UI for youtube-dl fails in some way you believe  is
2271       related to youtube-dl, by all means, go ahead and report the bug.
2272
2274       youtube-dl is released into the public domain by the copyright holders.
2275
2276       This   README   file   was   originally   written   by   Daniel  Bolton
2277       (https://github.com/dbbolton) and is likewise released into the  public
2278       domain.
2279
2280
2281
2282                                                                 YOUTUBE-DL(1)
Impressum