#!/bin/bash

TEMPFILE="/Users/phil/Documents/WMFO/lastsong.txt"

CURRENT=`curl -s http://www.spinitron.com/public/rss.php?station=wmfo | grep \<title\> | head -n 2 | tail -n 1 | sed -E "s_\ \<title\>|'\</title>__g" | tr -d '\t' | sed -E "s/\&amp;/\&/g" | sed -E "s/: '/:/g"`
OLD=`cat $TEMPFILE`

echo $CURRENT

if [[ "$CURRENT" != "$OLD" ]]
then 
	ARTIST=`echo $CURRENT | cut -f1 -d:`
	SONG=`echo $CURRENT | cut -f2 -d:`

	echo new song
	# curl -s --head $URL # Using head to not get any data...may not be necessary

	rm "$TEMPFILE"
	echo "$CURRENT" >> "$TEMPFILE"
else
	echo same song
fi