If you want to download videos or music from YouTube, you can use a utility known as yt-dlp.

Installation

You can install this tool using Homebrew by running the follwing commands.

brew install yt-dlp ffpmeg fprobe

Download

Single Video

# Download Music Only
yt-dlp --extract-audio --audio-format mp3 --audio-quality 6 https://www.youtube.com/watch?v=24a4eZZOTxU

# Download Best Video/Audio
yt-dlp -f "bv*+ba/b" https://www.youtube.com/watch?v=24a4eZZOTxU

Playlists

I wanted to download the audio for a currently unpublished collection of work, the soundtrack for The Flight of the Navigator.

Here’s the command I used to download the audio for all videos in the playlist.

yt-dlp --yes-playlist -x --audio-format mp3 --audio-quality 6 https://www.youtube.com/playlist?list=PLq6QtwrGW1_9HF_LyRS1DNvCl8slXcYNO