## Stream Recording With Ruby

One my favorite Greek journalists recently changed station and timetable. Since my schedule is messed up, I couldn’t listen to the show live. So I wrote a ruby script, as an exercise, to fetch the stream. The script is meant to work with cron.

Here is the code:

Dumping the stream into an .mp3 file is pretty straight forward. My main problem was how to make the script stay up and running 2 hours and 10 minutes. I opted for sleep method here, but a better way would be to detach the process in the background, save the pid and kill the process later using the predefined pid directory. I wonder if there are drawbacks having a process sleeping for 2 hours, but we’ll see.

When time permits I will roll out a gem to make the whole procedure more secure and easier.