summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-07-03 08:56:16 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-07-03 08:56:16 +0200
commit6f9ebc82577328dff7ffcb344a9f3e67151ba099 (patch)
tree7753b07d8d4db4a8268532f25f4736b6e89012e8
parent61970bc0c58a7af86630475d5c5728dd8e1b80ae (diff)
downloadbin-6f9ebc82577328dff7ffcb344a9f3e67151ba099.zip
bin-6f9ebc82577328dff7ffcb344a9f3e67151ba099.tar.gz
add cd2ogg cd2mp3
-rwxr-xr-xcd2mp365
-rwxr-xr-xcd2ogg83
2 files changed, 148 insertions, 0 deletions
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 <<EOF>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 <<EOF>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 "/<Artist>/ { match(\$0,/<Artist>.*<\/Artist>/); print substr(\$0,RSTART+8,RLENGTH-18); }" )
+#ALBUM=$(cat audio.cdindex | gawk "/<Title>/ { 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