Some improvments
This commit is contained in:
		
							
								
								
									
										74
									
								
								gsrip.sh
									
									
									
									
									
								
							
							
						
						
									
										74
									
								
								gsrip.sh
									
									
									
									
									
								
							| @@ -18,6 +18,11 @@ | ||||
|  | ||||
| set -e | ||||
|  | ||||
| CDDA2WAV=icedax | ||||
| LAME=lame | ||||
| OGGENC=oggenc | ||||
| EDITORS="emacs vim gedit kate" | ||||
|  | ||||
| tmp= | ||||
|  | ||||
| function _exit() | ||||
| @@ -156,17 +161,15 @@ while getopts ":ab:d:D:ef:hkop:r:-:" arg ; do | ||||
| 	    ;; | ||||
| 	mp3) | ||||
| 	    encode_mp3=1 | ||||
| 	    which lame > /dev/null | ||||
| 	    if [ ! $? ] ; then | ||||
| 		echo "lame not found, cannot continue" | ||||
| 	    if [ "`which $LAME`" == "" ] ; then | ||||
| 		echo "$LAME not found, cannot continue" | ||||
| 		exit 1 | ||||
| 	    fi | ||||
| 	    ;; | ||||
| 	ogg) | ||||
| 	    encode_ogg=1 | ||||
| 	    which oggenc > /dev/null | ||||
| 	    if [ ! $? ] ; then | ||||
| 		echo "oggenc not found, cannot continue" | ||||
| 	    if [ "`which $OGGENC`" == "" ] ; then | ||||
| 		echo "$OGGENC not found, cannot continue" | ||||
| 		exit 1 | ||||
| 	    fi | ||||
| 	    ;; | ||||
| @@ -187,9 +190,8 @@ if [ $keep_wav = 0 -a $encode_mp3 = 0 -a $encode_ogg = 0 ] ; then | ||||
| fi | ||||
|  | ||||
| if [ $resume = 0 ] ; then | ||||
|     which cdda2wav > /dev/null | ||||
|     if [ ! $? ] ; then | ||||
| 	echo "cdda2wav not found, cannot continue" | ||||
|     if [ "`which $CDDA2WAV`" == "" ] ; then | ||||
| 	echo "$CDDA2WAV not found, cannot continue" | ||||
| 	exit 1 | ||||
|     fi | ||||
|  | ||||
| @@ -201,8 +203,8 @@ fi | ||||
|  | ||||
| if [ $retrieve_infos = 0 ] ; then | ||||
|     if [ ! -f "$audio_cddb" ] ; then | ||||
| 	echo "$audio_cddb not found" | ||||
| 	exit | ||||
|     	echo "$audio_cddb not found" | ||||
|     	exit | ||||
|     fi | ||||
|     cat "$audio_cddb" | ||||
|     echo  | ||||
| @@ -210,29 +212,41 @@ if [ $retrieve_infos = 0 ] ; then | ||||
|     echo -n "> " | ||||
|     read response | ||||
|     if [ "$response" = "c" -o "$response" = "copy" ] ; then | ||||
| 	echo /bin/cp audio.cddb /tmp | ||||
| 	/bin/cp audio.cddb /tmp | ||||
| 	exit | ||||
|     	echo /bin/cp audio.cddb /tmp | ||||
|     	/bin/cp "$audio_cddb" /tmp | ||||
|     	exit | ||||
|     fi | ||||
|     [ ! -z "$response" -a $response != "y" -a $response = "yes" ] && exit | ||||
| else | ||||
|     if [ $auto = 1 ] ; then | ||||
| 	    cdda2wav -D "$dev" -L 1 -J -v title	 | ||||
| 	    $CDDA2WAV -D "$dev" -L 1 -J -v title	 | ||||
|     else	 | ||||
| # Info query | ||||
| 	while [ 1 ] ; do | ||||
| 	    cdda2wav -D "$dev" -L 0 -J -v title | ||||
| 	    if [ "$response" = "e" -o "$response" = "edit" ] ; then | ||||
| 	    	cat "$audio_cddb" | ||||
| 	    else | ||||
| 	    	$CDDA2WAV -D "$dev" -L 0 -J -v title | ||||
| 	    fi | ||||
| 	    echo  | ||||
| 	    echo "Is this correct ? (y[es], n[o], e[xit], c[opy])" | ||||
| 	    echo "Is this correct ? (y[es], n[o], q[uit], c[opy], e[dit])" | ||||
| 	    echo -n "> " | ||||
| 	    read response | ||||
| 	    if [ "$response" = "c" -o "$response" = "copy" ] ; then | ||||
| 		echo /bin/cp audio.cddb /tmp | ||||
| 		/bin/cp audio.cddb /tmp | ||||
| 		exit | ||||
| 	    	echo /bin/cp audio.cddb /tmp | ||||
| 	    	/bin/cp "$audio_cddb" /tmp | ||||
| 	    	exit | ||||
| 	    fi | ||||
| 	    if [ "$response" = "e" -o "$response" = "edit" ] ; then | ||||
| 	    	for editor in $EDITORS ; do | ||||
| 	    	    if [ "`which $editor`" != "" ] ; then | ||||
| 	    		$editor "$audio_cddb" | ||||
| 	    		break | ||||
| 	    	    fi | ||||
| 	    	done | ||||
| 	    fi | ||||
| 	    [ -z "$response" -o "$response" = "y" -o "$response" = "yes" ] && break | ||||
| 	    [ "$response" = "e" -o "$response" = "exit" ] && exit | ||||
| 	    [ "$response" = "q" -o "$response" = "quit" ] && exit | ||||
| 	done | ||||
|     fi | ||||
| fi | ||||
| @@ -257,10 +271,10 @@ else | ||||
| fi | ||||
|  | ||||
| # Suppress spaces | ||||
| band=$(echo $band) | ||||
| album=$(echo $album) | ||||
| genre=$(echo $genre) | ||||
| year=$(echo $year) | ||||
| band=$(echo $band | sed "s;/;-;g") | ||||
| album=$(echo $album | sed "s;/;-;g") | ||||
| genre=$(echo $genre | sed "s;/;-;g") | ||||
| year=$(echo $year | sed "s;/;-;g") | ||||
|  | ||||
| if [ $resume = 0 ] ; then | ||||
| # Extract wav | ||||
| @@ -279,7 +293,7 @@ if [ $resume = 0 ] ; then | ||||
| 	tracknum=$((tracknum + 1)) | ||||
|     done; | ||||
|  | ||||
|     cdda2wav -B -D $dev $tracks | ||||
|     $CDDA2WAV -B -D $dev $tracks | ||||
| fi | ||||
|  | ||||
| # Convert into mp3 | ||||
| @@ -310,6 +324,8 @@ for track_wav in *.wav ; do | ||||
|  | ||||
|     [ -z "$title" ] && title="Audio Track $prefix" | ||||
|      | ||||
|     title=$(echo $title | sed "s;/;-;g") | ||||
|  | ||||
|     filename=$pattern | ||||
|  | ||||
|     filename=$(echo $filename | sed "s/%g/$genre/g") | ||||
| @@ -323,7 +339,7 @@ for track_wav in *.wav ; do | ||||
|  | ||||
|     if [ $encode_mp3 = 1 ] ; then | ||||
| 	if [ ! -f "$new_file.mp3" -o $overwrite = 1 ] ; then | ||||
| 	    lame -b $bitrate -h --tt "$title" --ta "$band" --tl "$album" --ty "$year" --tn $i --tg "$genre" --add-id3v2 $track_wav "$new_file.mp3" | ||||
| 	    $LAME -b $bitrate -h --tt "$title" --ta "$band" --tl "$album" --ty "$year" --tn $i --tg "$genre" --add-id3v2 $track_wav "$new_file.mp3" | ||||
| 	else | ||||
| 	    echo "$new_file.mp3 already exists, skipping" | ||||
| 	fi | ||||
| @@ -331,7 +347,7 @@ for track_wav in *.wav ; do | ||||
|  | ||||
|     if [ $encode_ogg = 1 ] ; then | ||||
| 	if [ ! -f "$new_file.ogg" -o $overwrite = 1 ] ; then | ||||
| 	    oggenc -b $bitrate -q 10 -t "$title" -a "$band" --album "$album" -d "$year" -N $i -G "$genre" $track_wav -o "$new_file.mp3" | ||||
| 	    $OGGENC -b $bitrate -q 10 -t "$title" -a "$band" --album "$album" -d "$year" -N $i -G "$genre" $track_wav -o "$new_file.mp3" | ||||
| 	else | ||||
| 	    echo "$new_file.ogg already exists, skipping" | ||||
| 	fi | ||||
| @@ -349,5 +365,5 @@ for track_wav in *.wav ; do | ||||
|     fi | ||||
| done | ||||
|  | ||||
| echo "CD extracted into $dest" | ||||
| echo "CD extracted into $dest/$dir" | ||||
| exit | ||||
|   | ||||
		Reference in New Issue
	
	Block a user