From 6f9ebc82577328dff7ffcb344a9f3e67151ba099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sun, 3 Jul 2011 08:56:16 +0200 Subject: add cd2ogg cd2mp3 --- cd2mp3 | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ cd2ogg | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100755 cd2mp3 create mode 100755 cd2ogg diff --git a/cd2mp3 b/cd2mp3 new file mode 100755 index 0000000..ede06b0 --- /dev/null +++ b/cd2mp3 @@ -0,0 +1,65 @@ +#!/bin/sh + +# Zurcher Jeremy + +MYOPTS="-b 64 -q 7 --ty 2003" + +cat <lame_opts +BEGIN { out=""; } +/Tracknumber/ { + match( \$0,/=.*/); + S=substr(\$0,RSTART+2,RLENGTH-1); + if( int(S)<10 ) { + S="0"S; + } + out=out" --tn "S; +} +/Performer/ { + match( \$0,/'.*/); + S=substr(\$0,RSTART+1,RLENGTH-2); + gsub(" ","_",S); + out=out" --ta "S; +} +/Albumtitle/ { + match( \$0,/'.*/); + S=substr(\$0,RSTART+1,RLENGTH-2); + gsub(" ","_",S); + out=out" --tl "S; +} +/Tracktitle/ { + match( \$0,/'.*/); + S=substr(\$0,RSTART+1,RLENGTH-2); + gsub(" ","_",S); + out=out" --tt "S; +} +END { print out; } +EOF + +cat <build_name +BEGIN { out=""; } +/Tracknumber/ { + match( \$0,/=.*/); + S=substr(\$0,RSTART+2,RLENGTH-1); + if( int(S)<10 ) { + S="0"S; + } + out=S"_"out; +} +/Tracktitle/ { + match( \$0,/'.*/); + S=substr(\$0,RSTART+1,RLENGTH-2); + gsub(" ","_",S); + out=out""S; +} +END { print out; } +EOF +echo "cmd : sudo cdda2wav -v all -P 0 -n 75 -B -O wav dev=/dev/cdrom -L 1 || exit 1" +sudo cdda2wav -v all -P 0 -n 75 -B -O wav dev=/dev/cdrom -L 1 || exit 1 +for I in audio*.wav; do + INFO=`basename $I .wav`.inf + NAME=`cat $INFO | awk -f ./build_name` + LAMEOPTS=`cat $INFO | awk -f ./lame_opts` + echo "cdm : lame $MYOPTS $LAMEOPTS $I $NAME.mp3" + lame $MYOPTS $LAMEOPTS $I $NAME.mp3 +done +rm -f lame_opts build_name audio* diff --git a/cd2ogg b/cd2ogg new file mode 100755 index 0000000..bca09f3 --- /dev/null +++ b/cd2ogg @@ -0,0 +1,83 @@ +#!/bin/sh + +# Zurcher Jeremy + + +OGGOPTS=${OGGOPTS:="-b 192 -q 7"} + +sudo cdda2wav -v trackid,titles -P 0 -n 75 -B -O wav dev=/dev/scd0 -L 1 || exit 1 + +DISCID=$(cat audio.cddb | gawk '/DISCID/ { split($0,a,"="); print a[2]; }') +ARTIST=$(cat audio.cddb | gawk '/DTITLE/ { split($0,a,"="); i=index(a[2],"/"); print substr(a[2],0,i-2); }') +ALBUM=$(cat audio.cddb | gawk '/DTITLE/ { split($0,a,"="); i=index(a[2],"/"); print substr(a[2],i+2); }') +YEAR=$(cat audio.cddb | gawk '/DYEAR/ { split($1,a,"="); print a[2]; }') +GENRE=$(cat audio.cddb | gawk '/DGENRE/ { split($1,a,"="); print a[2]; }') + +echo "discid : >$DISCID<" +echo "Artist : >$ARTIST<" +echo "Album : >$ALBUM<" +echo "Year : >$YEAR<" +echo "Genre : >$GENRE<" + +IDX=0 +for I in audio*.wav; do + TRACK=$(cat audio.cddb | gawk "/TTITLE$IDX/ { split(\$0,a,\"=\"); print a[2]; exit; }" ) + IDX=$((IDX+1)) + TNUM=$(echo $IDX | gawk '{ n=$0; if(int($0)<10) { n="0"n; } print n; }' ) + OUTPUT=$(echo "${TNUM}_${TRACK}" | gawk "{ s=tolower(\$0); gsub(\" \",\"_\",s); gsub(\"'\",\"_\",s); print s; }" ) + #echo "$TNUM $TRACK => $OUTPUT.ogg" + oggenc $I -o "$OUTPUT.ogg" $OGGOPTS -a "$ARTIST" -l "$ALBUM" -t "$TRACK" -N "$TNUM" -G "$GENRE" -d "$YEAR" +done +rm -f ogg_opts audio* + +#ARTIST=$(cat audio.cdindex | gawk "// { match(\$0,/.*<\/Artist>/); print substr(\$0,RSTART+8,RLENGTH-18); }" ) +#ALBUM=$(cat audio.cdindex | gawk "// { match(\$0,/<Title>.*<\/Title>/); print substr(\$0,RSTART+7,RLENGTH-16); }" ) +#cat << EOF >ogg_opts +#BEGIN { out=""; } +#/Tracknumber/ { +# match( \$0,/=.*/); +# S=substr(\$0,RSTART+2,RLENGTH-1); +# if( int(S)<10 ) { +# S="0"S; +# } +# out=out" -N "S;ยง +#} +#/Performer/ { +# match( \$0,/'.*/); +# S=substr(\$0,RSTART+1,RLENGTH-2); +# gsub(" ","_",S); +# gsub("'","_",S); +# if( S~/\\\`$/ ) S = ENVIRON["BAND"]; +# if( S~/\\\`$/ ) S = "Unknown"; +# out=out" -a "S; +#} +#/Albumtitle/ { +# match( \$0,/'.*/); +# S=substr(\$0,RSTART+1,RLENGTH-2); +# gsub(" ","_",S); +# gsub("'","_",S); +# if( S~/\\\`$/ ) S = ENVIRON["ALBUM"]; +# if( S~/\\\`$/ ) S = "Unknown"; +# out=out" -l "S; +#} +#/Tracktitle/ { +# match( \$0,/'.*/); +# S=substr(\$0,RSTART+1,RLENGTH-2); +# gsub(" ","_",S); +# gsub("'","_",S); +# if( S~/\\\`$/ ) S = ENVIRON["TRACK"]; +# if( S~/\\\`$/ ) S = "Unknown"; +# out=out" -t "S; +#} +#END { print out; } +#EOF +# INFO=$(basename $I .wav).inf +# TRACK=$(cat $INFO | gawk '/Tracknumber/ { n=$2; if( int(n)<10 ) { n="0"n; } print n; }' ) +# TITLE=$(cat $INFO | gawk "/Tracktitle/ { match( \$0,/'.*/); t=substr(\$0,RSTART+1,RLENGTH-2); +# gsub(\" \",\"_\",t); gsub(\"'\",\"_\",t); +# if( t~/\\\`$/ ) S = ENVIRON["TRACK"]; +# if( t~/\\\`$/ ) S = "Unknown"; +# print t; } " ) +# FILE=$(cat $INFO | gawk "/Tracktitle/ { match(\$0,/'.*'/); t=substr(\$0,RSTART+1,RLENGTH-2); gsub(\" \",\"_\",t); gsub(\"'\",\"_\",t); print t; }" ) +# oggenc $I -o "$TRACK_$FILE.ogg" $OGGOPTS -a "$ARTIST" -l "$ALBUM" -t "$TITLE" -N "$TRACK" -G "$GENRE" -d "$YEAR" +#done -- cgit v1.1-2-g2b99