So, I've been using Linux for a while but not really with any skillz, so I thought I would jot down how I got my system to do some things I wanted to, and see if anyone would post a more elegant way to do it. Essentially, I want to save some streamed radio programs that run overnight to disk, so that I can listen to them during work the next day. Some of the programs don't matter the time of day, but I would rather it happen at night when no one is using the network.
First, I wanted to get a show from Detroit's NPR, Liz Copeland's overnight show, which runs midnight to 5am, Monday through Friday. It's a cool mix of jazz, rock, techo, or whatever... always interesting. (Another great reason to support NPR.) The site, WDET, has several streaming options and proved to be the easiest.
Next, I'd like to listen to NightCall with Peter Werbe on another Detroit station (just moved out of Detroit, and missing it). It's an extreeemely liberal talk show, but always well-reasoned and thought-provoking. The show starts at 11pm on Sunday night and runs for 3 hours. The WRIF site, however, uses some crappy applet streaming thing, which required a work around, to get it saved.
Lastly, I wanted the German news, to polish my Duetsche and because for some reason I like listening to German speakers. So I searched up two sites that I had been to before : B5 Actuelle and Deutsche Welle. They were a little better than WRIF, but still a pain in the ass.
Since, I'm dual-booting and working in Windows right now I looked for a Windows solution first and couldn't find one. The best I could find was Total Recorder, which would record your sound output to disk. This looked to be good and not too expensive, except Night Call and Liz Copeland overlap, so I can record both of them at the same time. The dual-boot also has the problem that files are transferred easily from Windows 2000 (damn NTFS) to Linux, but not the other way. I got around this in the standard way, making a FAT partition to use in both systems.
So I searched around some more and finally found that MPlayer has a function that allows you to dump streams to disk, and supports all the stream types I need. So first I go and try to get link to all the streams so I can use them on the command-line. My point is to make use cron to start some bash scripts that dump the Mplayer to disk, and then shut Mplayer down (couldn't get this to work, but made a kluge for it).
So the streams:
I used the mp3 stream from WDET, which mplayer can just dump to disk as an MP3. The stream is
the command is
mplayer -dumpaudio -dumpfile (output-file.mp3) (mp3-stream)
The WRIF stream is hidden in an
(Note: MPlayer seems to handle this stream fine, but my Totem doesn't seem to like it... have to check that out...) Just dumping this file to disk doesn't seem to work. The resulting file is not an
mplayer -ao pcm -aofile (output-file.wav) (asf-stream)
I used the same command for the German news stream, which I found the
The problem with this command is the file is HUGE, and its a wave file, while i would prefer an mp3. Since I have plenty of space I just dump the stream to a
lame -h (input-wav-file) (output-mp3-file)
This kinda sucks. I would like to just dump it as mp3 =(
So I'm not too familar with cron, but I've seen some gurus around work using it so I thought I would try it out. Turns out its pretty easy. This guide was really straight forward, if you know some Unix basics. The only hitch here was in stopping the mplayer processes after they have dumped the show. My first impulse was to set up a time with cron to start mplayer and a time on cron to kill mplayer. I found the command
could easily shut down all the mplayer processes. But this doesn't work (again because of overlapping programs)! If I call that command to kill Peter Werbe, Liz Copeland gets killed too
So I have no idea how to find out what the process I just started is in a script so I fall back on my programming to do it. Since I've been using Java for the last couple years I decide to code a quick little ditty to start a process, run it for X amount of time. This was really easy. (Setting up the runtime is more difficult) The method
returns a Process, and
shuts it down. The static method :
makes my program just sit there while MPlayer does its work. I'd feel more skilled if I did it in C, but this will have to do for now
Anyway, now whenever I'm done with work, I shut Windows down and let the linux partition boot and do its work. The next day I come in and all kinds of aural goodies are waiting for me!
If anyone knows a more elegant way to do this, I would love to hear... (or any eclectic streaming radio programs =) Sheesh long first entry, but I'd like to record how I did this, in case I have to do it again...