smtddr's notes

[Things I find interesting]

Downloading Ministry Of Sound radio shows.

f:id:smtddr:20141007135529p:plain

I've always downloaded MinistryOfSound's HedKandi & Chilled weekly radio shows from websites like alldj.org or mixing.dj. One day they just stopped having the files. I tried listening to them via their flash player, but it had a tendancy to skip. Even without the skipping I like to listen to music on the go and their flashplayer probably wouldn't work well on a smartphone. Not that I even have a smartphone to begin with. I just wanted to download the MP3s like I always did. So, I go to their website and begin my mission.

f:id:smtddr:20141007141423p:plain

So we pick up clues, notice the URL bar: id=HEDKANDI , this isn't useful at this moment but it will be later on. I start up Wireshark and watch the network traffic when I select HEDKANDI(or any other of their radioshows).

f:id:smtddr:20141007142808p:plain

You see all the stuff highlighted in red? That's how I came up with this linux command:

rtmpdump -v --playpath mp3:HEDKANDI.mp3 -r rtmp://odw-e-05.sharp-stream.com/mosod -o HEDKANDI.mp3

Make sure this is the newest rtmpdump(I'm on v2.4). Now, because this is streaming radio this must actually listen to the stream and capture as it plays. It cannot just download an MP3, it must actually stream for 2 hrs to get the whole stream. One it's done, it's actually not a good file. It skips all over the place. To fix this I transcode the HEDKANDI.mp3 file to wav using ffmpeg.

ffmpeg -i HEDKANDI.mp3 -f wav HEDKANDI.wav

This file is much bigger(uncompressed wav file), but all the skipping will be gone. I now take this file and turn it into an ogg file:

oggenc HEDKANDI.wav

Or an MP3 file:

lame -b 256 HEDKANDI.wav

The resulting file sounds just as good as the original stream and I'm free to put the file on my portable mp3 player and enjoy my tunes anywhere I go. Remember that id=HEDKANDI? So I also like to listen to chilled, when I select the chilled music it shows id=CHILLED. Without bothering with wireshark again I assumed the playpath is probably "mp3:CHILLED.mp3", and I was right. :)

So now I just do this:

./MOSRadioshowDownloader.sh HEDKANDI.mp3

The contents of the script are:

RADIOSHOW_FILE=$1
RTMP_URL=$( wget -q -O- http://tx.sharp-stream.com/mosod/mp3:$RADIOSHOW_FILE.multi.smil|grep rtmp|sed -e 's/.*=//' -e 's/"//' -e 's/".*//' ) 
rtmpdump -v --playpath mp3:$RADIOSHOW_FILE -r $RTMP_URL -o $RADIOSHOW_FILE  
ffmpeg -i $RADIOSHOW_FILE -f wav ${RADIOSHOW_FILE%mp3}wav 
oggenc ${RADIOSHOW_FILE%mp3}wav && rm -f ${RADIOSHOW_FILE%mp3}wav && rm -f $RADIOSHOW_FILE

That's it. Happy raving folks.