Youtube Ripping Made Easy

12-11-2014 – Updated bash script syntax to reflect usage of –youtube-skip-dash-manifest to keep errors down when doing bulk processed lists of videos.

There are plenty of annoying windows tools that claim to be able to properly rip audio from Youtube, however I don’t trust most of them any further than I can throw a car.  Here is a dirt simple guide to ripping audio on Linux, you could even accomplish it on a headless server if you really felt like it.

The center piece of this process is youtube-dl which is just a python script which takes care of all the work of pulling down and converting the files to mp3.  Go ahead and pull down the script, and drop it somewhere that you can access (check your $PATH variable depending on your distro of choice) and don’t forget to chmod +x the file so that its executable without first invoking the Python interpreter.  At this point you also want to make sure you have ffmpeg installed as that’s what does all the leg work for youtube-dl.  Once you have that out of the way lets look at a sample use of this program to figure out how to streamline things so you don’t have to type out a pile of arguments every time you want to pull down a file.

youtube-dl -l --prefer-free-formats --extract-audio --audio-format mp3

Fortunately the developers of this app didn’t go ape with cryptic command line arguments, pretty much everything there is self explanatory except for -l, which to save everyone the time of checking the –help output is to give it a litteral file name instead of the pseudo-random one that it derives from the youtube id string.  Now to simplify things even more, lets make a bash script called ‘ytdl’ in the same location you placed youtube-dl earlier.


/usr/local/bin/youtube-dl $1 --youtube-skip-dash-manifest -q -o %(title)s.%(ext)s --prefer-free-formats --extract-audio --audio-format mp3

Make the script executable and now all you have to do is invoke ytdl <youtubeurl> and it will kick off the process.  Background the process for bulk conversions or better yet if you really want to make things slick create a php front end for the whole thing (but make sure to password protect it) so you can pull down mp3s from youtube.  The one caveat is some videos don’t convert over to mp3 but mp4 or other strange formats that won’t work with this, at this point I don’t have a real fix for this but I’m sure one is in the works somewhere.