1 .TH "YOUTUBE\-DL" "1" "" "" ""
 
   4 youtube\-dl \- download videos from youtube.com or other video platforms
 
   7 \f[B]youtube\-dl\f[] [OPTIONS] URL [URL...]
 
  10 \f[B]youtube\-dl\f[] is a command\-line program to download videos from
 
  11 YouTube.com and a few more sites.
 
  12 It requires the Python interpreter, version 2.6, 2.7, or 3.2+, and it is
 
  13 not platform specific.
 
  14 It should work on your Unix box, on Windows or on Mac OS X.
 
  15 It is released to the public domain, which means you can modify it,
 
  16 redistribute it or use it however you like.
 
  20 Print this help text and exit
 
  25 Print program version and exit
 
  30 Update this program to latest version.
 
  31 Make sure that you have sufficient permissions (run with sudo if needed)
 
  35 .B \-i, \-\-ignore\-errors
 
  36 Continue on download errors, for example to skip unavailable videos in a
 
  41 .B \-\-abort\-on\-error
 
  42 Abort downloading of further videos (in the playlist or the command
 
  43 line) if an error occurs
 
  47 .B \-\-dump\-user\-agent
 
  48 Display the current browser identification
 
  52 .B \-\-list\-extractors
 
  53 List all supported extractors
 
  57 .B \-\-extractor\-descriptions
 
  58 Output descriptions of all supported extractors
 
  62 .B \-\-force\-generic\-extractor
 
  63 Force extraction to use the generic extractor
 
  67 .B \-\-default\-search \f[I]PREFIX\f[]
 
  68 Use this prefix for unqualified URLs.
 
  69 For example "gvsearch2:" downloads two videos from google videos for
 
  70 youtube\-dl "large apple".
 
  71 Use the value "auto" to let youtube\-dl guess ("auto_warning" to emit a
 
  72 warning when guessing).
 
  73 "error" just throws an error.
 
  74 The default value "fixup_error" repairs broken URLs, but emits an error
 
  75 if this is not possible instead of searching.
 
  80 Do not read configuration files.
 
  81 When given in the global configuration file /etc/youtube\-dl.conf: Do
 
  82 not read the user configuration in ~/.config/youtube\- dl/config
 
  83 (%APPDATA%/youtube\-dl/config.txt on Windows)
 
  87 .B \-\-config\-location \f[I]PATH\f[]
 
  88 Location of the configuration file; either the path to the config or its
 
  94 Do not extract the videos of a playlist, only list them.
 
  99 Mark videos watched (YouTube only)
 
 103 .B \-\-no\-mark\-watched
 
 104 Do not mark videos watched (YouTube only)
 
 109 Do not emit color codes in output
 
 114 .B \-\-proxy \f[I]URL\f[]
 
 115 Use the specified HTTP/HTTPS/SOCKS proxy.
 
 116 To enable experimental SOCKS proxy, specify a proper scheme.
 
 117 For example socks5://127.0.0.1:1080/.
 
 118 Pass in an empty string (\-\-proxy "") for direct connection
 
 122 .B \-\-socket\-timeout \f[I]SECONDS\f[]
 
 123 Time to wait before giving up, in seconds
 
 127 .B \-\-source\-address \f[I]IP\f[]
 
 128 Client\-side IP address to bind to
 
 132 .B \-4, \-\-force\-ipv4
 
 133 Make all connections via IPv4
 
 137 .B \-6, \-\-force\-ipv6
 
 138 Make all connections via IPv6
 
 143 .B \-\-geo\-verification\-proxy \f[I]URL\f[]
 
 144 Use this proxy to verify the IP address for some geo\-restricted sites.
 
 145 The default proxy specified by \-\-proxy (or none, if the options is not
 
 146 present) is used for the actual downloading.
 
 151 Bypass geographic restriction via faking X\-Forwarded\-For HTTP header
 
 156 .B \-\-no\-geo\-bypass
 
 157 Do not bypass geographic restriction via faking X\-Forwarded\-For HTTP
 
 158 header (experimental)
 
 162 .B \-\-geo\-bypass\-country \f[I]CODE\f[]
 
 163 Force bypass geographic restriction with explicitly provided two\-letter
 
 164 ISO 3166\-2 country code (experimental)
 
 169 .B \-\-playlist\-start \f[I]NUMBER\f[]
 
 170 Playlist video to start at (default is 1)
 
 174 .B \-\-playlist\-end \f[I]NUMBER\f[]
 
 175 Playlist video to end at (default is last)
 
 179 .B \-\-playlist\-items \f[I]ITEM_SPEC\f[]
 
 180 Playlist video items to download.
 
 181 Specify indices of the videos in the playlist separated by commas like:
 
 182 "\-\-playlist\-items 1,2,5,8" if you want to download videos indexed 1,
 
 183 2, 5, 8 in the playlist.
 
 184 You can specify range: "\-\-playlist\-items 1\-3,7,10\-13", it will
 
 185 download the videos at index 1, 2, 3, 7, 10, 11, 12 and 13.
 
 189 .B \-\-match\-title \f[I]REGEX\f[]
 
 190 Download only matching titles (regex or caseless sub\-string)
 
 194 .B \-\-reject\-title \f[I]REGEX\f[]
 
 195 Skip download for matching titles (regex or caseless sub\-string)
 
 199 .B \-\-max\-downloads \f[I]NUMBER\f[]
 
 200 Abort after downloading NUMBER files
 
 204 .B \-\-min\-filesize \f[I]SIZE\f[]
 
 205 Do not download any videos smaller than SIZE (e.g.
 
 210 .B \-\-max\-filesize \f[I]SIZE\f[]
 
 211 Do not download any videos larger than SIZE (e.g.
 
 216 .B \-\-date \f[I]DATE\f[]
 
 217 Download only videos uploaded in this date
 
 221 .B \-\-datebefore \f[I]DATE\f[]
 
 222 Download only videos uploaded on or before this date (i.e.
 
 227 .B \-\-dateafter \f[I]DATE\f[]
 
 228 Download only videos uploaded on or after this date (i.e.
 
 233 .B \-\-min\-views \f[I]COUNT\f[]
 
 234 Do not download any videos with less than COUNT views
 
 238 .B \-\-max\-views \f[I]COUNT\f[]
 
 239 Do not download any videos with more than COUNT views
 
 243 .B \-\-match\-filter \f[I]FILTER\f[]
 
 244 Generic video filter.
 
 245 Specify any key (see help for \-o for a list of available keys) to match
 
 246 if the key is present, !key to check if the key is not present, key >
 
 247 NUMBER (like "comment_count > 12", also works with >=, <, <=, !=, =) to
 
 248 compare against a number, key = \[aq]LITERAL\[aq] (like "uploader =
 
 249 \[aq]Mike Smith\[aq]", also works with !=) to match against a string
 
 250 literal and & to require multiple matches.
 
 251 Values which are not known are excluded unless you put a question mark
 
 252 (?) after the operator.
 
 253 For example, to only match videos that have been liked more than 100
 
 254 times and disliked less than 50 times (or the dislike functionality is
 
 255 not available at the given service), but who also have a description,
 
 256 use \-\-match\-filter "like_count > 100 & dislike_count <?
 
 262 Download only the video, if the URL refers to a video and a playlist.
 
 267 Download the playlist, if the URL refers to a video and a playlist.
 
 271 .B \-\-age\-limit \f[I]YEARS\f[]
 
 272 Download only videos suitable for the given age
 
 276 .B \-\-download\-archive \f[I]FILE\f[]
 
 277 Download only videos not listed in the archive file.
 
 278 Record the IDs of all downloaded videos in it.
 
 283 Download advertisements as well (experimental)
 
 286 .SS Download Options:
 
 288 .B \-r, \-\-limit\-rate \f[I]RATE\f[]
 
 289 Maximum download rate in bytes per second (e.g.
 
 294 .B \-R, \-\-retries \f[I]RETRIES\f[]
 
 295 Number of retries (default is 10), or "infinite".
 
 299 .B \-\-fragment\-retries \f[I]RETRIES\f[]
 
 300 Number of retries for a fragment (default is 10), or "infinite" (DASH
 
 305 .B \-\-skip\-unavailable\-fragments
 
 306 Skip unavailable fragments (DASH and hlsnative only)
 
 310 .B \-\-abort\-on\-unavailable\-fragment
 
 311 Abort downloading when some fragment is not available
 
 315 .B \-\-buffer\-size \f[I]SIZE\f[]
 
 316 Size of download buffer (e.g.
 
 317 1024 or 16K) (default is 1024)
 
 321 .B \-\-no\-resize\-buffer
 
 322 Do not automatically adjust the buffer size.
 
 323 By default, the buffer size is automatically resized from an initial
 
 328 .B \-\-playlist\-reverse
 
 329 Download playlist videos in reverse order
 
 333 .B \-\-playlist\-random
 
 334 Download playlist videos in random order
 
 338 .B \-\-xattr\-set\-filesize
 
 339 Set file xattribute ytdl.filesize with expected file size (experimental)
 
 343 .B \-\-hls\-prefer\-native
 
 344 Use the native HLS downloader instead of ffmpeg
 
 348 .B \-\-hls\-prefer\-ffmpeg
 
 349 Use ffmpeg instead of the native HLS downloader
 
 353 .B \-\-hls\-use\-mpegts
 
 354 Use the mpegts container for HLS videos, allowing to play the video
 
 355 while downloading (some players may not be able to play it)
 
 359 .B \-\-external\-downloader \f[I]COMMAND\f[]
 
 360 Use the specified external downloader.
 
 361 Currently supports aria2c,avconv,axel,curl,ffmpeg,httpie,wget
 
 365 .B \-\-external\-downloader\-args \f[I]ARGS\f[]
 
 366 Give these arguments to the external downloader
 
 369 .SS Filesystem Options:
 
 371 .B \-a, \-\-batch\-file \f[I]FILE\f[]
 
 372 File containing URLs to download (\[aq]\-\[aq] for stdin)
 
 377 Use only video ID in file name
 
 381 .B \-o, \-\-output \f[I]TEMPLATE\f[]
 
 382 Output filename template, see the "OUTPUT TEMPLATE" for all the info
 
 386 .B \-\-autonumber\-start \f[I]NUMBER\f[]
 
 387 Specify the start value for %(autonumber)s (default is 1)
 
 391 .B \-\-restrict\-filenames
 
 392 Restrict filenames to only ASCII characters, and avoid "&" and spaces in
 
 397 .B \-w, \-\-no\-overwrites
 
 398 Do not overwrite files
 
 403 Force resume of partially downloaded files.
 
 404 By default, youtube\-dl will resume downloads if possible.
 
 409 Do not resume partially downloaded files (restart from beginning)
 
 414 Do not use .part files \- write directly into output file
 
 419 Do not use the Last\-modified header to set the file modification time
 
 423 .B \-\-write\-description
 
 424 Write video description to a .description file
 
 428 .B \-\-write\-info\-json
 
 429 Write video metadata to a .info.json file
 
 433 .B \-\-write\-annotations
 
 434 Write video annotations to a .annotations.xml file
 
 438 .B \-\-load\-info\-json \f[I]FILE\f[]
 
 439 JSON file containing the video information (created with the
 
 440 "\-\-write\-info\-json" option)
 
 444 .B \-\-cookies \f[I]FILE\f[]
 
 445 File to read cookies from and dump cookie jar in
 
 449 .B \-\-cache\-dir \f[I]DIR\f[]
 
 450 Location in the filesystem where youtube\-dl can store some downloaded
 
 451 information permanently.
 
 452 By default $XDG_CACHE_HOME/youtube\-dl or ~/.cache/youtube\-dl .
 
 453 At the moment, only YouTube player files (for videos with obfuscated
 
 454 signatures) are cached, but that may change.
 
 458 .B \-\-no\-cache\-dir
 
 459 Disable filesystem caching
 
 463 .B \-\-rm\-cache\-dir
 
 464 Delete all filesystem cache files
 
 467 .SS Thumbnail images:
 
 469 .B \-\-write\-thumbnail
 
 470 Write thumbnail image to disk
 
 474 .B \-\-write\-all\-thumbnails
 
 475 Write all thumbnail image formats to disk
 
 479 .B \-\-list\-thumbnails
 
 480 Simulate and list all available thumbnail formats
 
 483 .SS Verbosity / Simulation Options:
 
 496 Do not download the video and do not write anything to disk
 
 500 .B \-\-skip\-download
 
 501 Do not download the video
 
 506 Simulate, quiet but print URL
 
 510 .B \-e, \-\-get\-title
 
 511 Simulate, quiet but print title
 
 516 Simulate, quiet but print id
 
 520 .B \-\-get\-thumbnail
 
 521 Simulate, quiet but print thumbnail URL
 
 525 .B \-\-get\-description
 
 526 Simulate, quiet but print video description
 
 531 Simulate, quiet but print video length
 
 536 Simulate, quiet but print output filename
 
 541 Simulate, quiet but print output format
 
 545 .B \-j, \-\-dump\-json
 
 546 Simulate, quiet but print JSON information.
 
 547 See \-\-output for a description of available keys.
 
 551 .B \-J, \-\-dump\-single\-json
 
 552 Simulate, quiet but print JSON information for each command\-line
 
 554 If the URL refers to a playlist, dump the whole playlist information in
 
 560 Be quiet and print the video information as JSON (video is still being
 
 566 Output progress bar as new lines
 
 571 Do not print progress bar
 
 575 .B \-\-console\-title
 
 576 Display progress in console titlebar
 
 581 Print various debugging information
 
 586 Print downloaded pages encoded using base64 to debug problems (very
 
 592 Write downloaded intermediary pages to files in the current directory to
 
 597 .B \-\-print\-traffic
 
 598 Display sent and read HTTP traffic
 
 602 .B \-C, \-\-call\-home
 
 603 Contact the youtube\-dl server for debugging
 
 607 .B \-\-no\-call\-home
 
 608 Do NOT contact the youtube\-dl server for debugging
 
 613 .B \-\-encoding \f[I]ENCODING\f[]
 
 614 Force the specified encoding (experimental)
 
 618 .B \-\-no\-check\-certificate
 
 619 Suppress HTTPS certificate validation
 
 623 .B \-\-prefer\-insecure
 
 624 Use an unencrypted connection to retrieve information about the video.
 
 625 (Currently supported only for YouTube)
 
 629 .B \-\-user\-agent \f[I]UA\f[]
 
 630 Specify a custom user agent
 
 634 .B \-\-referer \f[I]URL\f[]
 
 635 Specify a custom referer, use if the video access is restricted to one
 
 640 .B \-\-add\-header \f[I]FIELD:VALUE\f[]
 
 641 Specify a custom HTTP header and its value, separated by a colon
 
 643 You can use this option multiple times
 
 647 .B \-\-bidi\-workaround
 
 648 Work around terminals that lack bidirectional text support.
 
 649 Requires bidiv or fribidi executable in PATH
 
 653 .B \-\-sleep\-interval \f[I]SECONDS\f[]
 
 654 Number of seconds to sleep before each download when used alone or a
 
 655 lower bound of a range for randomized sleep before each download
 
 656 (minimum possible number of seconds to sleep) when used along with
 
 657 \-\-max\-sleep\-interval.
 
 661 .B \-\-max\-sleep\-interval \f[I]SECONDS\f[]
 
 662 Upper bound of a range for randomized sleep before each download
 
 663 (maximum possible number of seconds to sleep).
 
 664 Must only be used along with \-\-min\-sleep\-interval.
 
 667 .SS Video Format Options:
 
 669 .B \-f, \-\-format \f[I]FORMAT\f[]
 
 670 Video format code, see the "FORMAT SELECTION" for all the info
 
 675 Download all available video formats
 
 679 .B \-\-prefer\-free\-formats
 
 680 Prefer free video formats unless a specific one is requested
 
 684 .B \-F, \-\-list\-formats
 
 685 List all available formats of requested videos
 
 689 .B \-\-youtube\-skip\-dash\-manifest
 
 690 Do not download the DASH manifests and related data on YouTube videos
 
 694 .B \-\-merge\-output\-format \f[I]FORMAT\f[]
 
 695 If a merge is required (e.g.
 
 696 bestvideo+bestaudio), output to given container format.
 
 697 One of mkv, mp4, ogg, webm, flv.
 
 698 Ignored if no merge is required
 
 701 .SS Subtitle Options:
 
 708 .B \-\-write\-auto\-sub
 
 709 Write automatically generated subtitle file (YouTube only)
 
 714 Download all the available subtitles of the video
 
 719 List all available subtitles for the video
 
 723 .B \-\-sub\-format \f[I]FORMAT\f[]
 
 724 Subtitle format, accepts formats preference, for example: "srt" or
 
 729 .B \-\-sub\-lang \f[I]LANGS\f[]
 
 730 Languages of the subtitles to download (optional) separated by commas,
 
 731 use \-\-list\- subs for available language tags
 
 734 .SS Authentication Options:
 
 736 .B \-u, \-\-username \f[I]USERNAME\f[]
 
 737 Login with this account ID
 
 741 .B \-p, \-\-password \f[I]PASSWORD\f[]
 
 743 If this option is left out, youtube\-dl will ask interactively.
 
 747 .B \-2, \-\-twofactor \f[I]TWOFACTOR\f[]
 
 748 Two\-factor authentication code
 
 753 Use .netrc authentication data
 
 757 .B \-\-video\-password \f[I]PASSWORD\f[]
 
 758 Video password (vimeo, smotri, youku)
 
 761 .SS Adobe Pass Options:
 
 763 .B \-\-ap\-mso \f[I]MSO\f[]
 
 764 Adobe Pass multiple\-system operator (TV provider) identifier, use
 
 765 \-\-ap\-list\-mso for a list of available MSOs
 
 769 .B \-\-ap\-username \f[I]USERNAME\f[]
 
 770 Multiple\-system operator account login
 
 774 .B \-\-ap\-password \f[I]PASSWORD\f[]
 
 775 Multiple\-system operator account password.
 
 776 If this option is left out, youtube\-dl will ask interactively.
 
 781 List all supported multiple\-system operators
 
 784 .SS Post\-processing Options:
 
 786 .B \-x, \-\-extract\-audio
 
 787 Convert video files to audio\-only files (requires ffmpeg or avconv and
 
 792 .B \-\-audio\-format \f[I]FORMAT\f[]
 
 793 Specify audio format: "best", "aac", "flac", "mp3", "m4a", "opus",
 
 794 "vorbis", or "wav"; "best" by default; No effect without \-x
 
 798 .B \-\-audio\-quality \f[I]QUALITY\f[]
 
 799 Specify ffmpeg/avconv audio quality, insert a value between 0 (better)
 
 800 and 9 (worse) for VBR or a specific bitrate like 128K (default 5)
 
 804 .B \-\-recode\-video \f[I]FORMAT\f[]
 
 805 Encode the video to another format if necessary (currently supported:
 
 806 mp4|flv|ogg|webm|mkv|avi)
 
 810 .B \-\-postprocessor\-args \f[I]ARGS\f[]
 
 811 Give these arguments to the postprocessor
 
 815 .B \-k, \-\-keep\-video
 
 816 Keep the video file on disk after the post\- processing; the video is
 
 821 .B \-\-no\-post\-overwrites
 
 822 Do not overwrite post\-processed files; the post\-processed files are
 
 823 overwritten by default
 
 828 Embed subtitles in the video (only for mp4, webm and mkv videos)
 
 832 .B \-\-embed\-thumbnail
 
 833 Embed thumbnail in the audio as cover art
 
 838 Write metadata to the video file
 
 842 .B \-\-metadata\-from\-title \f[I]FORMAT\f[]
 
 843 Parse additional metadata like song title / artist from the video title.
 
 844 The format syntax is the same as \-\-output, the parsed parameters
 
 845 replace existing values.
 
 846 Additional templates: %(album)s, %(artist)s.
 
 847 Example: \-\-metadata\-from\-title "%(artist)s \- %(title)s" matches a
 
 848 title like "Coldplay \- Paradise"
 
 853 Write metadata to the video file\[aq]s xattrs (using dublin core and xdg
 
 858 .B \-\-fixup \f[I]POLICY\f[]
 
 859 Automatically correct known faults of the file.
 
 860 One of never (do nothing), warn (only emit a warning), detect_or_warn
 
 861 (the default; fix file if we can, warn otherwise)
 
 865 .B \-\-prefer\-avconv
 
 866 Prefer avconv over ffmpeg for running the postprocessors (default)
 
 870 .B \-\-prefer\-ffmpeg
 
 871 Prefer ffmpeg over avconv for running the postprocessors
 
 875 .B \-\-ffmpeg\-location \f[I]PATH\f[]
 
 876 Location of the ffmpeg/avconv binary; either the path to the binary or
 
 877 its containing directory.
 
 881 .B \-\-exec \f[I]CMD\f[]
 
 882 Execute a command on the file after downloading, similar to find\[aq]s
 
 884 Example: \-\-exec \[aq]adb push {} /sdcard/Music/ && rm {}\[aq]
 
 888 .B \-\-convert\-subs \f[I]FORMAT\f[]
 
 889 Convert the subtitles to other format (currently supported: srt|ass|vtt)
 
 894 You can configure youtube\-dl by placing any supported command line
 
 895 option to a configuration file.
 
 896 On Linux and OS X, the system wide configuration file is located at
 
 897 \f[C]/etc/youtube\-dl.conf\f[] and the user wide configuration file at
 
 898 \f[C]~/.config/youtube\-dl/config\f[].
 
 899 On Windows, the user wide configuration file locations are
 
 900 \f[C]%APPDATA%\\youtube\-dl\\config.txt\f[] or
 
 901 \f[C]C:\\Users\\<user\ name>\\youtube\-dl.conf\f[].
 
 902 Note that by default configuration file may not exist so you may need to
 
 905 For example, with the following configuration file youtube\-dl will
 
 906 always extract the audio, not copy the mtime, use a proxy and save all
 
 907 videos under \f[C]Movies\f[] directory in your home directory:
 
 911 #\ Lines\ starting\ with\ #\ are\ comments
 
 913 #\ Always\ extract\ audio
 
 916 #\ Do\ not\ copy\ the\ mtime
 
 920 \-\-proxy\ 127.0.0.1:3128
 
 922 #\ Save\ all\ videos\ under\ Movies\ directory\ in\ your\ home\ directory
 
 923 \-o\ ~/Movies/%(title)s.%(ext)s
 
 927 Note that options in configuration file are just the same options aka
 
 928 switches used in regular command line calls thus there \f[B]must be no
 
 929 whitespace\f[] after \f[C]\-\f[] or \f[C]\-\-\f[], e.g.
 
 930 \f[C]\-o\f[] or \f[C]\-\-proxy\f[] but not \f[C]\-\ o\f[] or
 
 931 \f[C]\-\-\ proxy\f[].
 
 933 You can use \f[C]\-\-ignore\-config\f[] if you want to disable the
 
 934 configuration file for a particular youtube\-dl run.
 
 936 You can also use \f[C]\-\-config\-location\f[] if you want to use custom
 
 937 configuration file for a particular youtube\-dl run.
 
 938 .SS Authentication with \f[C]\&.netrc\f[] file
 
 940 You may also want to configure automatic credentials storage for
 
 941 extractors that support authentication (by providing login and password
 
 942 with \f[C]\-\-username\f[] and \f[C]\-\-password\f[]) in order not to
 
 943 pass credentials as command line arguments on every youtube\-dl
 
 944 execution and prevent tracking plain text passwords in the shell command
 
 946 You can achieve this using a \f[C]\&.netrc\f[]
 
 947 file (http://stackoverflow.com/tags/.netrc/info) on a per extractor
 
 949 For that you will need to create a \f[C]\&.netrc\f[] file in your
 
 950 \f[C]$HOME\f[] and restrict permissions to read/write by only you:
 
 955 chmod\ a\-rwx,u+rw\ $HOME/.netrc
 
 959 After that you can add credentials for an extractor in the following
 
 960 format, where \f[I]extractor\f[] is the name of the extractor in
 
 965 machine\ <extractor>\ login\ <login>\ password\ <password>
 
 973 machine\ youtube\ login\ myaccount\@gmail.com\ password\ my_youtube_password
 
 974 machine\ twitch\ login\ my_twitch_account_name\ password\ my_twitch_password
 
 978 To activate authentication with the \f[C]\&.netrc\f[] file you should
 
 979 pass \f[C]\-\-netrc\f[] to youtube\-dl or place it in the configuration
 
 980 file (#configuration).
 
 982 On Windows you may also need to setup the \f[C]%HOME%\f[] environment
 
 986 The \f[C]\-o\f[] option allows users to indicate a template for the
 
 989 \f[B]tl;dr:\f[] navigate me to examples (#output-template-examples).
 
 991 The basic usage is not to set any template arguments when downloading a
 
 993 \f[C]youtube\-dl\ \-o\ funny_video.flv\ "http://some/video"\f[].
 
 994 However, it may contain special sequences that will be replaced when
 
 995 downloading each video.
 
 996 The special sequences may be formatted according to python string
 
 998 operations (https://docs.python.org/2/library/stdtypes.html#string-formatting).
 
 999 For example, \f[C]%(NAME)s\f[] or \f[C]%(NAME)05d\f[].
 
1000 To clarify, that is a percent symbol followed by a name in parentheses,
 
1001 followed by a formatting operations.
 
1002 Allowed names along with sequence type are:
 
1004 \f[C]id\f[] (string): Video identifier
 
1006 \f[C]title\f[] (string): Video title
 
1008 \f[C]url\f[] (string): Video URL
 
1010 \f[C]ext\f[] (string): Video filename extension
 
1012 \f[C]alt_title\f[] (string): A secondary title of the video
 
1014 \f[C]display_id\f[] (string): An alternative identifier for the video
 
1016 \f[C]uploader\f[] (string): Full name of the video uploader
 
1018 \f[C]license\f[] (string): License name the video is licensed under
 
1020 \f[C]creator\f[] (string): The creator of the video
 
1022 \f[C]release_date\f[] (string): The date (YYYYMMDD) when the video was
 
1025 \f[C]timestamp\f[] (numeric): UNIX timestamp of the moment the video
 
1028 \f[C]upload_date\f[] (string): Video upload date (YYYYMMDD)
 
1030 \f[C]uploader_id\f[] (string): Nickname or id of the video uploader
 
1032 \f[C]location\f[] (string): Physical location where the video was filmed
 
1034 \f[C]duration\f[] (numeric): Length of the video in seconds
 
1036 \f[C]view_count\f[] (numeric): How many users have watched the video on
 
1039 \f[C]like_count\f[] (numeric): Number of positive ratings of the video
 
1041 \f[C]dislike_count\f[] (numeric): Number of negative ratings of the
 
1044 \f[C]repost_count\f[] (numeric): Number of reposts of the video
 
1046 \f[C]average_rating\f[] (numeric): Average rating give by users, the
 
1047 scale used depends on the webpage
 
1049 \f[C]comment_count\f[] (numeric): Number of comments on the video
 
1051 \f[C]age_limit\f[] (numeric): Age restriction for the video (years)
 
1053 \f[C]format\f[] (string): A human\-readable description of the format
 
1055 \f[C]format_id\f[] (string): Format code specified by
 
1058 \f[C]format_note\f[] (string): Additional info about the format
 
1060 \f[C]width\f[] (numeric): Width of the video
 
1062 \f[C]height\f[] (numeric): Height of the video
 
1064 \f[C]resolution\f[] (string): Textual description of width and height
 
1066 \f[C]tbr\f[] (numeric): Average bitrate of audio and video in KBit/s
 
1068 \f[C]abr\f[] (numeric): Average audio bitrate in KBit/s
 
1070 \f[C]acodec\f[] (string): Name of the audio codec in use
 
1072 \f[C]asr\f[] (numeric): Audio sampling rate in Hertz
 
1074 \f[C]vbr\f[] (numeric): Average video bitrate in KBit/s
 
1076 \f[C]fps\f[] (numeric): Frame rate
 
1078 \f[C]vcodec\f[] (string): Name of the video codec in use
 
1080 \f[C]container\f[] (string): Name of the container format
 
1082 \f[C]filesize\f[] (numeric): The number of bytes, if known in advance
 
1084 \f[C]filesize_approx\f[] (numeric): An estimate for the number of bytes
 
1086 \f[C]protocol\f[] (string): The protocol that will be used for the
 
1089 \f[C]extractor\f[] (string): Name of the extractor
 
1091 \f[C]extractor_key\f[] (string): Key name of the extractor
 
1093 \f[C]epoch\f[] (numeric): Unix epoch when creating the file
 
1095 \f[C]autonumber\f[] (numeric): Five\-digit number that will be increased
 
1096 with each download, starting at zero
 
1098 \f[C]playlist\f[] (string): Name or id of the playlist that contains the
 
1101 \f[C]playlist_index\f[] (numeric): Index of the video in the playlist
 
1102 padded with leading zeros according to the total length of the playlist
 
1104 \f[C]playlist_id\f[] (string): Playlist identifier
 
1106 \f[C]playlist_title\f[] (string): Playlist title
 
1108 Available for the video that belongs to some logical chapter or section:
 
1109 \- \f[C]chapter\f[] (string): Name or title of the chapter the video
 
1110 belongs to \- \f[C]chapter_number\f[] (numeric): Number of the chapter
 
1111 the video belongs to \- \f[C]chapter_id\f[] (string): Id of the chapter
 
1112 the video belongs to
 
1114 Available for the video that is an episode of some series or programme:
 
1115 \- \f[C]series\f[] (string): Title of the series or programme the video
 
1116 episode belongs to \- \f[C]season\f[] (string): Title of the season the
 
1117 video episode belongs to \- \f[C]season_number\f[] (numeric): Number of
 
1118 the season the video episode belongs to \- \f[C]season_id\f[] (string):
 
1119 Id of the season the video episode belongs to \- \f[C]episode\f[]
 
1120 (string): Title of the video episode \- \f[C]episode_number\f[]
 
1121 (numeric): Number of the video episode within a season \-
 
1122 \f[C]episode_id\f[] (string): Id of the video episode
 
1124 Available for the media that is a track or a part of a music album: \-
 
1125 \f[C]track\f[] (string): Title of the track \- \f[C]track_number\f[]
 
1126 (numeric): Number of the track within an album or a disc \-
 
1127 \f[C]track_id\f[] (string): Id of the track \- \f[C]artist\f[] (string):
 
1128 Artist(s) of the track \- \f[C]genre\f[] (string): Genre(s) of the track
 
1129 \- \f[C]album\f[] (string): Title of the album the track belongs to \-
 
1130 \f[C]album_type\f[] (string): Type of the album \- \f[C]album_artist\f[]
 
1131 (string): List of all artists appeared on the album \-
 
1132 \f[C]disc_number\f[] (numeric): Number of the disc or other physical
 
1133 medium the track belongs to \- \f[C]release_year\f[] (numeric): Year
 
1134 (YYYY) when the album was released
 
1136 Each aforementioned sequence when referenced in an output template will
 
1137 be replaced by the actual value corresponding to the sequence name.
 
1138 Note that some of the sequences are not guaranteed to be present since
 
1139 they depend on the metadata obtained by a particular extractor.
 
1140 Such sequences will be replaced with \f[C]NA\f[].
 
1142 For example for \f[C]\-o\ %(title)s\-%(id)s.%(ext)s\f[] and an mp4 video
 
1143 with title \f[C]youtube\-dl\ test\ video\f[] and id
 
1144 \f[C]BaW_jenozKcj\f[], this will result in a
 
1145 \f[C]youtube\-dl\ test\ video\-BaW_jenozKcj.mp4\f[] file created in the
 
1148 For numeric sequences you can use numeric related formatting, for
 
1149 example, \f[C]%(view_count)05d\f[] will result in a string with view
 
1150 count padded with zeros up to 5 characters, like in \f[C]00042\f[].
 
1152 Output templates can also contain arbitrary hierarchical path, e.g.
 
1153 \f[C]\-o\ \[aq]%(playlist)s/%(playlist_index)s\ \-\ %(title)s.%(ext)s\[aq]\f[]
 
1154 which will result in downloading each video in a directory corresponding
 
1155 to this path template.
 
1156 Any missing directory will be automatically created for you.
 
1158 To use percent literals in an output template use \f[C]%%\f[].
 
1159 To output to stdout use \f[C]\-o\ \-\f[].
 
1161 The current default template is \f[C]%(title)s\-%(id)s.%(ext)s\f[].
 
1163 In some cases, you don\[aq]t want special characters such as äø, spaces,
 
1164 or &, such as when transferring the downloaded filename to a Windows
 
1165 system or the filename through an 8bit\-unsafe channel.
 
1166 In these cases, add the \f[C]\-\-restrict\-filenames\f[] flag to get a
 
1168 .SS Output template and Windows batch files
 
1170 If you are using an output template inside a Windows batch file then you
 
1171 must escape plain percent characters (\f[C]%\f[]) by doubling, so that
 
1172 \f[C]\-o\ "%(title)s\-%(id)s.%(ext)s"\f[] should become
 
1173 \f[C]\-o\ "%%(title)s\-%%(id)s.%%(ext)s"\f[].
 
1174 However you should not touch \f[C]%\f[]\[aq]s that are not plain
 
1176 environment variables for expansion should stay intact:
 
1177 \f[C]\-o\ "C:\\%HOMEPATH%\\Desktop\\%%(title)s.%%(ext)s"\f[].
 
1178 .SS Output template examples
 
1180 Note on Windows you may need to use double quotes instead of single.
 
1184 $\ youtube\-dl\ \-\-get\-filename\ \-o\ \[aq]%(title)s.%(ext)s\[aq]\ BaW_jenozKc
 
1185 youtube\-dl\ test\ video\ \[aq]\[aq]_Ƥāš.mp4\ \ \ \ #\ All\ kinds\ of\ weird\ characters
 
1187 $\ youtube\-dl\ \-\-get\-filename\ \-o\ \[aq]%(title)s.%(ext)s\[aq]\ BaW_jenozKc\ \-\-restrict\-filenames
 
1188 youtube\-dl_test_video_.mp4\ \ \ \ \ \ \ \ \ \ #\ A\ simple\ file\ name
 
1190 #\ Download\ YouTube\ playlist\ videos\ in\ separate\ directory\ indexed\ by\ video\ order\ in\ a\ playlist
 
1191 $\ youtube\-dl\ \-o\ \[aq]%(playlist)s/%(playlist_index)s\ \-\ %(title)s.%(ext)s\[aq]\ https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re
 
1193 #\ Download\ all\ playlists\ of\ YouTube\ channel/user\ keeping\ each\ playlist\ in\ separate\ directory:
 
1194 $\ youtube\-dl\ \-o\ \[aq]%(uploader)s/%(playlist)s/%(playlist_index)s\ \-\ %(title)s.%(ext)s\[aq]\ https://www.youtube.com/user/TheLinuxFoundation/playlists
 
1196 #\ Download\ Udemy\ course\ keeping\ each\ chapter\ in\ separate\ directory\ under\ MyVideos\ directory\ in\ your\ home
 
1197 $\ youtube\-dl\ \-u\ user\ \-p\ password\ \-o\ \[aq]~/MyVideos/%(playlist)s/%(chapter_number)s\ \-\ %(chapter)s/%(title)s.%(ext)s\[aq]\ https://www.udemy.com/java\-tutorial/
 
1199 #\ Download\ entire\ series\ season\ keeping\ each\ series\ and\ each\ season\ in\ separate\ directory\ under\ C:/MyVideos
 
1200 $\ youtube\-dl\ \-o\ "C:/MyVideos/%(series)s/%(season_number)s\ \-\ %(season)s/%(episode_number)s\ \-\ %(episode)s.%(ext)s"\ http://videomore.ru/kino_v_detalayah/5_sezon/367617
 
1202 #\ Stream\ the\ video\ being\ downloaded\ to\ stdout
 
1203 $\ youtube\-dl\ \-o\ \-\ BaW_jenozKc
 
1206 .SH FORMAT SELECTION
 
1208 By default youtube\-dl tries to download the best available quality,
 
1210 if you want the best quality you \f[B]don\[aq]t need\f[] to pass any
 
1211 special options, youtube\-dl will guess it for you by \f[B]default\f[].
 
1213 But sometimes you may want to download in a different format, for
 
1214 example when you are on a slow or intermittent connection.
 
1215 The key mechanism for achieving this is so\-called \f[I]format
 
1216 selection\f[] based on which you can explicitly specify desired format,
 
1217 select formats based on some criterion or criteria, setup precedence and
 
1220 The general syntax for format selection is \f[C]\-\-format\ FORMAT\f[]
 
1221 or shorter \f[C]\-f\ FORMAT\f[] where \f[C]FORMAT\f[] is a \f[I]selector
 
1222 expression\f[], i.e.
 
1223 an expression that describes format or formats you would like to
 
1226 \f[B]tl;dr:\f[] navigate me to examples (#format-selection-examples).
 
1228 The simplest case is requesting a specific format, for example with
 
1229 \f[C]\-f\ 22\f[] you can download the format with format code equal to
 
1231 You can get the list of available format codes for particular video
 
1232 using \f[C]\-\-list\-formats\f[] or \f[C]\-F\f[].
 
1233 Note that these format codes are extractor specific.
 
1235 You can also use a file extension (currently \f[C]3gp\f[], \f[C]aac\f[],
 
1236 \f[C]flv\f[], \f[C]m4a\f[], \f[C]mp3\f[], \f[C]mp4\f[], \f[C]ogg\f[],
 
1237 \f[C]wav\f[], \f[C]webm\f[] are supported) to download the best quality
 
1238 format of a particular file extension served as a single file, e.g.
 
1239 \f[C]\-f\ webm\f[] will download the best quality format with the
 
1240 \f[C]webm\f[] extension served as a single file.
 
1242 You can also use special names to select particular edge case formats:
 
1243 \- \f[C]best\f[]: Select the best quality format represented by a single
 
1244 file with video and audio.
 
1245 \- \f[C]worst\f[]: Select the worst quality format represented by a
 
1246 single file with video and audio.
 
1247 \- \f[C]bestvideo\f[]: Select the best quality video\-only format (e.g.
 
1249 May not be available.
 
1250 \- \f[C]worstvideo\f[]: Select the worst quality video\-only format.
 
1251 May not be available.
 
1252 \- \f[C]bestaudio\f[]: Select the best quality audio only\-format.
 
1253 May not be available.
 
1254 \- \f[C]worstaudio\f[]: Select the worst quality audio only\-format.
 
1255 May not be available.
 
1257 For example, to download the worst quality video\-only format you can
 
1258 use \f[C]\-f\ worstvideo\f[].
 
1260 If you want to download multiple videos and they don\[aq]t have the same
 
1261 formats available, you can specify the order of preference using
 
1263 Note that slash is left\-associative, i.e.
 
1264 formats on the left hand side are preferred, for example
 
1265 \f[C]\-f\ 22/17/18\f[] will download format 22 if it\[aq]s available,
 
1266 otherwise it will download format 17 if it\[aq]s available, otherwise it
 
1267 will download format 18 if it\[aq]s available, otherwise it will
 
1268 complain that no suitable formats are available for download.
 
1270 If you want to download several formats of the same video use a comma as
 
1272 \f[C]\-f\ 22,17,18\f[] will download all these three formats, of course
 
1273 if they are available.
 
1274 Or a more sophisticated example combined with the precedence feature:
 
1275 \f[C]\-f\ 136/137/mp4/bestvideo,140/m4a/bestaudio\f[].
 
1277 You can also filter the video formats by putting a condition in
 
1278 brackets, as in \f[C]\-f\ "best[height=720]"\f[] (or
 
1279 \f[C]\-f\ "[filesize>10M]"\f[]).
 
1281 The following numeric meta fields can be used with comparisons
 
1282 \f[C]<\f[], \f[C]<=\f[], \f[C]>\f[], \f[C]>=\f[], \f[C]=\f[] (equals),
 
1283 \f[C]!=\f[] (not equals): \- \f[C]filesize\f[]: The number of bytes, if
 
1284 known in advance \- \f[C]width\f[]: Width of the video, if known \-
 
1285 \f[C]height\f[]: Height of the video, if known \- \f[C]tbr\f[]: Average
 
1286 bitrate of audio and video in KBit/s \- \f[C]abr\f[]: Average audio
 
1287 bitrate in KBit/s \- \f[C]vbr\f[]: Average video bitrate in KBit/s \-
 
1288 \f[C]asr\f[]: Audio sampling rate in Hertz \- \f[C]fps\f[]: Frame rate
 
1290 Also filtering work for comparisons \f[C]=\f[] (equals), \f[C]!=\f[]
 
1291 (not equals), \f[C]^=\f[] (begins with), \f[C]$=\f[] (ends with),
 
1292 \f[C]*=\f[] (contains) and following string meta fields: \-
 
1293 \f[C]ext\f[]: File extension \- \f[C]acodec\f[]: Name of the audio codec
 
1294 in use \- \f[C]vcodec\f[]: Name of the video codec in use \-
 
1295 \f[C]container\f[]: Name of the container format \- \f[C]protocol\f[]:
 
1296 The protocol that will be used for the actual download, lower\-case
 
1297 (\f[C]http\f[], \f[C]https\f[], \f[C]rtsp\f[], \f[C]rtmp\f[],
 
1298 \f[C]rtmpe\f[], \f[C]mms\f[], \f[C]f4m\f[], \f[C]ism\f[], \f[C]m3u8\f[],
 
1299 or \f[C]m3u8_native\f[]) \- \f[C]format_id\f[]: A short description of
 
1302 Note that none of the aforementioned meta fields are guaranteed to be
 
1303 present since this solely depends on the metadata obtained by particular
 
1305 the metadata offered by the video hoster.
 
1307 Formats for which the value is not known are excluded unless you put a
 
1308 question mark (\f[C]?\f[]) after the operator.
 
1309 You can combine format filters, so
 
1310 \f[C]\-f\ "[height\ <=?\ 720][tbr>500]"\f[] selects up to 720p videos
 
1311 (or videos where the height is not known) with a bitrate of at least 500
 
1314 You can merge the video and audio of two formats into a single file
 
1315 using \f[C]\-f\ <video\-format>+<audio\-format>\f[] (requires ffmpeg or
 
1316 avconv installed), for example \f[C]\-f\ bestvideo+bestaudio\f[] will
 
1317 download the best video\-only format, the best audio\-only format and
 
1318 mux them together with ffmpeg/avconv.
 
1320 Format selectors can also be grouped using parentheses, for example if
 
1321 you want to download the best mp4 and webm formats with a height lower
 
1322 than 480 you can use \f[C]\-f\ \[aq](mp4,webm)[height<480]\[aq]\f[].
 
1324 Since the end of April 2015 and version 2015.04.26, youtube\-dl uses
 
1325 \f[C]\-f\ bestvideo+bestaudio/best\f[] as the default format selection
 
1326 (see #5447 (https://github.com/rg3/youtube-dl/issues/5447),
 
1327 #5456 (https://github.com/rg3/youtube-dl/issues/5456)).
 
1328 If ffmpeg or avconv are installed this results in downloading
 
1329 \f[C]bestvideo\f[] and \f[C]bestaudio\f[] separately and muxing them
 
1330 together into a single file giving the best overall quality available.
 
1331 Otherwise it falls back to \f[C]best\f[] and results in downloading the
 
1332 best available quality served as a single file.
 
1333 \f[C]best\f[] is also needed for videos that don\[aq]t come from YouTube
 
1334 because they don\[aq]t provide the audio and video in two different
 
1336 If you want to only download some DASH formats (for example if you are
 
1337 not interested in getting videos with a resolution higher than 1080p),
 
1338 you can add \f[C]\-f\ bestvideo[height<=?1080]+bestaudio/best\f[] to
 
1339 your configuration file.
 
1340 Note that if you use youtube\-dl to stream to \f[C]stdout\f[] (and most
 
1341 likely to pipe it to your media player then), i.e.
 
1342 you explicitly specify output template as \f[C]\-o\ \-\f[], youtube\-dl
 
1343 still uses \f[C]\-f\ best\f[] format selection in order to start content
 
1344 delivery immediately to your player and not to wait until
 
1345 \f[C]bestvideo\f[] and \f[C]bestaudio\f[] are downloaded and muxed.
 
1347 If you want to preserve the old format selection behavior (prior to
 
1348 youtube\-dl 2015.04.26), i.e.
 
1349 you want to download the best available quality media served as a single
 
1350 file, you should explicitly specify your choice with \f[C]\-f\ best\f[].
 
1351 You may want to add it to the configuration file (#configuration) in
 
1352 order not to type it every time you run youtube\-dl.
 
1353 .SS Format selection examples
 
1355 Note on Windows you may need to use double quotes instead of single.
 
1359 #\ Download\ best\ mp4\ format\ available\ or\ any\ other\ best\ if\ no\ mp4\ available
 
1360 $\ youtube\-dl\ \-f\ \[aq]bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best\[aq]
 
1362 #\ Download\ best\ format\ available\ but\ not\ better\ that\ 480p
 
1363 $\ youtube\-dl\ \-f\ \[aq]bestvideo[height<=480]+bestaudio/best[height<=480]\[aq]
 
1365 #\ Download\ best\ video\ only\ format\ but\ no\ bigger\ than\ 50\ MB
 
1366 $\ youtube\-dl\ \-f\ \[aq]best[filesize<50M]\[aq]
 
1368 #\ Download\ best\ format\ available\ via\ direct\ link\ over\ HTTP/HTTPS\ protocol
 
1369 $\ youtube\-dl\ \-f\ \[aq](bestvideo+bestaudio/best)[protocol^=http]\[aq]
 
1371 #\ Download\ the\ best\ video\ format\ and\ the\ best\ audio\ format\ without\ merging\ them
 
1372 $\ youtube\-dl\ \-f\ \[aq]bestvideo,bestaudio\[aq]\ \-o\ \[aq]%(title)s.f%(format_id)s.%(ext)s\[aq]
 
1376 Note that in the last example, an output template is recommended as
 
1377 bestvideo and bestaudio may have the same file name.
 
1380 Videos can be filtered by their upload date using the options
 
1381 \f[C]\-\-date\f[], \f[C]\-\-datebefore\f[] or \f[C]\-\-dateafter\f[].
 
1382 They accept dates in two formats:
 
1384 Absolute dates: Dates in the format \f[C]YYYYMMDD\f[].
 
1386 Relative dates: Dates in the format
 
1387 \f[C](now|today)[+\-][0\-9](day|week|month|year)(s)?\f[]
 
1393 #\ Download\ only\ the\ videos\ uploaded\ in\ the\ last\ 6\ months
 
1394 $\ youtube\-dl\ \-\-dateafter\ now\-6months
 
1396 #\ Download\ only\ the\ videos\ uploaded\ on\ January\ 1,\ 1970
 
1397 $\ youtube\-dl\ \-\-date\ 19700101
 
1399 $\ #\ Download\ only\ the\ videos\ uploaded\ in\ the\ 200x\ decade
 
1400 $\ youtube\-dl\ \-\-dateafter\ 20000101\ \-\-datebefore\ 20091231
 
1404 .SS How do I update youtube\-dl?
 
1406 If you\[aq]ve followed our manual installation
 
1407 instructions (http://rg3.github.io/youtube-dl/download.html), you can
 
1408 simply run \f[C]youtube\-dl\ \-U\f[] (or, on Linux,
 
1409 \f[C]sudo\ youtube\-dl\ \-U\f[]).
 
1411 If you have used pip, a simple
 
1412 \f[C]sudo\ pip\ install\ \-U\ youtube\-dl\f[] is sufficient to update.
 
1414 If you have installed youtube\-dl using a package manager like
 
1415 \f[I]apt\-get\f[] or \f[I]yum\f[], use the standard system update
 
1416 mechanism to update.
 
1417 Note that distribution packages are often outdated.
 
1418 As a rule of thumb, youtube\-dl releases at least once a month, and
 
1419 often weekly or even daily.
 
1420 Simply go to http://yt\-dl.org/ to find out the current version.
 
1421 Unfortunately, there is nothing we youtube\-dl developers can do if your
 
1422 distribution serves a really outdated version.
 
1423 You can (and should) complain to your distribution in their bugtracker
 
1426 As a last resort, you can also uninstall the version installed by your
 
1427 package manager and follow our manual installation instructions.
 
1428 For that, remove the distribution\[aq]s package, with a line like
 
1432 sudo\ apt\-get\ remove\ \-y\ youtube\-dl
 
1436 Afterwards, simply follow our manual installation
 
1437 instructions (http://rg3.github.io/youtube-dl/download.html):
 
1441 sudo\ wget\ https://yt\-dl.org/latest/youtube\-dl\ \-O\ /usr/local/bin/youtube\-dl
 
1442 sudo\ chmod\ a+x\ /usr/local/bin/youtube\-dl
 
1447 Again, from then on you\[aq]ll be able to update with
 
1448 \f[C]sudo\ youtube\-dl\ \-U\f[].
 
1449 .SS youtube\-dl is extremely slow to start on Windows
 
1451 Add a file exclusion for \f[C]youtube\-dl.exe\f[] in Windows Defender
 
1453 .SS I\[aq]m getting an error
 
1454 \f[C]Unable\ to\ extract\ OpenGraph\ title\f[] on YouTube playlists
 
1456 YouTube changed their playlist format in March 2014 and later on, so
 
1457 you\[aq]ll need at least youtube\-dl 2014.07.25 to download all YouTube
 
1460 If you have installed youtube\-dl with a package manager, pip, setup.py
 
1461 or a tarball, please use that to update.
 
1462 Note that Ubuntu packages do not seem to get updated anymore.
 
1463 Since we are not affiliated with Ubuntu, there is little we can do.
 
1465 bugs (https://bugs.launchpad.net/ubuntu/+source/youtube-dl/+filebug) to
 
1466 the Ubuntu packaging
 
1467 people (mailto:ubuntu-motu@lists.ubuntu.com?subject=outdated%20version%20of%20youtube-dl)
 
1468 \- all they have to do is update the package to a somewhat recent
 
1470 See above for a way to update.
 
1471 .SS I\[aq]m getting an error when trying to use output template:
 
1472 \f[C]error:\ using\ output\ template\ conflicts\ with\ using\ title,\ video\ ID\ or\ auto\ number\f[]
 
1474 Make sure you are not using \f[C]\-o\f[] with any of these options
 
1475 \f[C]\-t\f[], \f[C]\-\-title\f[], \f[C]\-\-id\f[], \f[C]\-A\f[] or
 
1476 \f[C]\-\-auto\-number\f[] set in command line or in a configuration
 
1478 Remove the latter if any.
 
1479 .SS Do I always have to pass \f[C]\-citw\f[]?
 
1481 By default, youtube\-dl intends to have the best options (incidentally,
 
1482 if you have a convincing case that these should be different, please
 
1483 file an issue where you explain that (https://yt-dl.org/bug)).
 
1484 Therefore, it is unnecessary and sometimes harmful to copy long option
 
1485 strings from webpages.
 
1486 In particular, the only option out of \f[C]\-citw\f[] that is regularly
 
1487 useful is \f[C]\-i\f[].
 
1488 .SS Can you please put the \f[C]\-b\f[] option back?
 
1490 Most people asking this question are not aware that youtube\-dl now
 
1491 defaults to downloading the highest available quality as reported by
 
1492 YouTube, which will be 1080p or 720p in some cases, so you no longer
 
1493 need the \f[C]\-b\f[] option.
 
1494 For some specific videos, maybe YouTube does not report them to be
 
1495 available in a specific high quality format you\[aq]re interested in.
 
1496 In that case, simply request it with the \f[C]\-f\f[] option and
 
1497 youtube\-dl will try to download it.
 
1498 .SS I get HTTP error 402 when trying to download a video. What\[aq]s
 
1501 Apparently YouTube requires you to pass a CAPTCHA test if you download
 
1503 We\[aq]re considering to provide a way to let you solve the
 
1504 CAPTCHA (https://github.com/rg3/youtube-dl/issues/154), but at the
 
1505 moment, your best course of action is pointing a web browser to the
 
1506 youtube URL, solving the CAPTCHA, and restart youtube\-dl.
 
1507 .SS Do I need any other programs?
 
1509 youtube\-dl works fine on its own on most sites.
 
1510 However, if you want to convert video/audio, you\[aq]ll need
 
1511 avconv (https://libav.org/) or ffmpeg (https://www.ffmpeg.org/).
 
1512 On some sites \- most notably YouTube \- videos can be retrieved in a
 
1513 higher quality format without sound.
 
1514 youtube\-dl will detect whether avconv/ffmpeg is present and
 
1515 automatically pick the best option.
 
1517 Videos or video formats streamed via RTMP protocol can only be
 
1518 downloaded when rtmpdump (https://rtmpdump.mplayerhq.hu/) is installed.
 
1519 Downloading MMS and RTSP videos requires either
 
1520 mplayer (http://mplayerhq.hu/) or mpv (https://mpv.io/) to be installed.
 
1521 .SS I have downloaded a video but how can I play it?
 
1523 Once the video is fully downloaded, use any video player, such as
 
1524 mpv (https://mpv.io/), vlc (http://www.videolan.org/) or
 
1525 mplayer (http://www.mplayerhq.hu/).
 
1526 .SS I extracted a video URL with \f[C]\-g\f[], but it does not play on
 
1527 another machine / in my web browser.
 
1529 It depends a lot on the service.
 
1530 In many cases, requests for the video (to download/play it) must come
 
1531 from the same IP address and with the same cookies and/or HTTP headers.
 
1532 Use the \f[C]\-\-cookies\f[] option to write the required cookies into a
 
1533 file, and advise your downloader to read cookies from that file.
 
1534 Some sites also require a common user agent to be used, use
 
1535 \f[C]\-\-dump\-user\-agent\f[] to see the one in use by youtube\-dl.
 
1536 You can also get necessary cookies and HTTP headers from JSON output
 
1537 obtained with \f[C]\-\-dump\-json\f[].
 
1539 It may be beneficial to use IPv6; in some cases, the restrictions are
 
1540 only applied to IPv4.
 
1541 Some services (sometimes only for a subset of videos) do not restrict
 
1542 the video URL by IP address, cookie, or user\-agent, but these are the
 
1543 exception rather than the rule.
 
1545 Please bear in mind that some URL protocols are \f[B]not\f[] supported
 
1546 by browsers out of the box, including RTMP.
 
1547 If you are using \f[C]\-g\f[], your own downloader must support these as
 
1550 If you want to play the video on a machine that is not running
 
1551 youtube\-dl, you can relay the video content from the machine that runs
 
1553 You can use \f[C]\-o\ \-\f[] to let youtube\-dl stream a video to
 
1554 stdout, or simply allow the player to download the files written by
 
1555 youtube\-dl in turn.
 
1556 .SS ERROR: no fmt_url_map or conn information found in video info
 
1558 YouTube has switched to a new video info format in July 2011 which is
 
1559 not supported by old versions of youtube\-dl.
 
1560 See above (#how-do-i-update-youtube-dl) for how to update youtube\-dl.
 
1561 .SS ERROR: unable to download video
 
1563 YouTube requires an additional signature since September 2012 which is
 
1564 not supported by old versions of youtube\-dl.
 
1565 See above (#how-do-i-update-youtube-dl) for how to update youtube\-dl.
 
1566 .SS Video URL contains an ampersand and I\[aq]m getting some strange
 
1567 output \f[C][1]\ 2839\f[] or
 
1568 \f[C]\[aq]v\[aq]\ is\ not\ recognized\ as\ an\ internal\ or\ external\ command\f[]
 
1570 That\[aq]s actually the output from your shell.
 
1571 Since ampersand is one of the special shell characters it\[aq]s
 
1572 interpreted by the shell preventing you from passing the whole URL to
 
1574 To disable your shell from interpreting the ampersands (or any other
 
1575 special characters) you have to either put the whole URL in quotes or
 
1576 escape them with a backslash (which approach will work depends on your
 
1579 For example if your URL is
 
1580 https://www.youtube.com/watch?t=4&v=BaW_jenozKc you should end up with
 
1583 \f[C]youtube\-dl\ \[aq]https://www.youtube.com/watch?t=4&v=BaW_jenozKc\[aq]\f[]
 
1587 \f[C]youtube\-dl\ https://www.youtube.com/watch?t=4\\&v=BaW_jenozKc\f[]
 
1589 For Windows you have to use the double quotes:
 
1591 \f[C]youtube\-dl\ "https://www.youtube.com/watch?t=4&v=BaW_jenozKc"\f[]
 
1592 .SS ExtractorError: Could not find JS function u\[aq]OF\[aq]
 
1594 In February 2015, the new YouTube player contained a character sequence
 
1595 in a string that was misinterpreted by old versions of youtube\-dl.
 
1596 See above (#how-do-i-update-youtube-dl) for how to update youtube\-dl.
 
1597 .SS HTTP Error 429: Too Many Requests or 402: Payment Required
 
1599 These two error codes indicate that the service is blocking your IP
 
1600 address because of overuse.
 
1601 Contact the service and ask them to unblock your IP address, or \- if
 
1602 you have acquired a whitelisted IP address already \- use the
 
1603 \f[C]\-\-proxy\f[] or \f[C]\-\-source\-address\f[]
 
1604 options (#network-options) to select another IP address.
 
1605 .SS SyntaxError: Non\-ASCII character
 
1611 File\ "youtube\-dl",\ line\ 2
 
1612 SyntaxError:\ Non\-ASCII\ character\ \[aq]\\x93\[aq]\ ...
 
1616 means you\[aq]re using an outdated version of Python.
 
1617 Please update to Python 2.6 or 2.7.
 
1618 .SS What is this binary file? Where has the code gone?
 
1620 Since June 2012 (#342 (https://github.com/rg3/youtube-dl/issues/342))
 
1621 youtube\-dl is packed as an executable zipfile, simply unzip it (might
 
1622 need renaming to \f[C]youtube\-dl.zip\f[] first on some systems) or
 
1623 clone the git repository, as laid out above.
 
1624 If you modify the code, you can run it by executing the
 
1625 \f[C]__main__.py\f[] file.
 
1626 To recompile the executable, run \f[C]make\ youtube\-dl\f[].
 
1627 .SS The exe throws an error due to missing \f[C]MSVCR100.dll\f[]
 
1629 To run the exe you need to install first the Microsoft Visual C++ 2010
 
1630 Redistributable Package
 
1631 (x86) (https://www.microsoft.com/en-US/download/details.aspx?id=5555).
 
1632 .SS On Windows, how should I set up ffmpeg and youtube\-dl? Where should
 
1633 I put the exe files?
 
1635 If you put youtube\-dl and ffmpeg in the same directory that you\[aq]re
 
1636 running the command from, it will work, but that\[aq]s rather
 
1639 To make a different directory work \- either for ffmpeg, or for
 
1640 youtube\-dl, or for both \- simply create the directory (say,
 
1641 \f[C]C:\\bin\f[], or \f[C]C:\\Users\\<User\ name>\\bin\f[]), put all the
 
1642 executables directly in there, and then set your PATH environment
 
1643 variable (https://www.java.com/en/download/help/path.xml) to include
 
1646 From then on, after restarting your shell, you will be able to access
 
1647 both youtube\-dl and ffmpeg (and youtube\-dl will be able to find
 
1648 ffmpeg) by simply typing \f[C]youtube\-dl\f[] or \f[C]ffmpeg\f[], no
 
1649 matter what directory you\[aq]re in.
 
1650 .SS How do I put downloads into a specific folder?
 
1652 Use the \f[C]\-o\f[] to specify an output template (#output-template),
 
1653 for example \f[C]\-o\ "/home/user/videos/%(title)s\-%(id)s.%(ext)s"\f[].
 
1654 If you want this for all of your downloads, put the option into your
 
1655 configuration file (#configuration).
 
1656 .SS How do I download a video starting with a \f[C]\-\f[]?
 
1658 Either prepend \f[C]http://www.youtube.com/watch?v=\f[] or separate the
 
1659 ID from the options with \f[C]\-\-\f[]:
 
1663 youtube\-dl\ \-\-\ \-wNyEUrxzFU
 
1664 youtube\-dl\ "http://www.youtube.com/watch?v=\-wNyEUrxzFU"
 
1667 .SS How do I pass cookies to youtube\-dl?
 
1669 Use the \f[C]\-\-cookies\f[] option, for example
 
1670 \f[C]\-\-cookies\ /path/to/cookies/file.txt\f[].
 
1672 In order to extract cookies from browser use any conforming browser
 
1673 extension for exporting cookies.
 
1675 cookies.txt (https://chrome.google.com/webstore/detail/cookiestxt/njabckikapfpffapmjgojcnbfjonfjfg)
 
1676 (for Chrome) or Export
 
1677 Cookies (https://addons.mozilla.org/en-US/firefox/addon/export-cookies/)
 
1680 Note that the cookies file must be in Mozilla/Netscape format and the
 
1681 first line of the cookies file must be either
 
1682 \f[C]#\ HTTP\ Cookie\ File\f[] or
 
1683 \f[C]#\ Netscape\ HTTP\ Cookie\ File\f[].
 
1684 Make sure you have correct newline
 
1685 format (https://en.wikipedia.org/wiki/Newline) in the cookies file and
 
1686 convert newlines if necessary to correspond with your OS, namely
 
1687 \f[C]CRLF\f[] (\f[C]\\r\\n\f[]) for Windows and \f[C]LF\f[]
 
1688 (\f[C]\\n\f[]) for Unix and Unix\-like systems (Linux, Mac OS, etc.).
 
1689 \f[C]HTTP\ Error\ 400:\ Bad\ Request\f[] when using \f[C]\-\-cookies\f[]
 
1690 is a good sign of invalid newline format.
 
1692 Passing cookies to youtube\-dl is a good way to workaround login when a
 
1693 particular extractor does not implement it explicitly.
 
1694 Another use case is working around
 
1695 CAPTCHA (https://en.wikipedia.org/wiki/CAPTCHA) some websites require
 
1696 you to solve in particular cases in order to get access (e.g.
 
1697 YouTube, CloudFlare).
 
1698 .SS How do I stream directly to media player?
 
1700 You will first need to tell youtube\-dl to stream media to stdout with
 
1701 \f[C]\-o\ \-\f[], and also tell your media player to read from stdin (it
 
1702 must be capable of this for streaming) and then pipe former to latter.
 
1703 For example, streaming to vlc (http://www.videolan.org/) can be achieved
 
1708 youtube\-dl\ \-o\ \-\ "http://www.youtube.com/watch?v=BaW_jenozKcj"\ |\ vlc\ \-
 
1711 .SS How do I download only new videos from a playlist?
 
1713 Use download\-archive feature.
 
1714 With this feature you should initially download the complete playlist
 
1715 with \f[C]\-\-download\-archive\ /path/to/download/archive/file.txt\f[]
 
1716 that will record identifiers of all the videos in a special file.
 
1717 Each subsequent run with the same \f[C]\-\-download\-archive\f[] will
 
1718 download only new videos and skip all videos that have been downloaded
 
1720 Note that only successful downloads are recorded in the file.
 
1722 For example, at first,
 
1726 youtube\-dl\ \-\-download\-archive\ archive.txt\ "https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re"
 
1730 will download the complete \f[C]PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re\f[]
 
1731 playlist and create a file \f[C]archive.txt\f[].
 
1732 Each subsequent run will only download new videos if any:
 
1736 youtube\-dl\ \-\-download\-archive\ archive.txt\ "https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re"
 
1739 .SS Should I add \f[C]\-\-hls\-prefer\-native\f[] into my config?
 
1741 When youtube\-dl detects an HLS video, it can download it either with
 
1742 the built\-in downloader or ffmpeg.
 
1743 Since many HLS streams are slightly invalid and ffmpeg/youtube\-dl each
 
1744 handle some invalid cases better than the other, there is an option to
 
1745 switch the downloader if needed.
 
1747 When youtube\-dl knows that one particular downloader works better for a
 
1748 given website, that downloader will be picked.
 
1749 Otherwise, youtube\-dl will pick the best downloader for general
 
1750 compatibility, which at the moment happens to be ffmpeg.
 
1751 This choice may change in future versions of youtube\-dl, with
 
1752 improvements of the built\-in downloader and/or ffmpeg.
 
1754 In particular, the generic extractor (used when your website is not in
 
1755 the list of supported sites by
 
1756 youtube\-dl (http://rg3.github.io/youtube-dl/supportedsites.html) cannot
 
1757 mandate one specific downloader.
 
1759 If you put either \f[C]\-\-hls\-prefer\-native\f[] or
 
1760 \f[C]\-\-hls\-prefer\-ffmpeg\f[] into your configuration, a different
 
1761 subset of videos will fail to download correctly.
 
1762 Instead, it is much better to file an issue (https://yt-dl.org/bug) or a
 
1763 pull request which details why the native or the ffmpeg HLS downloader
 
1764 is a better choice for your use case.
 
1765 .SS Can you add support for this anime video site, or site which shows
 
1766 current movies for free?
 
1768 As a matter of policy (as well as legality), youtube\-dl does not
 
1769 include support for services that specialize in infringing copyright.
 
1770 As a rule of thumb, if you cannot easily find a video that the service
 
1771 is quite obviously allowed to distribute (i.e.
 
1772 that has been uploaded by the creator, the creator\[aq]s distributor, or
 
1773 is published under a free license), the service is probably unfit for
 
1774 inclusion to youtube\-dl.
 
1776 A note on the service that they don\[aq]t host the infringing content,
 
1777 but just link to those who do, is evidence that the service should
 
1778 \f[B]not\f[] be included into youtube\-dl.
 
1779 The same goes for any DMCA note when the whole front page of the service
 
1780 is filled with videos they are not allowed to distribute.
 
1781 A "fair use" note is equally unconvincing if the service shows
 
1782 copyright\-protected videos in full without authorization.
 
1784 Support requests for services that \f[B]do\f[] purchase the rights to
 
1785 distribute their content are perfectly fine though.
 
1786 If in doubt, you can simply include a source that mentions the
 
1787 legitimate purchase of content.
 
1788 .SS How can I speed up work on my issue?
 
1790 (Also known as: Help, my important issue not being solved!) The
 
1791 youtube\-dl core developer team is quite small.
 
1792 While we do our best to solve as many issues as possible, sometimes that
 
1793 can take quite a while.
 
1794 To speed up your issue, here\[aq]s what you can do:
 
1796 First of all, please do report the issue at our issue
 
1797 tracker (https://yt-dl.org/bugs).
 
1798 That allows us to coordinate all efforts by users and developers, and
 
1799 serves as a unified point.
 
1800 Unfortunately, the youtube\-dl project has grown too large to use
 
1801 personal email as an effective communication channel.
 
1803 Please read the bug reporting instructions (#bugs) below.
 
1804 A lot of bugs lack all the necessary information.
 
1805 If you can, offer proxy, VPN, or shell access to the youtube\-dl
 
1807 If you are able to, test the issue from multiple computers in multiple
 
1808 countries to exclude local censorship or misconfiguration issues.
 
1810 If nobody is interested in solving your issue, you are welcome to take
 
1811 matters into your own hands and submit a pull request (or coerce/pay
 
1812 somebody else to do so).
 
1814 Feel free to bump the issue from time to time by writing a small comment
 
1815 ("Issue is still present in youtube\-dl version ...from France, but
 
1816 fixed from Belgium"), but please not more than once a month.
 
1817 Please do not declare your issue as \f[C]important\f[] or
 
1819 .SS How can I detect whether a given URL is supported by youtube\-dl?
 
1821 For one, have a look at the list of supported
 
1822 sites (docs/supportedsites.md).
 
1823 Note that it can sometimes happen that the site changes its URL scheme
 
1824 (say, from http://example.com/video/1234567 to
 
1825 http://example.com/v/1234567 ) and youtube\-dl reports an URL of a
 
1826 service in that list as unsupported.
 
1827 In that case, simply report a bug.
 
1829 It is \f[I]not\f[] possible to detect whether a URL is supported or not.
 
1830 That\[aq]s because youtube\-dl contains a generic extractor which
 
1831 matches \f[B]all\f[] URLs.
 
1832 You may be tempted to disable, exclude, or remove the generic extractor,
 
1833 but the generic extractor not only allows users to extract videos from
 
1834 lots of websites that embed a video from another service, but may also
 
1835 be used to extract video from a service that it\[aq]s hosting itself.
 
1836 Therefore, we neither recommend nor support disabling, excluding, or
 
1837 removing the generic extractor.
 
1839 If you want to find out whether a given URL is supported, simply call
 
1840 youtube\-dl with it.
 
1841 If you get no videos back, chances are the URL is either not referring
 
1842 to a video or unsupported.
 
1843 You can find out which by examining the output (if you run youtube\-dl
 
1844 on the console) or catching an \f[C]UnsupportedError\f[] exception if
 
1845 you run it from a Python program.
 
1846 .SH Why do I need to go through that much red tape when filing bugs?
 
1848 Before we had the issue template, despite our extensive bug reporting
 
1849 instructions (#bugs), about 80% of the issue reports we got were
 
1850 useless, for instance because people used ancient versions hundreds of
 
1851 releases old, because of simple syntactic errors (not in youtube\-dl but
 
1852 in general shell usage), because the problem was already reported
 
1853 multiple times before, because people did not actually read an error
 
1854 message, even if it said "please install ffmpeg", because people did not
 
1855 mention the URL they were trying to download and many more simple,
 
1856 easy\-to\-avoid problems, many of whom were totally unrelated to
 
1859 youtube\-dl is an open\-source project manned by too few volunteers, so
 
1860 we\[aq]d rather spend time fixing bugs where we are certain none of
 
1861 those simple problems apply, and where we can be reasonably confident to
 
1862 be able to reproduce the issue without asking the reporter repeatedly.
 
1863 As such, the output of \f[C]youtube\-dl\ \-v\ YOUR_URL_HERE\f[] is
 
1864 really all that\[aq]s required to file an issue.
 
1865 The issue template also guides you through some basic steps you can do,
 
1866 such as checking that your version of youtube\-dl is current.
 
1867 .SH DEVELOPER INSTRUCTIONS
 
1869 Most users do not need to build youtube\-dl and can download the
 
1870 builds (http://rg3.github.io/youtube-dl/download.html) or get them from
 
1873 To run youtube\-dl as a developer, you don\[aq]t need to build anything
 
1879 python\ \-m\ youtube_dl
 
1883 To run the test, simply invoke your favorite test runner, or execute a
 
1884 test file directly; any of the following work:
 
1888 python\ \-m\ unittest\ discover
 
1889 python\ test/test_download.py
 
1894 If you want to create a build of youtube\-dl yourself, you\[aq]ll need
 
1898 make (only GNU make is supported)
 
1905 .SS Adding support for a new site
 
1907 If you want to add support for a new site, first of all \f[B]make
 
1908 sure\f[] this site is \f[B]not dedicated to copyright
 
1909 infringement (README.md#can-you-add-support-for-this-anime-video-site-or-site-which-shows-current-movies-for-free)\f[].
 
1910 youtube\-dl does \f[B]not support\f[] such sites thus pull requests
 
1911 adding support for them \f[B]will be rejected\f[].
 
1913 After you have ensured this site is distributing its content legally,
 
1914 you can follow this quick list (assuming your service is called
 
1915 \f[C]yourextractor\f[]):
 
1917 Fork this repository (https://github.com/rg3/youtube-dl/fork)
 
1919 Check out the source code with:
 
1924 git\ clone\ git\@github.com:YOUR_GITHUB_USERNAME/youtube\-dl.git
 
1929 Start a new git branch with
 
1935 git\ checkout\ \-b\ yourextractor
 
1940 Start with this simple template and save it to
 
1941 \f[C]youtube_dl/extractor/yourextractor.py\f[]:
 
1947 from\ __future__\ import\ unicode_literals
 
1949 from\ .common\ import\ InfoExtractor
 
1952 class\ YourExtractorIE(InfoExtractor):
 
1953 \ \ \ \ _VALID_URL\ =\ r\[aq]https?://(?:www\\.)?yourextractor\\.com/watch/(?P<id>[0\-9]+)\[aq]
 
1955 \ \ \ \ \ \ \ \ \[aq]url\[aq]:\ \[aq]http://yourextractor.com/watch/42\[aq],
 
1956 \ \ \ \ \ \ \ \ \[aq]md5\[aq]:\ \[aq]TODO:\ md5\ sum\ of\ the\ first\ 10241\ bytes\ of\ the\ video\ file\ (use\ \-\-test)\[aq],
 
1957 \ \ \ \ \ \ \ \ \[aq]info_dict\[aq]:\ {
 
1958 \ \ \ \ \ \ \ \ \ \ \ \ \[aq]id\[aq]:\ \[aq]42\[aq],
 
1959 \ \ \ \ \ \ \ \ \ \ \ \ \[aq]ext\[aq]:\ \[aq]mp4\[aq],
 
1960 \ \ \ \ \ \ \ \ \ \ \ \ \[aq]title\[aq]:\ \[aq]Video\ title\ goes\ here\[aq],
 
1961 \ \ \ \ \ \ \ \ \ \ \ \ \[aq]thumbnail\[aq]:\ r\[aq]re:^https?://.*\\.jpg$\[aq],
 
1962 \ \ \ \ \ \ \ \ \ \ \ \ #\ TODO\ more\ properties,\ either\ as:
 
1963 \ \ \ \ \ \ \ \ \ \ \ \ #\ *\ A\ value
 
1964 \ \ \ \ \ \ \ \ \ \ \ \ #\ *\ MD5\ checksum;\ start\ the\ string\ with\ md5:
 
1965 \ \ \ \ \ \ \ \ \ \ \ \ #\ *\ A\ regular\ expression;\ start\ the\ string\ with\ re:
 
1966 \ \ \ \ \ \ \ \ \ \ \ \ #\ *\ Any\ Python\ type\ (for\ example\ int\ or\ float)
 
1970 \ \ \ \ def\ _real_extract(self,\ url):
 
1971 \ \ \ \ \ \ \ \ video_id\ =\ self._match_id(url)
 
1972 \ \ \ \ \ \ \ \ webpage\ =\ self._download_webpage(url,\ video_id)
 
1974 \ \ \ \ \ \ \ \ #\ TODO\ more\ code\ goes\ here,\ for\ example\ ...
 
1975 \ \ \ \ \ \ \ \ title\ =\ self._html_search_regex(r\[aq]<h1>(.+?)</h1>\[aq],\ webpage,\ \[aq]title\[aq])
 
1977 \ \ \ \ \ \ \ \ return\ {
 
1978 \ \ \ \ \ \ \ \ \ \ \ \ \[aq]id\[aq]:\ video_id,
 
1979 \ \ \ \ \ \ \ \ \ \ \ \ \[aq]title\[aq]:\ title,
 
1980 \ \ \ \ \ \ \ \ \ \ \ \ \[aq]description\[aq]:\ self._og_search_description(webpage),
 
1981 \ \ \ \ \ \ \ \ \ \ \ \ \[aq]uploader\[aq]:\ self._search_regex(r\[aq]<div[^>]+id="uploader"[^>]*>([^<]+)<\[aq],\ webpage,\ \[aq]uploader\[aq],\ fatal=False),
 
1982 \ \ \ \ \ \ \ \ \ \ \ \ #\ TODO\ more\ properties\ (see\ youtube_dl/extractor/common.py)
 
1989 \f[C]youtube_dl/extractor/extractors.py\f[] (https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/extractors.py).
 
1992 \f[C]python\ test/test_download.py\ TestDownload.test_YourExtractor\f[].
 
1993 This \f[I]should fail\f[] at first, but you can continually re\-run it
 
1994 until you\[aq]re done.
 
1995 If you decide to add more than one test, then rename \f[C]_TEST\f[] to
 
1996 \f[C]_TESTS\f[] and make it into a list of dictionaries.
 
1997 The tests will then be named \f[C]TestDownload.test_YourExtractor\f[],
 
1998 \f[C]TestDownload.test_YourExtractor_1\f[],
 
1999 \f[C]TestDownload.test_YourExtractor_2\f[], etc.
 
2002 \f[C]youtube_dl/extractor/common.py\f[] (https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/common.py)
 
2003 for possible helper methods and a detailed description of what your
 
2004 extractor should and may
 
2005 return (https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/common.py#L74-L252).
 
2006 Add tests and code for as many as you want.
 
2008 Make sure your code follows youtube\-dl coding
 
2009 conventions (#youtube-dl-coding-conventions) and check the code with
 
2010 flake8 (https://pypi.python.org/pypi/flake8).
 
2011 Also make sure your code works under all Python (http://www.python.org/)
 
2012 versions claimed supported by youtube\-dl, namely 2.6, 2.7, and 3.2+.
 
2014 When the tests pass, add (http://git-scm.com/docs/git-add) the new files
 
2015 and commit (http://git-scm.com/docs/git-commit) them and
 
2016 push (http://git-scm.com/docs/git-push) the result, like this:
 
2021 $\ git\ add\ youtube_dl/extractor/extractors.py
 
2022 $\ git\ add\ youtube_dl/extractor/yourextractor.py
 
2023 $\ git\ commit\ \-m\ \[aq][yourextractor]\ Add\ new\ extractor\[aq]
 
2024 $\ git\ push\ origin\ yourextractor
 
2029 Finally, create a pull
 
2030 request (https://help.github.com/articles/creating-a-pull-request).
 
2031 We\[aq]ll then review and merge it.
 
2033 In any case, thank you very much for your contributions!
 
2034 .SS youtube\-dl coding conventions
 
2036 This section introduces a guide lines for writing idiomatic, robust and
 
2037 future\-proof extractor code.
 
2039 Extractors are very fragile by nature since they depend on the layout of
 
2040 the source data provided by 3rd party media hosters out of your control
 
2041 and this layout tends to change.
 
2042 As an extractor implementer your task is not only to write code that
 
2043 will extract media links and metadata correctly but also to minimize
 
2044 dependency on the source\[aq]s layout and even to make the code foresee
 
2045 potential future changes and be ready for that.
 
2046 This is important because it will allow the extractor not to break on
 
2047 minor layout changes thus keeping old youtube\-dl versions working.
 
2048 Even though this breakage issue is easily fixed by emitting a new
 
2049 version of youtube\-dl with a fix incorporated, all the previous
 
2050 versions become broken in all repositories and distros\[aq] packages
 
2051 that may not be so prompt in fetching the update from us.
 
2052 Needless to say, some non rolling release distros may never receive an
 
2054 .SS Mandatory and optional metafields
 
2056 For extraction to work youtube\-dl relies on metadata your extractor
 
2057 extracts and provides to youtube\-dl expressed by an information
 
2058 dictionary (https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/common.py#L75-L257)
 
2059 or simply \f[I]info dict\f[].
 
2060 Only the following meta fields in the \f[I]info dict\f[] are considered
 
2061 mandatory for a successful extraction process by youtube\-dl:
 
2063 \f[C]id\f[] (media identifier)
 
2065 \f[C]title\f[] (media title)
 
2067 \f[C]url\f[] (media download URL) or \f[C]formats\f[]
 
2069 In fact only the last option is technically mandatory (i.e.
 
2070 if you can\[aq]t figure out the download location of the media the
 
2071 extraction does not make any sense).
 
2072 But by convention youtube\-dl also treats \f[C]id\f[] and \f[C]title\f[]
 
2074 Thus the aforementioned metafields are the critical data that the
 
2075 extraction does not make any sense without and if any of them fail to be
 
2076 extracted then the extractor is considered completely broken.
 
2079 field (https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/common.py#L149-L257)
 
2080 apart from the aforementioned ones are considered \f[B]optional\f[].
 
2081 That means that extraction should be \f[B]tolerant\f[] to situations
 
2082 when sources for these fields can potentially be unavailable (even if
 
2083 they are always available at the moment) and \f[B]future\-proof\f[] in
 
2084 order not to break the extraction of general purpose mandatory fields.
 
2087 Say you have some source dictionary \f[C]meta\f[] that you\[aq]ve
 
2088 fetched as JSON with HTTP request and it has a key \f[C]summary\f[]:
 
2092 meta\ =\ self._download_json(url,\ video_id)
 
2096 Assume at this point \f[C]meta\f[]\[aq]s layout is:
 
2102 \ \ \ \ "summary":\ "some\ fancy\ summary\ text",
 
2108 Assume you want to extract \f[C]summary\f[] and put it into the
 
2109 resulting info dict as \f[C]description\f[].
 
2110 Since \f[C]description\f[] is an optional meta field you should be ready
 
2111 that this key may be missing from the \f[C]meta\f[] dict, so that you
 
2112 should extract it like:
 
2116 description\ =\ meta.get(\[aq]summary\[aq])\ \ #\ correct
 
2124 description\ =\ meta[\[aq]summary\[aq]]\ \ #\ incorrect
 
2128 The latter will break extraction process with \f[C]KeyError\f[] if
 
2129 \f[C]summary\f[] disappears from \f[C]meta\f[] at some later time but
 
2130 with the former approach extraction will just go ahead with
 
2131 \f[C]description\f[] set to \f[C]None\f[] which is perfectly fine
 
2132 (remember \f[C]None\f[] is equivalent to the absence of data).
 
2134 Similarly, you should pass \f[C]fatal=False\f[] when extracting optional
 
2135 data from a webpage with \f[C]_search_regex\f[],
 
2136 \f[C]_html_search_regex\f[] or similar methods, for instance:
 
2140 description\ =\ self._search_regex(
 
2141 \ \ \ \ r\[aq]<span[^>]+id="title"[^>]*>([^<]+)<\[aq],
 
2142 \ \ \ \ webpage,\ \[aq]description\[aq],\ fatal=False)
 
2146 With \f[C]fatal\f[] set to \f[C]False\f[] if \f[C]_search_regex\f[]
 
2147 fails to extract \f[C]description\f[] it will emit a warning and
 
2148 continue extraction.
 
2150 You can also pass \f[C]default=<some\ fallback\ value>\f[], for example:
 
2154 description\ =\ self._search_regex(
 
2155 \ \ \ \ r\[aq]<span[^>]+id="title"[^>]*>([^<]+)<\[aq],
 
2156 \ \ \ \ webpage,\ \[aq]description\[aq],\ default=None)
 
2160 On failure this code will silently continue the extraction with
 
2161 \f[C]description\f[] set to \f[C]None\f[].
 
2162 That is useful for metafields that may or may not be present.
 
2163 .SS Provide fallbacks
 
2165 When extracting metadata try to do so from multiple sources.
 
2166 For example if \f[C]title\f[] is present in several places, try
 
2167 extracting from at least some of them.
 
2168 This makes it more future\-proof in case some of the sources become
 
2172 Say \f[C]meta\f[] from the previous example has a \f[C]title\f[] and you
 
2173 are about to extract it.
 
2174 Since \f[C]title\f[] is a mandatory meta field you should end up with
 
2179 title\ =\ meta[\[aq]title\[aq]]
 
2183 If \f[C]title\f[] disappears from \f[C]meta\f[] in future due to some
 
2184 changes on the hoster\[aq]s side the extraction would fail since
 
2185 \f[C]title\f[] is mandatory.
 
2186 That\[aq]s expected.
 
2188 Assume that you have some another source you can extract \f[C]title\f[]
 
2189 from, for example \f[C]og:title\f[] HTML meta of a \f[C]webpage\f[].
 
2190 In this case you can provide a fallback scenario:
 
2194 title\ =\ meta.get(\[aq]title\[aq])\ or\ self._og_search_title(webpage)
 
2198 This code will try to extract from \f[C]meta\f[] first and if it fails
 
2199 it will try extracting \f[C]og:title\f[] from a \f[C]webpage\f[].
 
2200 .SS Make regular expressions flexible
 
2202 When using regular expressions try to write them fuzzy and flexible.
 
2205 Say you need to extract \f[C]title\f[] from the following HTML code:
 
2209 <span\ style="position:\ absolute;\ left:\ 910px;\ width:\ 90px;\ float:\ right;\ z\-index:\ 9999;"\ class="title">some\ fancy\ title</span>
 
2213 The code for that task should look similar to:
 
2217 title\ =\ self._search_regex(
 
2218 \ \ \ \ r\[aq]<span[^>]+class="title"[^>]*>([^<]+)\[aq],\ webpage,\ \[aq]title\[aq])
 
2226 title\ =\ self._search_regex(
 
2227 \ \ \ \ r\[aq]<span[^>]+class=(["\\\[aq]])title\\1[^>]*>(?P<title>[^<]+)\[aq],
 
2228 \ \ \ \ webpage,\ \[aq]title\[aq],\ group=\[aq]title\[aq])
 
2232 Note how you tolerate potential changes in the \f[C]style\f[]
 
2233 attribute\[aq]s value or switch from using double quotes to single for
 
2234 \f[C]class\f[] attribute:
 
2236 The code definitely should not look like:
 
2240 title\ =\ self._search_regex(
 
2241 \ \ \ \ r\[aq]<span\ style="position:\ absolute;\ left:\ 910px;\ width:\ 90px;\ float:\ right;\ z\-index:\ 9999;"\ class="title">(.*?)</span>\[aq],
 
2242 \ \ \ \ webpage,\ \[aq]title\[aq],\ group=\[aq]title\[aq])
 
2245 .SS Use safe conversion functions
 
2247 Wrap all extracted numeric data into safe functions from \f[C]utils\f[]:
 
2248 \f[C]int_or_none\f[], \f[C]float_or_none\f[].
 
2249 Use them for string to number conversions as well.
 
2250 .SH EMBEDDING YOUTUBE\-DL
 
2252 youtube\-dl makes the best effort to be a good command\-line program,
 
2253 and thus should be callable from any programming language.
 
2254 If you encounter any problems parsing its output, feel free to create a
 
2255 report (https://github.com/rg3/youtube-dl/issues/new).
 
2257 From a Python program, you can embed youtube\-dl in a more powerful
 
2262 from\ __future__\ import\ unicode_literals
 
2266 with\ youtube_dl.YoutubeDL(ydl_opts)\ as\ ydl:
 
2267 \ \ \ \ ydl.download([\[aq]http://www.youtube.com/watch?v=BaW_jenozKc\[aq]])
 
2271 Most likely, you\[aq]ll want to use various options.
 
2272 For a list of options available, have a look at
 
2273 \f[C]youtube_dl/YoutubeDL.py\f[] (https://github.com/rg3/youtube-dl/blob/master/youtube_dl/YoutubeDL.py#L129-L279).
 
2274 For a start, if you want to intercept youtube\-dl\[aq]s output, set a
 
2275 \f[C]logger\f[] object.
 
2277 Here\[aq]s a more complete example of a program that outputs only errors
 
2278 (and a short message after the download is finished), and
 
2279 downloads/converts the video to an mp3 file:
 
2283 from\ __future__\ import\ unicode_literals
 
2287 class\ MyLogger(object):
 
2288 \ \ \ \ def\ debug(self,\ msg):
 
2289 \ \ \ \ \ \ \ \ pass
 
2291 \ \ \ \ def\ warning(self,\ msg):
 
2292 \ \ \ \ \ \ \ \ pass
 
2294 \ \ \ \ def\ error(self,\ msg):
 
2295 \ \ \ \ \ \ \ \ print(msg)
 
2299 \ \ \ \ if\ d[\[aq]status\[aq]]\ ==\ \[aq]finished\[aq]:
 
2300 \ \ \ \ \ \ \ \ print(\[aq]Done\ downloading,\ now\ converting\ ...\[aq])
 
2304 \ \ \ \ \[aq]format\[aq]:\ \[aq]bestaudio/best\[aq],
 
2305 \ \ \ \ \[aq]postprocessors\[aq]:\ [{
 
2306 \ \ \ \ \ \ \ \ \[aq]key\[aq]:\ \[aq]FFmpegExtractAudio\[aq],
 
2307 \ \ \ \ \ \ \ \ \[aq]preferredcodec\[aq]:\ \[aq]mp3\[aq],
 
2308 \ \ \ \ \ \ \ \ \[aq]preferredquality\[aq]:\ \[aq]192\[aq],
 
2310 \ \ \ \ \[aq]logger\[aq]:\ MyLogger(),
 
2311 \ \ \ \ \[aq]progress_hooks\[aq]:\ [my_hook],
 
2313 with\ youtube_dl.YoutubeDL(ydl_opts)\ as\ ydl:
 
2314 \ \ \ \ ydl.download([\[aq]http://www.youtube.com/watch?v=BaW_jenozKc\[aq]])
 
2319 Bugs and suggestions should be reported at:
 
2320 <https://github.com/rg3/youtube-dl/issues>.
 
2321 Unless you were prompted to or there is another pertinent reason (e.g.
 
2322 GitHub fails to accept the bug report), please do not send bug reports
 
2324 For discussions, join us in the IRC channel
 
2325 #youtube\-dl (irc://chat.freenode.net/#youtube-dl) on freenode
 
2326 (webchat (http://webchat.freenode.net/?randomnick=1&channels=youtube-dl)).
 
2328 \f[B]Please include the full output of youtube\-dl when run with
 
2329 \f[C]\-v\f[]\f[], i.e.
 
2330 \f[B]add\f[] \f[C]\-v\f[] flag to \f[B]your command line\f[], copy the
 
2331 \f[B]whole\f[] output and post it in the issue body wrapped in ``` for
 
2333 It should look similar to this:
 
2337 $\ youtube\-dl\ \-v\ <your\ command\ line>
 
2338 [debug]\ System\ config:\ []
 
2339 [debug]\ User\ config:\ []
 
2340 [debug]\ Command\-line\ args:\ [u\[aq]\-v\[aq],\ u\[aq]http://www.youtube.com/watch?v=BaW_jenozKcj\[aq]]
 
2341 [debug]\ Encodings:\ locale\ cp1251,\ fs\ mbcs,\ out\ cp866,\ pref\ cp1251
 
2342 [debug]\ youtube\-dl\ version\ 2015.12.06
 
2343 [debug]\ Git\ HEAD:\ 135392e
 
2344 [debug]\ Python\ version\ 2.6.6\ \-\ Windows\-2003Server\-5.2.3790\-SP2
 
2345 [debug]\ exe\ versions:\ ffmpeg\ N\-75573\-g1d0487f,\ ffprobe\ N\-75573\-g1d0487f,\ rtmpdump\ 2.4
 
2346 [debug]\ Proxy\ map:\ {}
 
2351 \f[B]Do not post screenshots of verbose logs; only plain text is
 
2354 The output (including the first lines) contains important debugging
 
2356 Issues without the full output are often not reproducible and therefore
 
2357 do not get solved in short order, if ever.
 
2359 Please re\-read your issue once again to avoid a couple of common
 
2360 mistakes (you can and should use this as a checklist):
 
2361 .SS Is the description of the issue itself sufficient?
 
2363 We often get issue reports that we cannot really decipher.
 
2364 While in most cases we eventually get the required information after
 
2365 asking back multiple times, this poses an unnecessary drain on our
 
2367 Many contributors, including myself, are also not native speakers, so we
 
2368 may misread some parts.
 
2370 So please elaborate on what feature you are requesting, or what bug you
 
2372 Make sure that it\[aq]s obvious
 
2376 How it could be fixed
 
2378 How your proposed solution would look like
 
2380 If your report is shorter than two lines, it is almost certainly missing
 
2381 some of these, which makes it hard for us to respond to it.
 
2382 We\[aq]re often too polite to close the issue outright, but the missing
 
2383 info makes misinterpretation likely.
 
2384 As a committer myself, I often get frustrated by these issues, since the
 
2385 only possible way for me to move forward on them is to ask for
 
2386 clarification over and over.
 
2388 For bug reports, this means that your report should contain the
 
2389 \f[I]complete\f[] output of youtube\-dl when called with the
 
2391 The error message you get for (most) bugs even says so, but you would
 
2392 not believe how many of our bug reports do not contain this information.
 
2394 If your server has multiple IPs or you suspect censorship, adding
 
2395 \f[C]\-\-call\-home\f[] may be a good idea to get more diagnostics.
 
2396 If the error is \f[C]ERROR:\ Unable\ to\ extract\ ...\f[] and you cannot
 
2397 reproduce it from multiple countries, add \f[C]\-\-dump\-pages\f[]
 
2398 (warning: this will yield a rather large output, redirect it to the file
 
2399 \f[C]log.txt\f[] by adding \f[C]>log.txt\ 2>&1\f[] to your
 
2400 command\-line) or upload the \f[C]\&.dump\f[] files you get when you add
 
2401 \f[C]\-\-write\-pages\f[] somewhere (https://gist.github.com/).
 
2403 \f[B]Site support requests must contain an example URL\f[].
 
2404 An example URL is a URL you might want to download, like
 
2405 \f[C]http://www.youtube.com/watch?v=BaW_jenozKc\f[].
 
2406 There should be an obvious video present.
 
2407 Except under very special circumstances, the main page of a video
 
2409 \f[C]http://www.youtube.com/\f[]) is \f[I]not\f[] an example URL.
 
2410 .SS Are you using the latest version?
 
2412 Before reporting any issue, type \f[C]youtube\-dl\ \-U\f[].
 
2413 This should report that you\[aq]re up\-to\-date.
 
2414 About 20% of the reports we receive are already fixed, but people are
 
2415 using outdated versions.
 
2416 This goes for feature requests as well.
 
2417 .SS Is the issue already documented?
 
2419 Make sure that someone has not already opened the issue you\[aq]re
 
2421 Search at the top of the window or browse the GitHub
 
2422 Issues (https://github.com/rg3/youtube-dl/search?type=Issues) of this
 
2424 If there is an issue, feel free to write something along the lines of
 
2425 "This affects me as well, with version 2015.01.01.
 
2426 Here is some more information on the issue: ...".
 
2427 While some issues may be old, a new post into them often spurs rapid
 
2429 .SS Why are existing options not enough?
 
2431 Before requesting a new feature, please have a quick peek at the list of
 
2433 options (https://github.com/rg3/youtube-dl/blob/master/README.md#options).
 
2434 Many feature requests are for features that actually exist already!
 
2435 Please, absolutely do show off your work in the issue report and detail
 
2436 how the existing similar options do \f[I]not\f[] solve your problem.
 
2437 .SS Is there enough context in your bug report?
 
2439 People want to solve problems, and often think they do us a favor by
 
2440 breaking down their larger problems (e.g.
 
2441 wanting to skip already downloaded files) to a specific request (e.g.
 
2442 requesting us to look whether the file exists before downloading the
 
2444 However, what often happens is that they break down the problem into two
 
2445 steps: One simple, and one impossible (or extremely complicated one).
 
2447 We are then presented with a very complicated request when the original
 
2448 problem could be solved far easier, e.g.
 
2449 by recording the downloaded video IDs in a separate file.
 
2450 To avoid this, you must include the greater context where it is
 
2452 In particular, every feature request that does not consist of adding
 
2453 support for a new site should contain a use case scenario that explains
 
2454 in what situation the missing feature would be useful.
 
2455 .SS Does the issue involve one problem, and one problem only?
 
2457 Some of our users seem to think there is a limit of issues they can or
 
2459 There is no limit of issues they can or should open.
 
2460 While it may seem appealing to be able to dump all your issues into one
 
2461 ticket, that means that someone who solves one of your issues cannot
 
2462 mark the issue as closed.
 
2463 Typically, reporting a bunch of issues leads to the ticket lingering
 
2464 since nobody wants to attack that behemoth, until someone mercifully
 
2465 splits the issue into multiple ones.
 
2467 In particular, every site support request issue should only pertain to
 
2468 services at one site (generally under a common domain, but always using
 
2469 the same backend technology).
 
2470 Do not request support for vimeo user videos, White house podcasts, and
 
2471 Google Plus pages in the same issue.
 
2472 Also, make sure that you don\[aq]t post bug reports alongside feature
 
2474 As a rule of thumb, a feature request does not include outputs of
 
2475 youtube\-dl that are not immediately related to the feature at hand.
 
2476 Do not post reports of a network error alongside the request for a new
 
2478 .SS Is anyone going to need the feature?
 
2480 Only post features that you (or an incapacitated friend you can
 
2481 personally talk to) require.
 
2482 Do not post features because they seem like a good idea.
 
2483 If they are really useful, they will be requested by someone who
 
2485 .SS Is your question about youtube\-dl?
 
2487 It may sound strange, but some bug reports we receive are completely
 
2488 unrelated to youtube\-dl and relate to a different, or even the
 
2489 reporter\[aq]s own, application.
 
2490 Please make sure that you are actually using youtube\-dl.
 
2491 If you are using a UI for youtube\-dl, report the bug to the maintainer
 
2492 of the actual application providing the UI.
 
2493 On the other hand, if your UI for youtube\-dl fails in some way you
 
2494 believe is related to youtube\-dl, by all means, go ahead and report the
 
2498 youtube\-dl is released into the public domain by the copyright holders.
 
2500 This README file was originally written by Daniel
 
2501 Bolton (https://github.com/dbbolton) and is likewise released into the