Tenderlove Making

My NPR is so Loud, they Hatin'

I’m up outta here tomorrow for Spain, and I realized that I’ll be missing out on my This American Life shows, so I am revisiting time-shifting my radio. I’ve got a D-Link USB Radio plugged in to my linux machine. I just had to install Alsa, lame, and fmtools and come up with a script to marry them. Here’s what I came up with:

#!/usr/bin/ruby -w

raise "#{$0} <name> <freq> <seconds>" if ARGV.length < 3

show    = ARGV[0]
freq    = ARGV[1]
seconds = ARGV[2]

FM      = '/usr/local/bin/fm'
LAME    = '/usr/bin/lame'
AMIXER  = '/usr/bin/amixer'
ARECORD = '/usr/bin/arecord'

file    = "#{ENV['HOME']}/#{show}_#{Time.now.strftime('%Y-%m-%d')}"
# Tune the radio
%x{#{FM} #{freq} 65535}

# Set up the mixer settings
%x{#{AMIXER} -c 0 set Line,0 100%,100% unmute cap}
%x{#{AMIXER} sset Capture 75%,75% unmute cap}
%x{#{ARECORD} -f cd -t wav -d #{seconds} #{file}.wav}
%x{#{LAME} --quiet -m j --preset standard #{file}.wav #{file}.mp3}
%x{rm #{file}.wav}

Then just set up my crontab to record the show: 0 19 * * Fri /home/aaron/record.rb TAL 94.9 3600

Now I'll have This American Life waiting for me when I get home!
« go back