Like many displaced Canadians, I like to listen to CBC Radio 3 at work to keep me feeling culturally connected to my home country. But the shows I enjoy tend to be on at inconvenient times here in Australia. Thanks to Radioshift, that isn’t a problem!
Radioshift from Rogue Amoeba is a Mac application for scheduled recording of web radio streams. Radioshift makes it easy to import your recordings into iTunes, but it would be nice, I thought, if those recordings showed up as a podcast, instead of normal music tracks in my iTunes library.
Why A Podcast?
By default, podcasts in iTunes remember your playback position when you stop listening to them halfway through, and aren’t played when you shuffle your entire iTunes music library. You can also choose to delete podcasts automatically after you have listened to them.
With the release of iPhone OS 3.0, podcasts gained even more benefits while on the go: when listening to a podcast on an iPhone or iPod touch, you can choose to listen at 2X speed, and also skip back 30 seconds with a single tap.
These new features were enough to make me get off my butt and do a little work.
Step 1: Generate A Podcast Feed
Technically, a podcast is just a text file that points to the MP3/M4A files that iTunes should download and store in its library. I whipped up a Python script that will generate a podcast file (podcast.xml) given a directory full of MP3/M4A files (such as those contained in the ~/Music/Radioshift folder after Radioshift does its thing).
To install this script on your own Mac, download this ZIP file containing three Python files:
Once you’ve unzipped the file, put all three files (podcastFromFolder.py) somewhere handy, like your home directory (/Users/kyank).
With the files in place, let’s test that the script works. Open Terminal and follow along.
First, you’ll need to make the podcastFromFolder.py script executable:
Computer:~ kyank$ chmod u+x podcastFromFolder.py
Be sure to specify the path to the podcastFromFolder.py file if you put it somewhere else on your system (mine is actually in ~/bin/podcastFromFolder.py).
Now try running the script in your Radioshift recordings folder:
Computer:~ kyank$ cd "Music/Radioshift/My Show"
Computer:My Show kyank$ ~/podcastFromFolder.py
In the first command, instead of My Show you’ll need to type the actual name of the folder containing your desired show’s Radioshift recordings (mine’s CBC Radio 3 with Grant Lawrence 2).
In the second command, again, you’ll need to specify the path to the script if it’s somewhere other than in your home directory.
If all goes well, these commands should execute silently, and you should find a new podcast.xml file in the folder along with any .M4A files that Radioshift has stored there. This file will contain the feed that tells iTunes about your “fake” podcast.
Step 2: Serve Up Your Podcast Feed
Unfortunately, iTunes is picky about where it gets its podcast feeds. You can’t simply point it at a file on your hard disk (believe me, I’ve tried!). iTunes will only accept a podcast feed that it retrieves from the Web.
Fortunately, the Mac comes with everything you need to make your computer look like part of the Web.
Open System Preferences, and click Sharing. Select Web Sharing from the menu on the left, and make sure the On checkbox next to Web Sharing is checked.
This enables the Apache 2 web server built into Mac OS X. Next, we need to make your Radioshift recordings folder available to the Web. Pop open Terminal and follow along:
Computer:My Show kyank$ cd ~/Sites/
Computer:Sites kyank$ ln -s "~/Music/Radioshift/My Show" "MyShow"
In that second command, replace My Show with the name of the folder for your desired show’s Radioshift recordings, and replace MyShow with a “web friendly”, simplified version of the show title. Here’s exactly what I typed on my system:
ln -s "~/Music/Radioshift/CBC Radio 3 with Grant Lawrence 2"
This creates in your Sites folder an alias that points to the folder containing your show’s recordings (and your new podcast feed file).
Open your web browser of choice and type this address:
Replace kyank with your Mac OS X username (it’s what appears before the $ in the Terminal prompt), and MyShow with the “web friendly” title you chose for your show above.
Chances are, the first time you try this address, your browser will tell you that you don’t have permission to view the requested page. You need to give Apache permission to follow the alias you created from your Sites folder above.
To do this, you’ll need to edit the user.conf file (where user is your Mac OS X username) in /etc/apache2/users. Since this is a protected system file, the simplest way to do this is probably to use the nano editor from inside Terminal:
Computer:Sites kyank$ cd /etc/apache2/users
Computer:users kyank$ sudo nano kyank.conf
Type your password when prompted, and the nano text editor will fill your Terminal window. On the line that begins with
FollowSymLinks to the end, so the file looks like this:
Options Indexes MultiViews FollowSymLinks
Allow from all
With that done, type ^O and then Enter to save your changes, then ^X to exit the nano editor. Go back into System Preferences and turn Web Sharing off and then on again to make this change take effect. Finally, load up that URL again:
Your browser should now display a list of the files contained in the show’s Radioshift recordings folder, including the podcast.xml file.
Now that you have a URL where iTunes will be able to find your podcast feed, you need to regenerate the podcast.xml file with a few extra settings to make the file complete. Again, pop open Terminal:
Computer:~ kyank$ cd "Music/Radioshift/My Show"
Computer:My Show kyank$ ~/podcastFromFolder.py .
"Grant Lawrence on CBC Radio 3" http://radio3.cbc.ca/
Notice the four new parameters I am passing to the podcastFromFolder.py script. You’ll want to supply your own values using this guide:
- The first parameter tells the script what folder to work on. Just type a period (or full stop, if you call it that) to tell it to use the current directory.
- "Grant Lawrence on CBC Radio 3"
- The second parameter specifies the title of your podcast as it should be displayed in iTunes (and on your iPod or iPhone). Choose something short that you’ll recognise.
- The third parameter specifies the web site that the podcast came from, so you can get to it from within iTunes. Set it to the URL of the web radio site that Radioshift records for you.
- This is the important one. Set this to the URL that you have just set up to point to your show’s Radioshift recordings folder. The script will use this to generate the full URLs to each of the audio files in the folder, and include them in the podcast feed.
Again, the script should run silently and generate a fresh podcast.xml file, which now contains everything iTunes needs to know to access your Radioshift recordings.
Step 3: Subscribe To Your Feed
Open iTunes, and from the menu bar choose Advanced → Subscribe to Podcast…
In the window that pops up, type the full URL to your podcast.xml file. Mine looks like this:
Click OK, and iTunes should happily begin downloading the most recent recording into a new podcast with the title you specified. You can click the Get All button to instruct it to get all of your recordings (assuming you have more than one).
You did it! Your iTunes library now contains your Radioshift recordings as a podcast.
Step 4: Automate Feed Updates
Of course, as Radioshift makes new recordings, you will want these to appear in your iTunes podcast too. This means you need to automate the running of the podcastFromFolder.py script every time a new recording is completed.
It is possible to set this up using Mac OS X’s Folder Actions, and if you’re an AppleScript genius I invite you to do so. In practice, I find Folder Actions unreliable even in Leopard (they seem to become disabled for no reason after working perfectly for days), and dealing with recordings-in-progress and other such complexities is not for the faint of heart.
Rather, I recommend you grab yourself a copy of Hazel from Noodlesoft, which is a System Preferences panel that will monitor folders for files matching the criteria you specify, and then do whatever you like to them.
With Hazel installed, open System Preferences and choose Hazel. In the Folder list on the left, add the folder containing your show’s Radioshift recordings. Then, on the right, click the + button to add a new rule.
Copy the settings for the rule from this screenshot:
Make sure to adjust the path to podcastFromFolder.py, and the arguments passed to the script to match those you used when manually invoking it above.
With the rule in place, Hazel should generate an updated podcast.xml file each time Radioshift finishes a new recording, which will enable iTunes to add the recording to your library as a new episode of the podcast.
Note that, while iTunes copies the recordings into your library, the original recordings remain in your Radioshift recordings folder. To save disk space, you will want to periodically open Radioshift and delete all the old recordings. Better yet, you can use another Hazel rule to automatically delete recordings from the recordings folder after a week or so—the copies will remain in your iTunes library, and the corresponding entries will be purged from the podcast feed the next time Radioshift downloads a new recording.
If this seems like a lot of work, you’re not imagining things. I have sent Rogue Amoeba a feature request to suggest that it make exposing your subscriptions as podcasts visible to iTunes a built-in feature in a future version of Radioshift.
In the meantime, if you use Radioshift to record a regular web radio broadcast, the added convenience of having new episodes appear as a podcast in iTunes will make all the hackery above worthwhile.
Let me know if you run into any trouble with the above setup, or if you have any suggestions for improving it.