Audiograb script

From Maze's wiki
Revision as of 08:42, 10 September 2012 by Admin (talk | contribs)

Jump to: navigation, search
  1. !/bin/bash

cdinfo=`cd-discid /dev/sr0` discid=`echo "${cdinfo}" | cut -d\ -f 1` noftracks=`echo "${cdinfo}" | cut -d\ -f 2` cdinfocddb=`echo ${cdinfo} | sed 's/ /+/g'` cddbcdsummaries=`wget "http://freedb.freedb.org/~cddb/cddb.cgi?cmd=cddb+query+${cdinfocddb}&hello=maze+ma-ze.nl+grab.sh+1.0&proto=6" -O - -q | tail -n +2 | head -n -1` nofcddbcdsummaries=`echo "${cddbcdsummaries}" | wc -l` chosensummary=1 [ "${nofcddbcdsummaries}" -ne "1" ] && echo "${cddbcdsummaries}" | nl && read -p "Select correct CD [1]:" chosensummarycustom [ "${chosensummarycustom}" != "" ] && chosensummary=${chosensummarycustom} cddbcdsummary=`echo "${cddbcdsummaries}" | head -n ${chosensummary} | tail -n 1 | cut -d\ -f -2 | sed 's/ /+/g'` cddbcdfullinfo=`wget "http://freedb.freedb.org/~cddb/cddb.cgi?cmd=cddb+read+${cddbcdsummary}&hello=maze+ma-ze.nl+grab.sh+1.0&proto=6" -O - -q` [ "${noftracks}" -lt "10" ] && noftrackslz=0 artistname=`echo "${cddbcdfullinfo}" | grep 'DTITLE' | tr -d "\r" | tr -d "\n" | sed 's/DTITLE=//g' | cut -d/ -f 1 | sed 's/^\ *//' | sed 's/\ *$//'` albumname=`echo "${cddbcdfullinfo}" | grep 'DTITLE' | tr -d "\r" | 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 "\r" | 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/sr0 -O wav -t ${actualtrack} - | oggenc -q 5 -Q -t "${trackname}" -G "${genre}" -a "${artistname}" -l "${albumname}" -d "${year}" -N "${leadingzero}${actualtrack}/${noftrackslz}${noftracks}" -o "$artistname/$albumname/$leadingzero$actualtrack-$trackfilename.ogg" -
 track=$((${track}+1))

done