Last active
October 27, 2022 21:19
-
-
Save 0xquad/62ea3bfa60fe5c84b864cb8a62222c8c to your computer and use it in GitHub Desktop.
CD rip script that uses cdda2wav and lame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Rip an audio CD to MP3 complete with ID3 tags. Requires cdda2wav and lame. | |
# | |
# Copyright (c) 2016-2022, Alexandre Hamelin <alexandre.hamelin gmail.com> | |
# Check requirements | |
for bin in cdda2wav lame; do | |
type -Pp $bin >/dev/null || { | |
echo "binary $bin is required, aborting" | |
exit 1 | |
} | |
done | |
#dev=$(cdda2wav -scanbus 2>/dev/null | awk '/CD-ROM/ {print $1}') # eg: 8,0,0 | |
[[ -f audio_01.inf ]] || cdda2wav -cddbp-server=gnudb.gnudb.org -B || { | |
echo "error running cdda2wav" | |
exit 1 | |
} | |
[[ -f audio.cddb ]] || { | |
echo "Warning: No CDDB file created, create your own an rerun this script" | |
echo "You need these lines: DTITLE, DYEAR, TTITLEs (one per track" | |
exit 1 | |
} | |
album=$(sed '/^DTITLE/!d; s/.*=//' audio.cddb) | |
year=$(sed '/^DYEAR/!d; s/.*=//' audio.cddb) | |
ntracks=$(sed '/^TTITLE/!d' audio.cddb | wc -l) | |
# FIXME/TODO: disc artist or track artists are currently not parsed | |
sed '/^T/!d; s/.*=//' audio.cddb | cat -n | while read i title; do | |
idx=$(printf %02d $i) | |
lame --tt "$title" \ | |
--ta "$USER" \ | |
--tl "$album" \ | |
--ty "$year" \ | |
--tn $i/$(printf %02d $ntracks) \ | |
"audio_$idx.wav" "$idx - $title.mp3" | |
done | |
ls -l *.mp3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment