Automated Commercial Recorder
Mythtv could be of use to you.  It will automatically mark commercial in points and out points in a recording.  You could modify the their transcode shell script to cut the program and leave the commercials.