Twitter and YouTube download

First intall yt-dlp (that's youtube-dl fork based on the inactive youtube-dlc)

brew install yt-dlp

Download video

Download the best video quality with the best extension - for video, mp4 > webm > flv or for audio, m4a > aac > mp3 :

yt-dlp -S "ext" -o "~/Download/%(title)s.%(ext)s" [URL]

Extract MP3 audio from YouTube video

Get the best audio quality into mp3 file:

yt-dlp -f "ba" -x --audio-format mp3 [URL]

Download other formats

First you need to list all available formats with:

yt-dlp --list-formats [URL]

then download them using --format or -f parameter:

yt-dlp --format mp4 [URL]

Other useful commands

If you will need to update yt-dlp use:

yt-dlp -U