It's all spinning wheels and self-doubt until the first pot of coffee.

I'm finally timeshifting radio again

Today's bundle of little discoveries:

  • DSBRTuner has been updated to support AppleScript since last I downloaded it.
  • DSBRTuner has been updated to record to MP3 on disk.
  • MacOSX has a command called osascript with which you can launch AppleScripts (among other things) from a shell.
  • Like perl, osascript has an option -e to run a one-liner from the shell.

Given these discoveries, I was able to cobble together a quick pair of scripts with which to schedule recording radio broadcasts to MP3 via cron.

Wow. Another little project that became, all of a sudden, so much easier than I thought. I love Unix and OS X. Before this, I'd been looking high and low for all the parts: a scheduler, a sound recorder, an app controller, etc & so forth. Given the source code to DSBRTuner, I was almost about to hack some solutions into it, but I'd never gotten the time.

Now, I can happily record and listen to my favorite late Sunday night radio show during the week again!

Oh yeah, and the ugly scripts:

1) dsbr_start_recording

MP3_FN="$2-`date "+%Y%m%dT%H%M%S"`.mp3"
TELL='tell application "DSBRTUNER" to'

open /Applications/DSBRTuner.app
$OSA -e "$TELL set frequency to $FREQ"
$OSA -e "$TELL record to file "$MP3_FN""

2) dsbr_stop_recording

TELL='tell application "DSBRTUNER" to'

open /Applications/DSBRTuner.app
$OSA -e "$TELL stop recording"
$OSA -e "$TELL quit"


Archived Comments