A quick and easy way of downloading MP3s from Youtube.

08 September 2020

Let's say you find a particularly banging' track on Youtube that you'd like to save for posterity.. what's an easy way of grabbing just the audio so you can listen to it later?  Sure, you can go hunting for a sketchy website that'll download the video, strip out the audio, and give it to you in a download, but those come and go and you can never be sure you're getting what you want.  My personal favorite technique is to use youtube-dl: youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=EO2dPcvf1BQ

But I can never remember off the top of my head what combination of command line switches to use, I always have to go through youtube-dl's online help to find it.  Recently I realized that I could set a shell alias for this command and go about my usual business.  Oh, and document it so the next time I have to set up a box, I can just search my blog for what I did...  It was trivial to do, I just added the following to my ~/.bashrc file: alias mp3-dl='youtube-dl -x --audio-format mp3'

Now I just have to do this:

{09:28:27 @ Tue Sep 08}
[drwho @ windbringer mp3] () $ mp3-dl https://www.youtube.com/watch?v=EO2dPcvf1BQ
[youtube] EO2dPcvf1BQ: Downloading webpage
[youtube] EO2dPcvf1BQ: Downloading MPD manifest
[dashsegments] Total fragments: 12
[download] Destination: Warren Zevon - Real or Not w_Lyrics-EO2dPcvf1BQ.webm
[download] 100% of 1.64MiB in 00:01
[ffmpeg] Destination: Warren Zevon - Real or Not w_Lyrics-EO2dPcvf1BQ.mp3
Deleting original file Warren Zevon - Real or Not w_Lyrics-EO2dPcvf1BQ.webm (pass -k to keep)
{09:28:45 @ Tue Sep 08}
[drwho @ windbringer mp3] () $

Share and enjoy!