When I do my part of the code I like doing it on Friday night with some nice uptempo music. That’s if i’m not in a bar drinking beer or playing my sax.

So I wrote a little script to record the Studio Brussel stream in the evening when they broadcast some very nice mixes music. Progressive drumnbass, dub step, minimalistic, techno acid combinations, very very nice for long marathon coding sessions, at times coffee doesnt’ work anymore 🙂

Basically the command is:

mplayer http://mp3.streampower.be/stubru-high -cache 4096 --dumpstream
mv http://mp3.streampower.be/stubru-high stubru_WEEKNUMBER_TAKENUMBER.mp3

Some code to automate it in python (for easy crontab deployment)

# Script to record Studio Brussel at Friday
# Default record time = 60 minutes
# Best run from crontab
DEBUG=True

import os,sys
from datetime import *
import time

MINUTES=59
#Default to current week
WEEK_NUMBER=datetime.date(datetime.now()).isocalendar()[1]
TAKE_NUMBER=1 #No argumnet given? it wil use take1 and overwrite it. 

try:
    TAKE_NUMBER=sys.argv[1]
except:
    print 'No take number provided: using default: %s' % TAKE_NUMBER
cmd='mplayer http://mp3.streampower.be/stubru-high -cache 4096 -dumpstream -dumpfile %s/studio_brussel_%s_day_%s_take_%s.mp3 &' % (os.path.expanduser('~'), WEEK_NUMBER,datetime.today().isoweekday(),TAKE_NUMBER)
if DEBUG: print 'Executing cmd: %s' % cmd
os.system(cmd)
time.sleep(60*MINUTES)
os.system('killall mplayer')

Trigger it from cron for ultimate ease of mind.

#Crontab file for Friday night from 21:01 - Saturday morning 02:01 in 5 takes
1 21 * * 5 /usr/local/bin/record_studio_brussel.sh 1 > studio_brussel.log
1 22 * * 5 /usr/local/bin/record_studio_brussel.sh 2 > studio_brussel.log
1 23 * * 5 /usr/local/bin/record_studio_brussel.sh 3 > studio_brussel.log
1 0 * * 6 /usr/local/bin/record_studio_brussel.sh 4 > studio_brussel.log
1 1 * * 6 /usr/local/bin/record_studio_brussel.sh 5 > studio_brussel.log

Now all you have to do is copy or symlink a shell script that launches it to your /usr/local/bin and make it executable.

#!/bin/bash
/usr/bin/python /usr/local/bin/record_studio_brussel.py $1

liveismusic

screenie_ brussel
Have a nice one.