-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathape2mp3
executable file
·87 lines (75 loc) · 2.65 KB
/
ape2mp3
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
#
# ChangeLog:
# 1. use "mid3v2" to add idv3 tags(UTF-8).
#
#
# Usage :
# $ ape2mp3 album.cue album.ape
#
# Pre-install:
# 1. mac – Monkey’s Audio Codec (MAC) utility and library
# $ yum install mac
# 2. lame – LAME Ain’t an MP3 Encoder… but it’s the best of all
# $ yum install lame
# 3. shorten – Low complexity and fast waveform coder
# $ rpm -ivh shorten-3.6.0-1.2.i386.rpm
# 4. shntool – Multi-purpose WAVE data processing and reporting utility
# $ rpm -ivh shntool-3.0.6-1.i386.rpm
# 5. cuetools – Utilities to works with cue and TOC files
# $ rpm -ivh cuetools-1.3.1-2.i386.rpm
#
echo "Brian's Archive CUE/FLAC Splitter v0.1"
echo "No sanity checking in place. Be careful."
if [ $# != 2 ]
then
echo ""
echo "Usage:"
echo " $0 cue_file ape_flac_file"
echo ""
exit 1
fi
#Get the filenames
cuefile=$1
flacfile=$2
#Other variables
tracks=$(cueprint -d '%N' "$cuefile")
#Get the filenames into an array
count=1
while [ $count -le $tracks ]
do
tracknames[$count]=$(cueprint -n$count -t '%p-%T-%02n-%t' "$cuefile"|sed -e s@/@,@g)
count=`expr $count + 1`
done
#Load up the ID3 tag info into variables for later use
id3count=1
while [ $id3count -le $tracks ]
do
artist[$id3count]=$(cueprint -n$id3count -t '%p' "$cuefile")
album[$id3count]=$(cueprint -n$id3count -t '%T' "$cuefile")
tracknum[$id3count]=$(cueprint -n$id3count -t '%02n' "$cuefile")
title[$id3count]=$(cueprint -n$id3count -t '%t' "$cuefile")
echo "Artist: ${artist[$id3count]}"
echo "Album: ${album[$id3count]}"
echo "Track No: ${tracknum[$id3count]}"
echo "Song Title: ${title[$id3count]}"
id3count=$[$id3count + 1]
done
#Output general file information
cueprint -d '%P - %T\n' "$cuefile"
echo "Total number of tracks: " $tracks
#Split this bitch
cuebreakpoints "$cuefile" | shntool split -a '' -n '%02d' -o wav "$flacfile"
#Convert those waves into mp3s
convertcount=1
while [ $convertcount -le $tracks ]
do
wavenum=`printf "%02d" $convertcount`
set -x
#lame --add-id3v2 --noreplaygain -b 320 --ta "${artist[$convertcount]}" --tl "${album[$convertcount]}" --tn "${tracknum[$convertcount]}" --tt "${title[$convertcount]}" "$wavenum.wav" "${tracknames[$convertcount]}.mp3"
lame --add-id3v2 --noreplaygain -b 320 "$wavenum.wav" "${tracknames[$convertcount]}.mp3"
mid3v2 -a "${artist[$convertcount]}" -A "${album[$convertcount]}" -T "${tracknum[$convertcount]}" -t "${title[$convertcount]}" "${tracknames[$convertcount]}.mp3"
set +x
rm "$wavenum.wav"
convertcount=$[$convertcount + 1]
done