2022 UPDATE: It's better to use the YT-DLP fork of youtube-dl at this point. You can always make an alias for yt-dlp
like so: alias youtube-dl='/usr/local/bin/yt-dlp'
(make sure to replace /usr/local/bin/
with your actual yt-dlp path).
YouTube has recently blocked age-restricted videos from being downloaded. You can use the youtube-dl
's --cookies
flag to pass your stored cookie preferences to the command to bypass this.
- Install a Chrome extension like Get Cookies.txt to get your browser's cookies.
- Install youtube-dl from source, or use Python 3's PIP package manager to install it.
- Obtain a copy of your browser cookies stored as a
.txt
file.
Download youtube-dl and install the command-line tool for your operating system. You can also use Python's PIP package manager to install youtube-dl, which is recommended.
Download the latest version of youtube-dl. On macOS you can put the binary in the /usr/local/bin
directory, or you install it using pip3
.
In a UNIX-like terminal you can use the which youtube-dl
command to verify it's installed, or use the youtube-dl --version
command to see which installed version is associated with the command.
Use the which pip
or which pip3
command to ensure that PIP for Python is installed.
Make sure to use the version of PIP that's associated with Python 3.x, and then execute the following command:
pip3 install youtube-dl
brew install youtube-dl
Basic youtube-dl
command is as follows:
youtube-dl "https://www.youtube.com/watch?v=VIDEO_ID_GOES_HERE"
youtube-dl "https://www.youtube.com/watch?v=VIDEO_ID_GOES_HERE" --cookies path/to/cookies.txt
NOTE: These commands should work in Windows command prompt, or in a UNIX-like terminal on macOS and Linux. Make sure to use \
instead in Windows command prompt.
Run the youtube-dl
command using Python 3 with the --verbose
and --all-subs
options:
python3 /usr/local/bin/youtube-dl -f bestvideo+bestaudio \
--all-subs --cookies path/to/cookies.txt \
"https://www.youtube.com/watch?v=VIDEO_ID_GOES_HERE" --verbose
Use this last command in case you get an AttributeError: 'bool' object has no attribute 'split'
error and you need to explicitly use Python 3. In a Windows 10 command prompt you'll probably need to use the py
command instead of python3
.
The -f bestvideo+bestaudio
option will download the best quality possible.