-
Notifications
You must be signed in to change notification settings - Fork 0
/
cd2mp3
executable file
·57 lines (45 loc) · 1.37 KB
/
cd2mp3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
wav_ext='wav'
inf_ext='inf'
cd_info_file='audio.cdindex'
title_label='\<Title\>'
artist_label='\<Artist\>'
audiotitle='Tracktitle'
tracknumberlabel='Tracknumber'
function extractcdinfo {
local result=`cat $cd_info_file | grep $1 | head -n 1`
result=${result#*$1}
result=${result%*$2}
echo "$result"
}
function normalize {
result=`echo "$1" | sed -e s/\ /./g -e s/[\(\)\!\?]//g`
echo "$result"
}
if [ ! -f ]; then
echo "No se encontro informacion del CD" && exit 1
fi
srcdir=`pwd`
tmpdir="/tmp/"`date +%N`
mkdir $tmpdir
cd $tmpdir
cdda2wav -verbose-level toc -L 0 -B -D /dev/cdrom
artist=$(extractcdinfo "\<Artist\>" "\</Artist\>")
artistdir=$(normalize "$artist")
album=$(extractcdinfo "\<Title\>" "\</Title\>")
albumdir=$(normalize "$album")
mkdir -p $srcdir/$artistdir/$albumdir
for file in `ls *.$wav_ext`; do
filename="${file%.*}"
trackname=`grep $audiotitle $filename.$inf_ext`
tracknumber=`grep $tracknumberlabel $filename.$inf_ext`
if [ -n "$trackname" ]; then
trackname=${trackname#Tracktitle*\'*}
trackname=${trackname%*\'*}
tracknumber=${tracknumber#Tracknumber=}
outfilename=$(normalize "$trackname")
echo "Ripping $trackname..."
lame --quiet -b 192 --tt "'$trackname'" --ta "'$artist'" --tl "'$album'" --tn $tracknumber $filename.$wav_ext $srcdir/$artistdir/$albumdir/`printf %02d $tracknumber`-$outfilename.mp3
fi
done
rm -rf $tmpdir