Difference between revisions of "Audiograb script"

From Maze's wiki
Jump to: navigation, search
Line 2: Line 2:
 
* cd-discid
 
* cd-discid
 
* icedax
 
* icedax
* lame (eg. compile from source) or adjust script ate the lame part to work with your favorite encoder.
+
* vorbis-tools
  
 
<pre>
 
<pre>

Revision as of 08:40, 10 September 2012

For this audiograb script to run you need some packages to be installed:

  • cd-discid
  • icedax
  • vorbis-tools
#!/bin/sh
cdinfo=`cd-discid /dev/cdrom1`
cddbcdsummary=`cddbcmd -m http cddb query $cdinfo`
nofcddbcdsummaries=`echo "$cddbcdsummary" | wc -l`
chosensummary=1
[ "$nofcddbcdsummaries" -ne "1" ] && echo "$cddbcdsummary" | nl && read -p "Select correct CD [1]:" chosensummarycustom
[ "$chosensummarycustom" != "" ] && chosensummary=$chosensummarycustom
cddbcdsummary=`echo "$cddbcdsummary" | head -n $chosensummary | tail -n 1 | cut -d\  -f -2`
cddbcdfullinfo=`cddbcmd -m http cddb read $cddbcdsummary`
noftracks=`echo "$cddbcdfullinfo" | grep 'TTITLE' | cut -d= -f 1 | sort -u | wc -l`
[ "$noftracks" -lt "10" ] && noftrackslz=0
artistname=`echo "$cddbcdfullinfo" | grep 'DTITLE' | tr -d "\n" | sed 's/DTITLE=//g' | cut -d/ -f 1 | sed 's/^\ *//' | sed 's/\ *$//'`
albumname=`echo "$cddbcdfullinfo" | grep 'DTITLE' | tr -d "\n" | sed 's/DTITLE=//g' | cut -d/ -f 2- | sed 's/^\ *//' | sed 's/\ *$//'`

read -p "Enter Artist [$artistname]:" artistnamecustom
[ "$artistnamecustom" != "" ] && artistname=$artistnamecustom
read -p "Enter Albumname [$albumname]:" albumnamecustom
[ "$albumnamecustom" != "" ] && albumname=$albumnamecustom
read -p "Enter Genre [$genre]:" genrecustom
[ "$genrecustom" != "" ] && genre=$genrecustom
read -p "Enter Year [$year]:" yearcustom
[ "$yearcustom" != "" ] && year=$yearcustom
mkdir -p "$artistname"/"$albumname"

track=0
while [ "$track" -lt "$noftracks" ]
do
  actualtrack=$(($track+1))
  leadingzero=""
  [ "$actualtrack" -lt "10" ] && leadingzero=0
  trackname=`echo "$cddbcdfullinfo" | grep 'TTITLE'$track'=' | tr -d "\n" | sed 's/TTITLE[0-9]*=//' | sed 's/^\ *//' | sed 's/\ *$//'`
  read -p "Enter title for track $leadingzero$actualtrack [$trackname]:" tracknamecustom
  [ "$tracknamecustom" != "" ] && trackname=$tracknamecustom
  trackfilename=`echo "$trackname" | sed 's/\//_/g'`
  icedax -q -D /dev/cdrom1 -O wav -t $actualtrack - | lame --preset standard --quiet --tt "$trackname" --tg "$genre" --ta "$artistname" --tl "$albumname" --ty "$year" --tn "$leadingzero$actualtrack/$noftrackslz$noftracks" --id3v2-only - "$artistname/$albumname/$leadingzero$actualtrack-$trackfilename.mp3"
  track=$(($track+1))
done