-- INTRODUCTION -- Script designed to encode MP3s, add ID tags, and upload to LibSyn. -- This is shout-out-ware: if you use it and like it, please give our -- podcast a shout-out on your podcast. :-) -- LICENSE -- Copyright 2006, The four guys from the podcast "Four Guys Walk -- Into a Bar..." (http://fourguys.libsyn.com, or available on iTunes) -- Feel free to modify to fit your needs, but please do not redistribute -- without this message and the internal documentation. -- REQUIREMENTS -- Requires the LAME command-line utility, which needs to be compiled, -- which probably requires installation of Xcode Tools. -- INSTALLATION OF REQUIRED COMPONENTS -- Don't worry, this is dead easy. -- Installation instructions: -- First, if you haven't already done so, install Xcode Tools; the installer -- can be found in /Applications/Installers/Xcode Tools/XcodeTools.mpkg. -- Next, download the LAME command-line utility. You can find it at -- http://lame.sourceforge.net/download/download.html, under -- "Source Code." Download and un-archive the folder and look -- for a file called "INSTALL" which contains the installation -- instructions, in particular, the following key passage: -- ================================== -- Building the software on *NIX platforms using configure: -- ================================== -- Run the following commands: -- % ./configure -- % make -- % make install -- Once you've opened a terminal window, cd'ed into the LAME folder, -- and issued those three commands, you should see a staggering amount -- of techno-babble fly by, after which you should have a file called "lame" -- in your /usr/local/bin directory. Try typing -- ls /usr/local/bin -- into the terminal window and looking for it. If it's there, -- you're good to go. (If it's not, something has gone wrong, -- and you should consult a local IT geek. We have no idea. -- Sorry.) -- THE SCRIPT -- First, set the global variables; otherwise they'll get dropped, annoyingly. global theFilename global theTitle global quoteMark global theDir global inputDirectory global myITunesDir global imageData global LibUser global LibPass global podcastName global artistName global myComment global FTPserver global bitrate global frequency -- USER-SPECIFIC SETTINGS -- Next, set up a few variables that will be specific to your computer. -- Pick a directory for the script to use (I use the desktop) -- and don't forget the trailing colon: -- e.g., set inputDirectory to "/Users/someguy/desktop/" set inputDirectory to "Macintosh HD:path:to:some:directory:" -- Now set the bitrate and frequency at which you want your -- podcast to be recorded. We use 96 / 44.1, but for spoken podcasts -- 64 / 22.05 is perhaps more common. set bitrate to "64" set frequency to "22.05" -- Next, tell iTunes a little bit about your podcast. set podcastName to "Name Of Your Podcast" set artistName to "Artist Name" set myComment to "Your comment" -- The biggest trick here is finding the file that iTunes is going to -- import below. Usually replacing the right parts of the path -- with the appropriate values will do the trick, but check to -- make sure. It should NOT be in the podcasts directory. set myITunesDir to "/Users/someguy/Music/iTunes/iTunes Music/" & artistName & "/" & podcastName & "/" -- Here's where you tell it to find the picture. Replace this path. set imageData to (read file ("HD:Users:someguy:pictures:mypicture.pict") from 513) -- Note: Adding the image is a little tricky; I had to convert mine -- to .pict format and use a much larger version of the artwork -- in order to make it come out looking all right. No idea why. -- Bottom line, your mileage may vary. -- Now set the FTP server to libsyn.org. You probably don't -- want to change this, except for testing purposes. -- Don't forget the slash at the end ("ftp://ftp.libsyn.org/"). set FTPserver to "ftp://ftp.libsyn.org/" -- Finally, give it your username and password for your Libsyn account -- so that it can ftp in and upload the file at the end. set LibUser to "username" set LibPass to "password" -- END OF USER-SPECIFIC SETTINGS -- YOU SHOULD NOT HAVE TO CHANGE ANYTHING BELOW HERE set theDir to POSIX path of inputDirectory -- CONVERSION TO MP3 -- Find the original file, which must be in lossless format. -- Note that LAME will NOT convert encoded files to .mp3! -- Note also that some .aiff files are really .aifc, which -- are partially encoded. Audacity produces the right kind -- of .aiff file. Try converting a small file first using LAME -- to see whether it'll work. If not, you'll get a lot of static. set theFile to POSIX path of (choose file with prompt "Select a file to read (NO SPACES IN FILENAME!):" of type {"AIFF", "WAV"}) -- Choose a filename with no spaces... display dialog "Enter output filename" default answer "1__Foo.mp3" set theFilename to (text returned of result) -- ...and a title as it will show up in iTunes. display dialog "Enter episode title" default answer "1. Foo" set theTitle to (text returned of result) set newFile to theDir & theFilename set tempFile to theDir & "deleteme.mp3" set quoteMark to "\"" -- Now convert from lossless format to a file called deleteme.mp3. -- If you want to tweak your mp3 encryption options, this is the -- place to do it; there are quite a few. This is very vanilla. -- In the shell, type "/usr/local/bin/lame --longhelp" to see all options. -- Note: We don't use variable-rate or average-rate encoding because -- we're not sure that all mp3 players understand them. set theCommand to "/usr/local/bin/lame --preset cbr " & bitrate & " --resample " & frequency & " " & theFile & " " & tempFile do shell script theCommand -- ADDING ID3 TAGS -- Now import deleteme.mp3 into iTunes and add ID3 information. tell application "iTunes" add inputDirectory & ":deleteme.mp3" to playlist "Library" of source "Library" set myTrack to track "deleteme" in the playlist "Library" set data of artwork 1 of myTrack to imageData set album of myTrack to podcastName set artist of myTrack to artistName set comment of myTrack to myComment set year of myTrack to "2006" set name of myTrack to theTitle set genre of myTrack to "Podcast" set bookmarkable of myTrack to true set EQ of myTrack to "Spoken Word" set rating of myTrack to 100 -- (just a little joke. That doesn't really work.) end tell -- UPLOADING TO LIBSYN -- Now copy the modified iTunes file to the working directory and -- delete deleteme.mp3. Note that this leaves a copy -- in iTunes so that you can inspect it later. do shell script "cp " & quoteMark & myITunesDir & theTitle & ".mp3" & quoteMark & " " & quoteMark & theDir & theFilename & quoteMark do shell script "rm " & quoteMark & theDir & "deleteme.mp3" & quoteMark -- Finally, just ftp the new file up to your LibSyn account (obviously, -- replace "username" and "password" with your real values)... set myuploadfile to theDir & theFilename set mycommand to "curl " & FTPserver & " -u " & LibUser & ":" & LibPass & " -T " & myuploadfile as string do shell script mycommand -- ...delete the local file from the working directory... do shell script "rm " & quoteMark & theDir & theFilename & quoteMark -- ...and notify the user that everything has finished! -- (Feel free to eliminate either notification; I like both.) tell application "iTunes" say "Conversion, tagging, and upload complete!" with timeout of 5000 seconds display dialog "Conversion, tagging, and upload complete!" buttons {"OK"} default button 1 end timeout end tell -- Ta-daah!