Turning a protected RTSP stream into an iTunes podcast
Jan 06, '09 07:30:00AM • Contributed by: bed42
Jan 06, '09 07:30:00AM • Contributed by: bed42
A friend of mine does a radio show that interests me. Unfortunately, being a late night show (midnight) and interstate, for me to listen to this live would require me being awake at 4am or so. Due to record label copyright permissions, this show is not available as a podcast download -- it's only available for live or delayed streaming. Undeterred, I wanted to automatically grab the stream and make it available on my iPhone for listening when it suited me, while out and about.
This particular stream is served with the Real Time Streaming Protocol, which means all we really need is the LIVE555 openRTSP command line program. With that installed, it's as simple as calling openRTSP with the stream URL:
In this case, the name of the stream is in the format radioshow_YY_MM_DD.mp4. So my script will grab today's stream. First, a shell script named radioshow.sh: Once I had the file, I wanted to put it in my iTunes library flagged as a podcast. A commandline tool AtomicParsley enables us to set the appropriate MP4 tags so iTunes sees the file as a PodCast. However, AtomicParsley doesn't like the MP4 tags created by openRTSP. To get around this, we can load our file in QuickTime, and then re-export it to MP4. This will now be a file with MP4 tags that AtomicParsley can modify. We can then execute the following command:
[robg adds: I haven't tested this one.]
This particular stream is served with the Real Time Streaming Protocol, which means all we really need is the LIVE555 openRTSP command line program. With that installed, it's as simple as calling openRTSP with the stream URL:
openRTSP -4 -a -t -d 3900 rtsp://streaming.server.com.au:80/streaming.server.com.au/name.mp4 1>name.mp4
This will write the audio stream as a file (named name.mp4 in this example). The next step is to automate this process with a script being launched by crontab (for a Linux server) or launchd (for an OS X server).In this case, the name of the stream is in the format radioshow_YY_MM_DD.mp4. So my script will grab today's stream. First, a shell script named radioshow.sh: Once I had the file, I wanted to put it in my iTunes library flagged as a podcast. A commandline tool AtomicParsley enables us to set the appropriate MP4 tags so iTunes sees the file as a PodCast. However, AtomicParsley doesn't like the MP4 tags created by openRTSP. To get around this, we can load our file in QuickTime, and then re-export it to MP4. This will now be a file with MP4 tags that AtomicParsley can modify. We can then execute the following command:
AtomicParsley name.mp4 --podcastFlag true --artist name --title name --advisory explicit --description name --podcastURL name --podcastGUID 1 --year "2008-12-25" --overWrite
This will create a new file, which we can then drag into iTunes. This will now show up as a proper podcast, so it will automatically sync to my iPhone and then be removed once I've listened to it. Now that's a fair bit of manual mucking around, so we can use AppleScript to automate all of this in one nice move, which can be the scheduled with launchd to occur at a convenient time:
This script does the following:
- Looks in a directory in my file server and copies it file locally
- Loads it into QuickTime, and exports it to add proper tags
- Sets podcast tags with AtomicPasley
- Imports it into iTunes
- Cleans up files
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>RadioShow</string>
<key>ProgramArguments</key>
<array>
<string>/Users/bed/scripts/RadioShow.app</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>8</integer>
<key>Minute</key>
<integer>0</integer>
<key>Weekday</key>
<integer>5</integer>
</dict>
</dict>
</plist>
•
[13,125 views]
