Be a Better Podcaster Blog: Automating Your Podcast Workflow Part 2

Yesterday, I posted Part 1 of the podcasting automation process I’m using. Today, it’s on to Part 2. Remember, this tutorial is for Mac users (or Linux, I suppose) – it won’t port to Windows. I may decide to rewrite the whole thing in PHP down the road, but for now, this was done using the Bash shell on a Unix-based system.

First, a short recap…

The workflow picks up after the final editing and exporting to MP3 of the podcast episode. The automation includes the following steps:

  1. Set the ID3 tags
  2. FTP the episode to the remote server
  3. Archive the MP3 to a local folder and an attached Drobo unit
  4. Create a WordPress post for the show notes

Yesterday’s post created set up all the variables needed. Today I’ll cover the first three things on the list, tomorrow I’ll finish up with a PHP script that handles the posting to WordPress.

Automatically Setting ID3 Tags on the Command Line

There is no way to use the command line to set ID3 tags without a third-party tool or library. There is currently only one tool that will allow you to set every conceivable tag via the command line, and that’s ID3 Editor. I’d been using this tool in its GUI form for a long time, but the command line interface is awesome as well. Unfortunately, documentation about this command line use is very, very rare. First, the code:

[bash]############################
# The main monkey business
#
case $showcode in

### Geek Dads Weekly ###
"gdw") echo "case gdw"
# set ID3 variables
album="$showname"
image="$gdwimage"

# set FTP variables
remotedir="$gdwremotedir"
ftpserv="$gdwftp"

# set storage variables
localstor="$gdwl"
drobo="$gdwd"

# set WordPress variables
wpcat="3"
;;

### Be a Better Podcaster ###
"babp") echo "case babp"
# set ID3 variables
album="$showname"
image="$babpimage"

# set FTP variables
remotedir="$babpremotedir"
ftpserv="$babpftp"

# set storage variables
localstor="$babpl"
drobo="$babpd"

# set WordPress variables
wpcat="110"
;;

### Inside Internet Marketing ###
"iim") echo "case iim"
# set ID3 variables
album="$showname"
image="$iimimage"

# set FTP variables
remotedir="$iimremotedir"
ftpserv="$iimftp"

# set storage variables
localstor="$iiml"
drobo="$iimd"

# set WordPress variables
wpcat="14"
;;

### Yet Another Weight Loss Show ###
"yawls") echo "case yawls"
# set ID3 variables
album="$showname"
image="$yawlsimage"

# set FTP variables
remotedir="$yawlsremotedir"
ftpserv="$yawlsftp"

# set storage variables
localstor="$yawlsl"
drobo="$yawlsd"

# set WordPress variables
wpcat="8"
;;

### Road to Thin ###
"rtt") echo "case rtt"
# set ID3 variables
album="$showname"
image="$rttimage"

# set FTP variables
remotedir="$rttremotedir"
ftpserv="$rttftp"

# set storage variables
localstor="$rttl"
drobo="$rttd"
;;
esac
[/bash]

This is a case statement. In English, this code says, “look at the $showcode variable, and if it’s gdw, set some variables to some values. If it’s babp (or one of the other shows), set those variables to some other values”. The variables in question are the album and image for the ID3 tags, the location of the remote directory on the FTP server, and the local folder & Drobo location to archive to. The Road to Thin show doesn’t have a WordPress category set because I don’t create a post for it – it’s not part of QAQN, but I do the production for it.

[bash]############################
# Set the ID3 tags
id3edcmd -gn "Podcast" -im "$image" -cm "$composer" -cp "$copyright" -co "$comment" -ur "$url" -yr "$DATE" -ti "$fulltitle" -ar "$artist" -al "$album" "$process/$file"
[/bash]

This is my favorite part of the whole script for some reason. Once you have the command line tool installed and configured, it’s invoked with the id3edcmd command with a metric boatload of options. I don’t use them all, but I’ll list them all because someone, somewhere, is wondering how to use this tool. As you can see, I simply declared some variables and popped them into the options, with the exception of the -gn option, which is “Podcast” for all the episodes.

  • -gn = genre (text)
  • -im = image (text; the location of the image file on your hard drive)
  • -cm = composer (text)
  • -cp = copyright (text)
  • -co = comment (text; multi-line, if formatted correctly)
  • -ur = URL (text)
  • -yr = year (number; four digits ONLY)
  • -ti = title (text)
  • -ar = artist (text)
  • -al = album (text)
  • -tr = track number (number)
  • -ts = number of tracks (number)
  • -cf = comment (text; loads from a separate text file)
  • -oa = original artist (text)
  • -en = encoder (text)
  • -cl = compilation flag (iTunes only)
  • -ly = lyrics (text; loads from a separate text file)
  • -cn = conductor (text)
  • -sn = set number (number)
  • -ss = number of sets (number; this is ‘Disk Number’ in iTunes)

That’s only about half the list, and I think I’ve covered everything remotely of interest to podcasters. Whew. For more options, open a Terminal window and type id3edcmd /h – that will give you the complete list.

So, that’s it for setting the ID3 tags. Now, let’s move on to FTP.

[bash]############################
# upload via FTP
/usr/bin/ftp "$ftpserv" << ftpEOF
prompt
cd "$remotedir"
lcd "$process"
put "$file"
quit
ftpEOF
[/bash]

This tiny little bit of code logs into the FTP server, selects the proper directory, PUTs the file up, then quits out. Next-to-lastly:

[bash]############################
# file management (local and Drobo)
test -d "$localstor" && cp "$process/$file" "$localstor"
test -d "$drobo" && mv "$process/""$showcode"*.mp3"" "$drobo"
[/bash]

Now, this is fairly interesting. The first line says, “test to see if the directory defined in the $localstor variable exists, and if it does, copy the MP3 file to that location”. The second line says, “test to see if the directory defined in the $drobo variable exsits, and if it does, move the MP3 file to that location. There is a world of difference between copy and move. I copy first because I want the MP3 file to remain in the Process folder. I move in the next step because I want the MP3 file to both go to the Drobo and disappear from the Process folder. The benefit to structuring the code this way is that if the Drobo isn’t connected, the MP3 file doesn’t get moved anywhere. It will stay in the Process folder until the next time the script runs for the same show.

So, let’s say an episode of Geek Dads Weekly is being processed. It will always go to local storage (unless the directory got deleted for some odd reason). If the Drobo is connected, it will go there, too. If not, it stays. I can then do episodes of all my other shows without affecting this file, but the next time I do a Geek Dads episode, that episode plus the first one will both go to the Drobo (if it’s connected, of course).

And finally:

[bash]url=`echo -e "http://qaqn.com/postwps.php?wpcat=$wpcat\x26fulltitle=$fulltitle"`

if [ "$showcode" != "rtt" ]; then
open -a Safari "$url"
fi
[/bash]

That wraps up the script. Yesterday’s plus today’s = complete. This script works as-is, however, it stops short of posting to WordPress because that is better handled by PHP. That’s the call right there at the end: the script launches Safari (insert Firefox or Chrome if you like) and runs a remote PHP script that takes care of it.

Caution. See the \x26 in there? That’s the ampersand (&) in the URL. You absolutely must format it this way because in Bash, an ampersand is a reserved character (it tells a process to run in the background). The script breaks at this point if you include any ampersands in your URL. Right now, all I’m sending is the category number and the title of the episode, but I can expand it later to send tags, dates, and other information.

Tomorrow: the conclusion!

About Daniel M. Clark

Daniel M. Clark is a podcaster and proprietor of QAQN, a writer at danielmclark.com, and an all-around cool dude everywhere else.

God, I hate talking about myself in the third-person.

Previous post:

Next post: