The first thing we need to do is to open up the Terminal located in /Applications/Utilities/ or simply by invoking Spotlight and typing Terminal.
We’re going to install a package called youtube-dl, which is a command-line application that lets you download videos directly from YouTube and a handful of other sites (including Vimeo!). It’s a great little tool to have at your fingertips and there are two ways to install it: directly or via a package manager like Homebrew.
Direct Install of youtube-dl
In the terminal window, copy/paste the first line, press return, then copy/paste the second line, press return:
sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl sudo chmod a+rx /usr/local/bin/youtube-dl
After the first command you will be asked to enter your system password, just like if you were installing an app from a source outside of the App Store.
Install via Homebrew (my preferred method)
Homebrew is a package manager. Think about it like a terminal-based App Store/aggregator. Developers submit their apps to the Homebrew repository and then, rather than having to remember obscure and long strings of text like you see above, Homebrew abstracts it away in favor of something simpler. First, you have to install Homebrew, like so:
sudo /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
That will download and install all of the necessary components for Homebrew. At that point, you can now install youtube-dl via a simpler brew command.
brew install youtube-dl
Once that is successful, now you’re ready to rock!
Snag a YouTube Video For Funsies
While in the Terminal still, let’s grab a YouTube video for fun so you can see how it all works. The basic format is super straightforward:
youtube-dl https://www.youtube.com/watch?v=dQw4w9WgXcQ -f mp4
That simple command says: Use youtube-dl to download the video at the URL in an MP4 format. You could also use -f webm for the WebM version (usually for the 4K versions) or even -f mp3 to just grab the audio. That will download to your Home folder by default Macintosh HD/Users/USERNAME/
To change the location to a spot of your choosing, you can add the -o command, which specifies an output folder. Here’s what it would look like if I wanted the video to download to my Movies folder:
youtube-dl https://www.youtube.com/watch?v=dQw4w9WgXcQ -f mp4 -o "/Users/agormley/Movies/%(title)s.%(ext)s"
Protip: After typing -o in the Terminal, the easiest way to specific a custom path is to just drag and drop the destination folder right into the Terminal window. It’ll automatically populate the path! Don’t forget to add the very-important trailing slash with the file-naming template /%(title)s.%(ext)s

Shreniks-MacBook-Pro:~ shreniksalguna$ youtube-dl https://www.youtube.com/watch?v=HKQNsX5_S38 -f mp3 -o "/Users/shreniksalguna/Downloads/YouTube/%(title)s.%(ext)s"