Archive for October 2005
Rather than me defending my linux usage…read some reasons from other people for using Linux rather than Windows. Brilliant.
SubSpace FM, a long running project of mine and a few other people is finally coming to fruition. It’s basically an internet radio station, except we play good tunes! Tune in now to our shoutcast stream, highly recommended as at the moment it’s my personal CD collection which I must say is most wicked.
On another note, I stupidly forgot to turn the server database back on! Whoops.
I’ve written a script to convert .flac files to .mp3 and retain a useful directory structure. This is mad-handy for my w800i phone.
source_path="${1%/}/";
dest_base="${2%/}/";
bit_rate=$3
if [ ! -r "$source_path" ]; then
echo "Source path not found."
exit 2
fi
if [ ! -r "$dest_base" ]; then
echo "Destination base path not found"
exit 2
fi
if [ ! $bit_rate ]; then
echo "No bit rate specified, defaulting to 128kbps"
bit_rate=128
fi
artist_album=`echo "$source_path" | sed 's:^.*/\([^/]*/[^/]*/[^/]*\)$:\1:'`
dest_path="$dest_base$artist_album"
# Check out source dir
if [ ! "$(ls -A "$source_path"*.flac )" ]; then
echo "No .flac files found in source path."
exit 2;
fi
cd "$source_path"
ls | grep .flac | while read file ;do
# Each flac
title=`metaflac --list --block-type=VORBIS_COMMENT "$file" | grep "TITLE=" | sed "s/comment\[0\]: TITLE=//g" | sed "s/^ *//g"`
artist=`metaflac --list --block-type=VORBIS_COMMENT "$file" | grep "ARTIST=" | sed "s/comment\[1\]: ARTIST=//g" | sed "s/^ *//g"`
tracknumber=`metaflac --list --block-type=VORBIS_COMMENT "$file" | grep "TRACKNUMBER=" | sed "s/comment\[2\]: TRACKNUMBER=//g" | sed "s/^ *//g"`
tracktotal=`metaflac --list --block-type=VORBIS_COMMENT "$file" | grep "TRACKTOTAL=" | sed "s/comment\[3\]: TRACKTOTAL=//g" | sed "s/^ *//g"` album=`metaflac --list --block-type=VORBIS_COMMENT "$file" | grep "ALBUM=" | sed "s/comment\[4\]: ALBUM=//g" | sed "s/^ *//g"`
echo "Converting: $artist - $album [$title]"
flac --silent -d "$file"
wavfile=${file%.flac}.wav
newfile=${file%.flac}.mp3
lame --quiet --tt "$title" --ta "$artist" --tl "$album" --tn $tracknumber --preset "$bit_rate"kbps "$wavfile" "$newfile"
done
rm *.wav
mkdir -p "$dest_path"
mv *.mp3 "$dest_path"
exit 0;
By no means perfect, but it does work. You will need flac and lame installed for this to work. Comments/suggestions welcome!
Right, I’m moving john-hunt.com over to a new much much much faster server than this one. This will also save me £20 a month. You may experience problems trying to access the site over the next couple of days, but don’t worry, it will return!
Update:
All done, there shouldn’t be any loss of service, you should just notice it speed up a bit when your ISP’s master dns records get updated!
