My NPR is so Loud, they Hatin’ 4

Posted by Aaron Patterson on September 11, 2006

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
[/sourcecode]
Now I'll have This American Life waiting for me when I get home!

Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

  1. pshjackie Mon, 11 Sep 2006 22:03:21 UTC

    this posting is so nerdy that it’s doubly-nerdy, which means it cancels itself out and is now identified as a non-entity-blog-entry. sorry i had to be the one to tell you. i’ll miss you sissyboy! have fun!

  2. Aaron Patterson Tue, 12 Sep 2006 09:44:55 UTC

    You can’t get away with a “comment goodbye”. You are getting a phone call when I get to the airport young lady.

  3. Jamie Thingelstad Tue, 24 Oct 2006 20:56:59 UTC

    You can do this much easier just by downloading the episode from the TAL shoutcast server. Just do

    curl -O -A ‘iTunes/4.7 (Macintosh; N; PPC)’ http://wbez-tal.streamguys.us:8020/content/313.mp3

    Obviously replacing the 313 with the episode number. Voila!

  4. Aaron Patterson Wed, 25 Oct 2006 10:24:51 UTC

    Awesome. I came up with this script before TAL had a podcast, but this is much easier!

Comments

Check Spelling
Activate Spell Check while Typing