#!/usr/bin/ruby #usage: youtube-to-mp3 #example: youtube-to-mp3 http://www.youtube.com/playlist?list=PL398CE05652474A1E #desc: downloads a single youtube vid or a playlist, then converts to mp3. # Requires youtube-dl and ffmpeg url = ARGV[0] system("youtube-dl -citA #{url}") Dir.foreach(".") do |file| filename = file[/(^\d{5}.*)[\-].*/,1] if filename != nil mp3_file = filename + ".mp3" system("ffmpeg -i \"#{file}\" -vn -acodec libmp3lame -ar 44100 -ac 2 -ab 128000 \"#{mp3_file}\"") end end