silliam n00b
Joined: 12 Aug 2006 Posts: 1
|
Posted: Sat Aug 12, 2006 5:30 pm Post subject: cd ripping cluster |
|
|
I have a bunch of old boxes that i've installed gentoo on, and i am wondering if anyone knows of a project that would help me with starting ripping on one machine and automating ripping and conversion of cd's on all of the other boxes. I have written a bash script that i can use to automate the ripping, tagging, and conversion of my cd's, but i want to rewrite it in python so that i can hopefully run the entire operation from one terminal in parallel. If anybody has any suggestions, or would like to help me, that would be great!
here is my script, except it has some problems with the rudimentary db that i made up, i am very new to scripting, and programming in general, so if anyone has any suggestions for improvements, that would be awesome!
Code: |
#! /bin/bash
# Assing which cdrom to work on based upon the first parameter passed to the program, and copystatus is the second
cdrom=$1
copystatus=$2
date=`date +%s%N`
Cleanup ()
{
rm -r "$workdir"
rm "/tmp/"$date""
echo "cleaning up"
exit
}
# If the user types in copy, then it will register that the cd is a copy
if [ "$copystatus" = "copy" ]
then
mkdir "/tmp/music/copy"$cdrom""
workdir="/tmp/music/copy"$cdrom""
else
mkdir "/tmp/music"$cdrom""
workdir="/tmp/music"$cdrom""
fi
# This brings the cdrom in and changes to the workdirectory
eject -t "$cdrom"
cd "$workdir"
# This fetches the toc, and assigns the albumname variable
/clusterrip/Freedbtool/freedbtool.py get -n 1 -d "/clusterrip/Freedbtool/discid "$cdrom""
alubmtempname1=`cat $workdir/toc | grep DTITLE`
if [ -z "$albumname1" ]
then
albumname="unknown-""$date"
else
albumname=`echo "$albumtempname1" | tr -d "?[]/\=+<>:;,"`
fi
echo "checking the db"
# This checks the albumdb to make sure i don't rerip a cd, or replace a copy with an original
if [ -e "/music/albumdb/copy/"$albumname"" -a -z "$copystatus" ]
then
rm -r "/music/copy/"$albumname""
rm "/music/albumdb/copy/"$albumname""
touch "/music/albumdb/"$albumname""
else
if [ -f "/music/albumdb/copy/"$albumname"" -a "$copystatus" = "copy" ]
then
Cleanup
else
if [ -f "/music/albumdb/"$albumname"" ]
then
Cleanup
else
if [ "$copystatus" = "copy" ]
then
touch "/music/albumdb/copy/"$albumname""
else
touch "/music/albumdb/"$albumname""
fi
fi
fi
fi
# Read each track with cdparanoia
cdparanoia --batch --output-wav --force-cdrom-device "$cdrom"
# Find all .wav files count them, and then put them in a list
todolist=/tmp/"$date"
touch "$todolist"
find "$workdir" -name "*.wav" > "$todolist"
numofitems=`cat "$todolist" | wc -l`
# Convert all .wav files to flac then remove the old .wav files
if [ -n "$numofitems" ]
then
curritem="1"
while [ "$curritem" -le "$numofitems" ]
do
line=`sed -n "$curritem{p;q;}" "$todolist"`
echo "$line"
flac --best "${line%}"
rm "${line%}"
echo "Processed : $line"
let "curritem += 1"
done
else
echo "Something very bad just happened, there are no .wav files!"
fi
# tag all of the flac files with apev2 tags
/clusterrip/Apetag/tagdir.py -t ""$workdir"/toc" -m tag
if [ "$copystatus" = "copy" ]
then
mkdir "/music/copy/$albumname"
mv ""$workdir"/*" "/music/copy/$albumname"
else
mkdir "/music/$albumname/"
mv ""$workdir"/*" "/music/$albumname"
fi
|
|
|