Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×
Music

Journal Journal: Getting my favorite streamed radio shows on disk.

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 :
http://141.217.119.35:8000/listen.pls
the command is :
mplayer -dumpaudio -dumpfile (output-file.mp3) (mp3-stream)

The WRIF stream is hidden in an .apx file, which is an xml file which contains the link to the .apf stream (AFAIK), which I grabbed. The stream is hosted on another site, but you can access it here :
http://stream1.dc1.sonixtream.com/WRIF
(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 .asf file. I found later that MPlayer can encode the audio before putting it on disk, but I could only find a way to do it as a wave file :
mplayer -ao pcm -aofile (output-file.wav) (asf-stream)

I used the same command for the German news stream, which I found the .asf stream at :
mms://193.159.246.27/live/dwelle/dwelle_audio_low

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 .wav file and then convert it to mp3 using lame. The command, for high quality, is :
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 :
pkill mplayer
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 :o

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 :
Runtime.getRuntime().exec("mplayer....");
returns a Process, and
Process.destroy();
shuts it down. The static method :
Thread.sleep(long timeInMillis)
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...

Slashdot Top Deals

Anyone can make an omelet with eggs. The trick is to make one with none.

Working...