Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/bin/bash
# Encode a WAV to a finalized podcast MP3 with metadata, in the current directory
# Requires lame
# With Homebrew on Mac OS X: brew install lame
# Usage:
# Call the script with three arguments:
# -t or --title followed by the title of the episode in quotes
# -s or --summary followed by the iTunes Summary for the episode, in quotes
# the name of the file, which is assumed to have the episode number in it.
#
# So, for episode 104, the correct syntax would be:
#
# encode-podcast.sh -t "Minutiæ" -s "Please email us about Photos.app, UXKit, and React." atp104.wav
for ARGS in "$@"
do
case "$ARGS" in
-t|--title)
shift
EPISODE_TITLE="$1"
shift
;;
-s|--summary)
shift
EPISODE_SUMMARY="$1"
shift
;;
-*|--*)
echo " $NAME [warning]: Don't know what to do with arg: $1"
exit 1
;;
esac
done # for args
INPUT_WAV_FILE="$@"
# Strip everything from the filename except the numbers
EPISODE_NUMBER=`echo "$INPUT_WAV_FILE" | sed 's#.*/##g' | tr -dc '[0-9]'`
echo "
INPUT_WAV_FILE: $INPUT_WAV_FILE
EPISODE_TITLE: $EPISODE_TITLE
EPISODE_NUMBER: $EPISODE_NUMBER
EPISODE_SUMMARY: $EPISODE_SUMMARY
"
SHOW_AUTHOR="ATP"
# Artwork: ideally 1400x1400, but less than 128 KB to maximize compatibility
ARTWORK_JPG_FILENAME="${HOME}/Dropbox/ATP/Artwork.jpg"
# Output quality (kbps): 96 or 64 recommended
MP3_KBPS=96
# Really long lines make baby Jesus cry
lame --noreplaygain --cbr -h -b $MP3_KBPS \
--resample 44.1 --tt "$EPISODE_NUMBER: $EPISODE_TITLE" --tc "$EPISODE_SUMMARY" \
--ta "$SHOW_AUTHOR" --tl "$SHOW_AUTHOR" --ty `date '+%Y'` --ti "$ARTWORK_JPG_FILENAME" \
--add-id3v2 "$INPUT_WAV_FILE" "${INPUT_WAV_FILE%%.wav}.mp3"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment