How to Download YouTube Videos and Playlists with youtube-dl on Windows, Linux, and macOS (Tutorial)
Table of Content
Want to download YouTube videos for offline use or save an entire playlist for a long flight? youtube-dl
is your go-to open-source tool for this. It's simple, efficient, and works across multiple platforms.
In this guide, we'll show you how to install youtube-dl
on Windows, Linux, and macOS, and demonstrate how you can use it to download both individual videos and entire playlists. Let's dive in!
What is youtube-dl
?
youtube-dl
is a powerful, command-line tool for downloading videos from YouTube and other video-sharing sites. It's free, open-source, and supports a wide range of options. You can download specific video formats, extract audio-only versions, and even grab entire playlists.
And don't let the "command-line" part intimidate you! It's simpler than it sounds.
1. Installing youtube-dl
On Windows
- Download the executable: Go to the official GitHub page and download the latest version of
youtube-dl
:
https://github.com/ytdl-org/youtube-dl/releases - Place it in a convenient location: Move the downloaded
youtube-dl.exe
file to a folder, e.g.,C:\youtube-dl
. - Add it to your system PATH:
- Right-click on Start and go to System > Advanced system settings.
- Click Environment Variables.
- In the System Variables section, find Path, click Edit, and add the path to the
youtube-dl.exe
(e.g.,C:\youtube-dl
).
- Install FFmpeg (optional but recommended): This helps with downloading and converting high-quality formats.
- Download FFmpeg from https://ffmpeg.org/download.html.
- Extract the ZIP and add the
bin
folder to your PATH.
Verify the installation: Open Command Prompt and type:
youtube-dl --version
On Linux
Most Linux distributions make it easy to install youtube-dl
via the package manager. For example:
Ubuntu/Debian
sudo apt update
sudo apt install youtube-dl
Fedora
sudo dnf install youtube-dl
Arch Linux
sudo pacman -S youtube-dl
Install FFmpeg
To download high-quality videos or audio, install FFmpeg:
sudo apt install ffmpeg # For Debian/Ubuntu
On macOS
If you use Homebrew, installing youtube-dl
is a breeze:
brew install youtube-dl
To install FFmpeg alongside it:
brew install ffmpeg
Verify Installation:
youtube-dl --version
2. Downloading YouTube Videos
Now that you've got youtube-dl
installed, let's start downloading videos!
Basic Video Download
To download a single video, use:
youtube-dl <video-URL>
Example:
youtube-dl https://www.youtube.com/watch?v=dQw4w9WgXcQ
By default, this will download the highest quality available.
Downloading a Specific Format
Want to choose a particular resolution or format? Use the -F
option to list available formats:
youtube-dl -F <video-URL>
Example Output:
format code extension resolution
249 webm audio only
250 webm audio only
140 m4a audio only
160 mp4 144p
133 mp4 240p
134 mp4 360p
135 mp4 480p
To download a specific format, use:
youtube-dl -f 134 <video-URL>
Extracting Audio Only
Want just the audio from a video? This is useful for podcasts or music tracks:
youtube-dl -x --audio-format mp3 <video-URL>
3. Downloading YouTube Playlists
Yes, youtube-dl
can handle entire playlists!
To download a full playlist, simply provide the playlist URL:
youtube-dl <playlist-URL>
Les see by an example:
youtube-dl https://www.youtube.com/playlist?list=PLx0sYbCqOb8TBPRdmBHs5Iftvv9TPboYG
Downloading Only Specific Videos from a Playlist
You can download specific videos by their index. For example, to download only videos 1, 3, and 5 from a playlist:
youtube-dl --playlist-items 1,3,5 <playlist-URL>
4. Advanced Tips
Download Subtitles:
youtube-dl --write-sub --sub-lang en <video-URL>
Set a Custom Download Directory:
youtube-dl -o "~/Downloads/%(title)s.%(ext)s" <video-URL>
Resume Interrupted Downloads:
youtube-dl -c <video-URL>
Wrapping Up
youtube-dl
is a versatile tool that makes downloading YouTube videos and playlists a breeze. Whether you're on Windows, Linux, or macOS, you now have a reliable way to save your favorite content for offline viewing.
And remember, always respect copyright laws and YouTube's terms of service!
Happy downloading!
Additional Resources:
- Official GitHub Repo: https://github.com/ytdl-org/youtube-dl
- Full Documentation: https://youtube-dl.readthedocs.io/