September 22, 2014

Disk Archaeology: slayGrab.sh

During some recent data archaeology I found this here old script which I wrote back in 2006-2007.

At the time I was living in Tokyo and it was quite difficult for me to manage to tune in on Slayradio’s live-shows due to time difference, and I especially missed the BBB show.

This gave me the first real situation to write a piece of software to solve something I could not do and thus it had to run unassisted and do the right-thing™. This gave me an opportunity to flex my bash muscles, learn how to stream a live broadcast through an mplayer pipe and down into a file on my drive. Of course, it also had to stop streaming when the show was over which is what the sleep $duration part covers in the script.

Decently clean looking, though the lack of logging and error handling kinda irks my current self, but what can you do?

#!/bin/bash

##                                                             ##
#                           slayGrab                            #
# @desc   : A small script for catching live-casts from         #
#         slayradio and save to file. This idea was born since  #
#         I'm no longer able to make it to BBB in time and      #
#         wanted to hear it at a better time.                   #
#                                                               #
#         Grabbed content are NOT to be redistributed,          #
#         Without the consent of Slayradio.org and The Boz!     #
#                                                               #
# @author : Sekre                                               #
# @rev    : 0.1                                                 #
##                                                             ##


relay=4
port=8000
feedurl="http://relay$relay.slayradio.org:$port"

duration=10800     # specify in seconds [default: 3hours]
sampleRate=44100   # 44kHz sample rate

outputFile="boz_$(date +%d%m%y).mp3"
outputDir="/home/zebh/Musik/boz/"

if [ -e $outputDir/$outputFile ]; then # <--- Needs some work
	temp_outputFile=$outputFile.temp
	
	## Dump stream.

	mplayer -really-quiet -cache 128 \
	        -dumpfile $outputDir/$outputFile \
			-dumpstream $feedurl &

	## Check md5sums we don't need double versions
	# TODO
	##
	
else
	mplayer -really-quiet -cache 128 \
	        -dumpfile $outputDir/$outputFile \
			-dumpstream -playlist $feedurl &
fi

sleep $duration
kill  $!

id3v2 -a "Boz" -A "Bowness Bit' o Bollocks" \
      -t "BBB - $(date +%F)" -y $(date +%y) \
	  $outputDir/$outputFile

# Finito

© Sebastian Hörberg 2018

Powered by Hugo & Kiss.