Downloading Audio/Songs from YouTube

Sometimes you come across a video in YouTube and you want to save its audio. Originally I thought it would take some search for the actual URL of the flv source, then downloading it using wget and finally conversion using ffmpeg. But luckily for me, it turns out there is much simpler way to so so: youtube-dl is small python script that does it all. It will download and extract the audio from a YouTube video without any hassle.

Installation is quick via pip:

$ pip install --user youtube_dl

Note that there is an underscore there instead of an hyphen. youtube-dl is also available in Ubuntu’s repository, however the version there is too old and didn’t work for me. The --user flag tells pip to install it for the current user (I just don’t like installing unnecessary things as root :-)). Now all you have to do is:

$ youtube-dl --extract-audio http://www.youtube.com/watch?v=XXXXXXXXXX

All that is left is to fix the metadata tags of the file with the correct values with your favorite player.

One thought on “Downloading Audio/Songs from YouTube”

  1. Awesome. I am running a Linux VM on my computer and your tip helped a lot. On my windows, i usually use youtube downloader, it downloads the video, but then you manually need to convert it which is a hassle.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.