Created
May 3, 2014 20:57
-
-
Save anonymous/a7b7325dfed682bdfbb1 to your computer and use it in GitHub Desktop.
CD Digitizing Toolchain
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 | |
# | |
## convert.sh | |
# | |
# This script is used to convert all of the WAV audio files of a given | |
# artist/album pair to a different encoding. | |
# | |
# usage: | |
# convert.sh [artist] [album] | |
CODEC="flac" | |
# Prompt for information. | |
ARTIST="$1" | |
ALBUM="$2" | |
if [ -z "$ARTIST" ] | |
then | |
echo -n "Please enter an artist: " | |
read ARTIST | |
fi | |
if [ -z "$ALBUM" ] | |
then | |
echo -n "Please enter an album: " | |
read ALBUM | |
fi | |
# Assume the directories to move from are incoming and untagged. | |
INDIR="incoming/$ARTIST/$ALBUM" | |
OUTDIR="untagged/$ARTIST/$ALBUM" | |
INFILES=$(ls "$INDIR") | |
mkdir -p "$OUTDIR" | |
for file in $INFILES | |
do | |
infile="$INDIR/$file" | |
outfile="$OUTDIR/$(basename "$file").$CODEC" | |
# Convert the file | |
ffmpeg -i "$infile" "$outfile" | |
# If the conversion was successful, remove the raw file. | |
if [ $? == 0 ] | |
then | |
rm "$infile" | |
fi | |
done | |
# Prune empty directories under the artist. | |
rm -d "$INDIR" | |
rm -d "incoming/$ARTIST" |
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 | |
# | |
## getcd.sh | |
# | |
# This script opens the CD drive and prompts the user for an artist | |
# and album name. It then uses CDparanoia to rip the CD, and put it in | |
# the appropriate directory in raw form. | |
# | |
# usage: | |
# getcd.sh [artist] [album] | |
# Open the tray. | |
eject | |
# Prompt for information. | |
ARTIST="$1" | |
ALBUM="$2" | |
if [ -z "$ARTIST" ] | |
then | |
echo -n "Please enter an artist: " | |
read ARTIST | |
fi | |
if [ -z "$ALBUM" ] | |
then | |
echo -n "Please enter an album: " | |
read ALBUM | |
fi | |
# Close the tray. | |
eject -t | |
# Make the appropriate directory inside incoming/ | |
DIR="incoming/$ARTIST/$ALBUM" | |
mkdir -p "$DIR" | |
echo "==== RIPPING ====" | |
# Wait for the drive to be mounted. | |
# TODO: something sensible | |
sleep 10 | |
# Rip the CD in semi-paranoid batch mode, and put the WAV results in | |
# the appropriate directory. | |
CURDIR=$(pwd) | |
cd "$DIR" | |
cdparanoia -Y -B | |
cd "$CURDIR" | |
# Eject the tray again. | |
eject | |
echo "==== DONE ====" |
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 | |
# | |
## importcd.sh | |
# | |
# This script combines getcd.sh and convert.sh. | |
# | |
# usage: | |
# importcd.sh [artist] [album] | |
# Prompt for information. | |
ARTIST="$1" | |
ALBUM="$2" | |
if [ -z "$ARTIST" ] | |
then | |
echo -n "Please enter an artist: " | |
read ARTIST | |
fi | |
if [ -z "$ALBUM" ] | |
then | |
echo -n "Please enter an album: " | |
read ALBUM | |
fi | |
# Invoke getcd.sh in the same directory. | |
"$(dirname $0)/getcd.sh" "$ARTIST" "$ALBUM" | |
# Same deal for convert.sh. | |
"$(dirname $0)/convert.sh" "$ARTIST" "$ALBUM" | |
# Send a terminal bell alert. | |
echo -n "\a" |
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 | |
# Run the import command. | |
beet -d "/home/sasha/music" import -i -l "tag.log" "untagged/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment