Taken from here
yay -S atomicparsley
youtube-dl --extract-audio -f bestaudio[ext=m4a] --add-metadata --embed-thumbnail YOUTUBE_URL
Update 2025-12-11
yt-dlp is the successor to youtube-dl. Here is the latest (with an appropriate cookies file)
yt-dlp --audio-format m4a -x --embed-metadata --embed-thumbnail --cookies cookies.txt YOUTUBE_URL
You can also do a list of URLs by passing the -a argument:
yt-dlp --audio-format m4a -x --embed-metadata --embed-thumbnail --cookies cookies.txt -a playlists.txt
I used this cheat sheet to get the parameters I want.