|
|
@ -307,7 +307,192 @@ then |
|
|
|
|
|
|
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
function getDiscInfo |
|
|
|
|
|
{ |
|
|
|
|
|
local device |
|
|
|
|
|
|
|
|
|
|
|
test $# -ge 1 && device="$1" |
|
|
|
|
|
|
|
|
|
|
|
unset diskData cddbId dTracks dLength dIndex dText dExtra |
|
|
|
|
|
|
|
|
|
|
|
diskData="`cdda2wav -D ${device} -N -J -v toc,sectors 2>&1`" |
|
|
|
|
|
|
|
|
|
|
|
cddbId="`echo "$diskData" |\ |
|
|
|
|
|
sed '/^CDDB/!d;s/^.*0x\(.*\)$/\1/'`" |
|
|
|
|
|
dTracks="`echo "$diskData" |\ |
|
|
|
|
|
sed '/tracks/!d;s/^.*tracks:\([0-9]*\).*$/\1/'`" |
|
|
|
|
|
dLength="`echo "$diskData" |\ |
|
|
|
|
|
sed '/tracks/!d;s/^.*time \([0-9:\.]*\).*$/\1/'`" |
|
|
|
|
|
dIndex="`echo "$diskData" |\ |
|
|
|
|
|
sed '/CDINDEX/!d;s/^.*: *\([a-zA-Z0-9_\.]*-\).*$/\1/'`" |
|
|
|
|
|
dText="`echo "$diskData" | sed ' |
|
|
|
|
|
/CD-Text/!d;s/^[^:]*: *\(.*[^ ]\).*$/\1/'`" |
|
|
|
|
|
dExtra="`echo "$diskData" | sed ' |
|
|
|
|
|
/CD-Extra/!d;s/^[^:]*: *\(.*[^ ]\).*$/\1/'`" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getCDDBInfo |
|
|
|
|
|
{ |
|
|
|
|
|
local uri i hello |
|
|
|
|
|
|
|
|
|
|
|
uri="freedb.freedb.org/~cddb/cddb.cgi" |
|
|
|
|
|
|
|
|
|
|
|
test $# -ge 1 && cddbId="$1" || return 1 |
|
|
|
|
|
test $# -ge 2 && uri="$2" |
|
|
|
|
|
|
|
|
|
|
|
hello="hello=${USER}+${HOSTNAME}+test+0.0.1" |
|
|
|
|
|
|
|
|
|
|
|
# first get the genre list from server |
|
|
|
|
|
eval "`curl -s "http://${uri}?cmd=cddb+lscat&${hello}&proto=6" |\ |
|
|
|
|
|
sed '1d;$d' | tr -d '\r' | tr '\n' ',' |\ |
|
|
|
|
|
sed 's/,$//;s/,/" "/g;s/^\(.*\)$/local -a genre=("\1")/'`" |
|
|
|
|
|
|
|
|
|
|
|
unset cddbInfo |
|
|
|
|
|
|
|
|
|
|
|
# search for info in all genres |
|
|
|
|
|
for i in "${genre[@]}" |
|
|
|
|
|
do |
|
|
|
|
|
local cmd="cmd=cddb+read+${i}+${cddbId}" |
|
|
|
|
|
local cddb="`curl -s "http://${uri}?${cmd}&${hello}&proto=6"`" |
|
|
|
|
|
|
|
|
|
|
|
local ret="`echo "$cddb" | head -c 3`" |
|
|
|
|
|
|
|
|
|
|
|
if [ "$ret" != "210" ] |
|
|
|
|
|
then |
|
|
|
|
|
if [ ${verbose:-0} -ge 3 ] |
|
|
|
|
|
then |
|
|
|
|
|
debug="`echo "$cddb" | head -n 1`" |
|
|
|
|
|
echo $"[ERROR] cddb: ${debug}" |
|
|
|
|
|
fi |
|
|
|
|
|
else |
|
|
|
|
|
cddb="`echo "$cddb" | tr -d '\r' | sed '1d;/^#/d;/^\.$/{d;q}'`" |
|
|
|
|
|
cddbInfo[${#cddbInfo[@]}]="$cddb" |
|
|
|
|
|
fi |
|
|
|
|
|
done |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function getCDInfo |
|
|
function getCDInfo |
|
|
|
|
|
{ |
|
|
|
|
|
local uri device sampler cnt cddb |
|
|
|
|
|
local delimiter |
|
|
|
|
|
|
|
|
|
|
|
sampler=0 |
|
|
|
|
|
cddbEntry="" |
|
|
|
|
|
device="/dev/cdrom" |
|
|
|
|
|
uri="freedb.freedb.org/~cddb/cddb.cgi" |
|
|
|
|
|
|
|
|
|
|
|
test $# -ge 1 && sampler="$1" |
|
|
|
|
|
test $# -ge 2 && cddbEntry="$2" |
|
|
|
|
|
test $# -ge 3 && device="$3" |
|
|
|
|
|
test $# -ge 4 && uri="$4" |
|
|
|
|
|
|
|
|
|
|
|
getDiscInfo "$device" |
|
|
|
|
|
getCDDBInfo "$cddbId" |
|
|
|
|
|
|
|
|
|
|
|
cnt=${#cddbInfo[@]} |
|
|
|
|
|
if [ ${cnt} -gt 1 ] |
|
|
|
|
|
then |
|
|
|
|
|
if [ "$cddbEntry" -lt $cnt ] 2>/dev/null |
|
|
|
|
|
then |
|
|
|
|
|
cddb="${cddbInfo[$cddbEntry]}" |
|
|
|
|
|
echo "done" |
|
|
|
|
|
else |
|
|
|
|
|
echo |
|
|
|
|
|
echo "found more than 1 CDDB Entry. Please select:" |
|
|
|
|
|
|
|
|
|
|
|
local i=0; |
|
|
|
|
|
while [ $i -lt $cnt ] |
|
|
|
|
|
do |
|
|
|
|
|
local title="`echo "${cddbInfo[$i]}" | sed '/^DTITLE/!d;s/^.*=//'`" |
|
|
|
|
|
echo " [$i] - $title" |
|
|
|
|
|
i=$((i+1)) |
|
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
|
|
echo " [q] - quit script" |
|
|
|
|
|
echo |
|
|
|
|
|
|
|
|
|
|
|
cddb="" |
|
|
|
|
|
while [ -z "$cddb" ] |
|
|
|
|
|
do |
|
|
|
|
|
echo -n "==> " |
|
|
|
|
|
read i |
|
|
|
|
|
|
|
|
|
|
|
test "x$i" == "xq" && exit 1 |
|
|
|
|
|
i="`echo "$i" | sed '/[^0-9]/d'`" |
|
|
|
|
|
test -z "$i" && continue |
|
|
|
|
|
|
|
|
|
|
|
cddb="${cddbInfo[$i]}" |
|
|
|
|
|
test -z "$cddb" && echo "wrong input ($i)" |
|
|
|
|
|
done |
|
|
|
|
|
fi |
|
|
|
|
|
else |
|
|
|
|
|
cddb="${cddbInfo[0]}" |
|
|
|
|
|
echo "done" |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
eval "`echo "$cddb" | tr -d '\r' | sed ' |
|
|
|
|
|
/DTITLE/s/^.*=\(\(.*\) \/ \)*\(.*\)$/dArtist="\2";dTitle="\3"/p |
|
|
|
|
|
/DYEAR/s/^.*=\(.*\)$/dYear="\1"/p |
|
|
|
|
|
/DGENRE/s/^.*=\(.*\)$/dGenre="\1"/p |
|
|
|
|
|
/TTITLE/s/^TTITLE\([0-9]*\)=\(.*\)$/tArtist[\1]="";tTitle[\1]="\2"/p |
|
|
|
|
|
d'`" |
|
|
|
|
|
|
|
|
|
|
|
if [ "$sampler" == "yes" ] |
|
|
|
|
|
then |
|
|
|
|
|
echo |
|
|
|
|
|
echo "some CDs contain content from various artist. If this is such a CD" |
|
|
|
|
|
echo "one might want to declare a pattern that separates the artist from" |
|
|
|
|
|
echo "the title information. Here are the titles as reported by CDDB:" |
|
|
|
|
|
echo |
|
|
|
|
|
|
|
|
|
|
|
for i in "${tTitle[@]}" |
|
|
|
|
|
do |
|
|
|
|
|
echo " - $i" |
|
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
|
|
echo |
|
|
|
|
|
echo "if you want to split those entries in artist and title please give" |
|
|
|
|
|
echo "now the string pattern to split at." |
|
|
|
|
|
echo "Otherwise simply press ENTER here" |
|
|
|
|
|
echo -n "==> " |
|
|
|
|
|
|
|
|
|
|
|
__OLDIFS__="$IFS" |
|
|
|
|
|
IFS="" |
|
|
|
|
|
read delimiter |
|
|
|
|
|
IFS="$__OLDIFS__" |
|
|
|
|
|
|
|
|
|
|
|
if [ "x$delimiter" != "x" ] |
|
|
|
|
|
then |
|
|
|
|
|
eval "`echo "$cddb" | tr -d '\r' | sed ' |
|
|
|
|
|
/TTITLE/s/^TTITLE\([0-9]*\)=\(\(.*\)'"$delimiter"'\)*\(.*\)$/tArtist[\1]="\3";tTitle[\1]="\4"/p |
|
|
|
|
|
d'`" |
|
|
|
|
|
fi |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# Nu pack ich in alle tArtist die leer sind den dArtist. |
|
|
|
|
|
i=0 |
|
|
|
|
|
while [ $i -lt ${#tArtist[@]} ] |
|
|
|
|
|
do |
|
|
|
|
|
tNum=$((i+1)) |
|
|
|
|
|
tLength[$i]=`echo "$diskData" | sed ' |
|
|
|
|
|
/[^0-9]'$tNum'\.(.*:.*)/ !d |
|
|
|
|
|
s/.*[^0-9]'$tNum'\.( *\([^)]*\).*$/\1/'` |
|
|
|
|
|
tStartSec[$i]=`echo "$diskData" | sed ' |
|
|
|
|
|
/[^0-9]'$tNum'\.([^:]*)/ !d |
|
|
|
|
|
s/.*[^0-9]'$tNum'\.( *\([^)]*\).*$/\1/'` |
|
|
|
|
|
|
|
|
|
|
|
test $tNum -eq ${#tArtist[@]} && tNum="lead-out" || tNum=$((tNum+1)) |
|
|
|
|
|
|
|
|
|
|
|
tEndSec[$i]=`echo "$diskData" | sed ' |
|
|
|
|
|
/[^0-9]'$tNum'\.*([^:]*)/ !d |
|
|
|
|
|
s/.*[^0-9]'$tNum'\.*( *\([^)]*\).*$/\1/'` |
|
|
|
|
|
|
|
|
|
|
|
test -z "${tArtist[$i]}" && tArtist[$i]="$dArtist" |
|
|
|
|
|
i=$((i+1)) |
|
|
|
|
|
done |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getCDInfo_old |
|
|
{ |
|
|
{ |
|
|
local uri device cmd i hello cddb ret diskData tNum |
|
|
local uri device cmd i hello cddb ret diskData tNum |
|
|
|
|
|
|
|
|
@ -364,10 +549,11 @@ function getCDInfo |
|
|
/DGENRE/s/^.*=\(.*\)$/dGenre="\1"/p |
|
|
/DGENRE/s/^.*=\(.*\)$/dGenre="\1"/p |
|
|
/TTITLE/s/^TTITLE\([0-9]*\)=\(\(.*\) \/ \)*\(.*\)$/tArtist[\1]="\3";tTitle[\1]="\4"/p |
|
|
/TTITLE/s/^TTITLE\([0-9]*\)=\(\(.*\) \/ \)*\(.*\)$/tArtist[\1]="\3";tTitle[\1]="\4"/p |
|
|
d'`" |
|
|
d'`" |
|
|
break |
|
|
|
|
|
fi |
|
|
fi |
|
|
done |
|
|
done |
|
|
|
|
|
|
|
|
|
|
|
exit 1 |
|
|
|
|
|
|
|
|
# Nu pack ich in alle tArtist die leer sind den dArtist. |
|
|
# Nu pack ich in alle tArtist die leer sind den dArtist. |
|
|
i=0 |
|
|
i=0 |
|
|
while [ $i -lt ${#tArtist[@]} ] |
|
|
while [ $i -lt ${#tArtist[@]} ] |
|
|
|