Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

An AppleScript to record Car Talk via Audio Hijack Apps
I love Car Talk from Click and Clack and NPR. Since I live in France, I can't get it over the radio, but I do listen over the Internet. My favorite way to listen is to record a show to my iPod and then listen to it in the car on my way to the beach on the weekend -- the drive is about an hour long, and Tom and Ray make it easy to forget about the traffic.

I wanted to automate this process, but the URL for the RealAudio stream changes every week. So I wrote an AppleScript that figures out what this week's URL is, and I call that script from Audio Hijack every Tuesday morning. Audio Hijack then passes the file to iTunes when it's done with it, where it gets added to a Smart "CarTalk" playlist. VoilĂ  -- Car Talk in my car, every week!

Script: CarTalkByWeek
set today to current date
set NewYearsDay to date "1/1" of today
set SecondsOfYear to today - NewYearsDay
set WeekOfYear to round SecondsOfYear / weeks + 1 rounding down
set ThisWeeksCarTalk to "05" & WeekOfYear
set CarTalkURL to "http://play.rbn.com/?url=cartalk/cartalk/demand/CT" ¬
& ThisWeeksCarTalk & "-01.ra?url=cartalk/cartalk/demand/CT" ¬
& ThisWeeksCarTalk & "-02.ra?url=cartalk/cartalk/demand/CT" ¬
& ThisWeeksCarTalk & "-03.ra?url=cartalk/cartalk/demand/CT" ¬
& ThisWeeksCarTalk & "-04.ra?url=cartalk/cartalk/demand/CT" ¬
& ThisWeeksCarTalk & "-05.ra?url=cartalk/cartalk/demand/CT" ¬
& ThisWeeksCarTalk & "-06.ra?url=cartalk/cartalk/demand/CT" ¬
& ThisWeeksCarTalk & "-07.ra?url=cartalk/cartalk/demand/CT" ¬
& ThisWeeksCarTalk & "-08.ra?url=cartalk/cartalk/demand/CT" ¬
& ThisWeeksCarTalk & "-09.ra?url=cartalk/cartalk/demand/CT" ¬
& ThisWeeksCarTalk & "-10.ra"
tell application "RealPlayer"
  open clip with URL CarTalkURL
end tell
To do's...
  • I wish I could figure out how to handle errors from RealAudio if/when the script gets the URL wrong. "Handling errors" would generally mean sending myself an email.
  • I wish I could figure out how to reliably wake my beige G3 (Jaguar) from power-off on Tuesday mornings to make sure the script runs; I tried ResurrXtion, but I couldn't get it working repeatedly/reliably.
    •    
  • Currently 3.67 / 5
  You rated: 4 / 5 (6 votes cast)
 
[23,378 views]  

An AppleScript to record Car Talk via Audio Hijack | 13 comments | Create New Account
Click here to return to the 'An AppleScript to record Car Talk via Audio Hijack' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to record Car Talk via Audio Hijack
Authored by: andybru on Jul 07, '05 10:57:55AM

Woohoo! Thank you! I have been meaning to do something like this for months!
There are a few NPR programs I'd like to do this with - "Car Talk", "Wadda ya know", "Wait, Wait Don't Tell me" and SciFri (although that is now being Podcast).
Thanks again!



[ Reply to This | # ]
An AppleScript to record Car Talk via Audio Hijack
Authored by: schiefaw on Jul 07, '05 12:13:35PM

Science Friday, at least, is now available as a podcast from the Apple store.



[ Reply to This | # ]
An AppleScript to record Car Talk via Audio Hijack
Authored by: maddys_daddy on Jul 07, '05 01:55:04PM
...and SciFri (although that is now being Podcast).
Yes, I think he said that.

[ Reply to This | # ]
An AppleScript to record Car Talk via Audio Hijack
Authored by: osxpounder on Jul 07, '05 09:20:53PM

Wow, andy, 2 of those shows don't run in my city. I'm glad to hear about SciFri -- I had no idea it existed, and since it podcasts, I suppose I can find out all about it. Thanks!

---
--
osxpounder



[ Reply to This | # ]
An AppleScript to record NPR's Morning Edition via Audio Hijack
Authored by: crashcane on Jul 07, '05 12:04:39PM
Thanks, I was trying to figure it out myself, now you saved me some work. Here is a script I wrote to record the daily morning edition show via Audio Hijack. The script URL is set to use windows media player, but you can change that by changing the text
mediaPref=WM
to
mediaPref=RM 
I am not sure if it works to grab Weekend Edition as well, since I only use it on weekdays.

tell application "Finder"
	set myDATE to (do shell script "date +%d-%b-%G") as string
end tell
tell application "Safari"
	open location ("http://www.npr.org/dmg/dmg.php?prgCode=ME&showDate=" & myDATE & "&segNum=&mediaPref=WM&getUnderwriting=1")
end tell


[ Reply to This | # ]
An AppleScript to record Car Talk via Audio Hijack
Authored by: jolietconvict on Jul 07, '05 12:08:08PM

Beter yet just use Radio Recorder to record the mp3 stream of one of the NPR stations that broadcast in mp3.



[ Reply to This | # ]
An AppleScript to record Car Talk via Audio Hijack
Authored by: jspivack on Jul 07, '05 12:22:04PM

This would require knowing at which time the show is broadcast. The hint's way doesn't depend on a time-dependent stream.



[ Reply to This | # ]
An AppleScript to record Car Talk via Audio Hijack
Authored by: laurion on Jul 07, '05 02:02:13PM

I've been recording it for months. I just grab the live stream from one of the NPR stations that has it (I think in Connecticut), running it through Audio Hijack. I do this for a few other shows as well. Applescript works, but is probably more complicated than necessary.



[ Reply to This | # ]
An AppleScript to record Car Talk via Audio Hijack
Authored by: sherbang on Jul 07, '05 04:43:26PM

I've done the same thing, but differently.

I've written a python script that uses mplayer to download the realplayer streams to wav files, then I convert them to ogg, but you could just as easily convert them to mp3s.

The benefit of this is that you don't need to use a program like AudioHijack to get the audio, it's all done with free software.

This requires Mplayer, you must also add the realplayer libraries to mplayer for i to play realaudio streams, and it requires oggenc to encode the oggs (or lame if you want to make it do mp3s instead).


#!/usr/bin/python

import datetime
import os

urlcore='rtsp://rx-lvl3-ny23.rbn.com/farm/*/cartalk/cartalk/demand/CT'
oldweeknumber=518
olddate=datetime.date(2005,5,1)
datediff = datetime.date.today() - olddate
weeknumber = oldweeknumber + (datediff.days/7)

mplayer='/Applications/MPlayer OS X 2.app/Contents/Resources/mplayer.app/Contents/MacOS/mplayer'
oggenc='oggenc'
outdir='/Users/sherbang/Cartalk/'

num = 1
while num < 11:
  url = '%s%0.4i-%0.2i.ra' % (urlcore, weeknumber, num,)
  filename = 'CarTalk Episode %s - %02i' % (weeknumber, num,)

  #download with mplayer
  mplayercommand = '"%s" "%s" -ao pcm:file="%s%s.wav" -af channels=2:2:0:0:0:1 -vc dummy -vo null'% (mplayer, url, outdir, filename,)
  ret = os.system(mplayercommand)
  assert ret == 0, 'mplayer failed: %s' % mplayercommand

  #oggenc + tag
  oggenccommand = '"%s" "%s%s.wav" -l "CarTalk Episode %s" -t "CarTalk %s-%0.2i" -N %i -G "Talk Radio"' % (oggenc, outdir, filename, weeknumber, weeknumber, num, num,)
  ret = os.system(oggenccommand)
  assert ret == 0, 'oggenc failed: %s' % oggenccommand

  #delete outdir+filename+'.wav'
  os.unlink(outdir+filename+'.wav')
  num += 1

print 'DONE'


[ Reply to This | # ]
An AppleScript to record Car Talk via Audio Hijack
Authored by: bcarver on Nov 09, '05 03:33:50PM
Sherbang--excellent script. I modified your code to allow encoding to MP3 with lame. Works for me on ubuntu quite nicely.

#!/usr/bin/python

import datetime
import os

urlcore='rtsp://rx-lvl3-ny23.rbn.com/farm/*/cartalk/cartalk/demand/CT'
oldweeknumber=518
olddate=datetime.date(2005,5,1)
datediff = datetime.date.today() - olddate
weeknumber = oldweeknumber + (datediff.days/7)

mplayer='/usr/bin/mplayer'
oggenc='/usr/bin/oggenc'
lame='/usr/bin/lame'
outdir='/home/bcarver/cartalk/'

num = 1
while num < 11:
  url = '%s%0.4i-%0.2i.ra' % (urlcore, weeknumber, num,)
  filename = 'CarTalk Episode %s - %02i' % (weeknumber, num,)

  #download with mplayer
  mplayercommand = '"%s" "%s" -ao pcm:file="%s%s.wav" -af channels=2:2:0:0:0:1 -vc dummy -vo null'% (mplayer, url, outdir, filename,)
  ret = os.system(mplayercommand)
  assert ret == 0, 'mplayer failed: %s' % mplayercommand

  #oggenc + tag
  #oggenccommand = '"%s" "%s%s.wav" -l "CarTalk Episode %s" -t "CarTalk %s-%0.2i" -N %i -G "Talk Radio"' % (oggenc, outdir, filename, weeknumber, weeknumber, num, num,)
  #ret = os.system(oggenccommand)
  #assert ret == 0, 'oggenc failed: %s' % oggenccommand  

  #lame + tag
  lamecommand = '"%s" --tl "CarTalk Episode %s" --tt "CarTalk %s-%0.2i" -ta "Dewey, Cheetham and Howe" --tn %i --tg "Other" "%s%s.wav" "%s%s.mp3"' % (lame, weeknumber, weeknumber, num, num, outdir, filename, outdir, filename)
  ret = os.system(lamecommand)
  assert ret == 0, 'lame failed: %s' % lamecommand  

  #delete outdir+filename+'.wav'
  os.unlink(outdir+filename+'.wav')
  num += 1

print 'DONE'


[ Reply to This | # ]
How to find NPR stations broadcasting Car Talk
Authored by: hamarkus on Jul 07, '05 06:23:25PM

You can get a list of almost all NPR stations broadcasting Car Talk at:
http://publicradiofan.com/cgi-bin/program.pl?programid=36

Over the weekend you can listen to it at almost any time you want, coming close to something like radio-on-demand. As others have pointed out, you can use programs like Audio Hijack to schedule an automated recording.



[ Reply to This | # ]
How to find NPR stations broadcasting Car Talk
Authored by: ledheadzeppelin on Jul 13, '05 07:06:56PM

when i use the script on the first post it doesnt work and i cant save it for audio hijack can anyone help



[ Reply to This | # ]
An AppleScript to record Car Talk via Audio Hijack
Authored by: pokeysan on Sep 25, '06 10:39:30AM
Even better, you can avoid the opening advertisement by changing getUnderwriting=1 to getUnderwriting=0

This script also works for Fresh Air, if you change prgCode=MA to prgCode=FA

Now if anyone has figured out how to automate This American Life, Studio 360, or To the Best of Our Knowledge, please let me know. The latter 2 programs do have podcasts, but they include only a segment of the show.

[ Reply to This | # ]