on run {inputFile, parameters}
set theFile to inputFile as text
set theSlug to (find text "\\\\:([A-Za-z]+)[0-9]{1,3}.aif" in theFile using "\\\\1" with regexp and string result)
set theNumber to (find text "\\\\:[A-Za-z]+([0-9]{1,3}).aif" in theFile using "\\\\1" with regexp and string result)
set theResultPath to (find text "(.*?).aif" in theFile using "\\\\1" with regexp and string result)
set theSuggestion to "Enter Podcast Name"
if theSlug is "theincomparable" then set theSuggestion to "The Incomparable"
if theSlug is "tpk" then set theSuggestion to "Total Party Kill"
if theSlug is "tvtm" then set theSuggestion to "TV Talk Machine"
if theSlug is "teevee" then set theSuggestion to "TeeVee"
if theSlug is "rocketsurgery" then
set theSuggestion to "The Incomparable"
set theSlug to "theincomparable-rocketsurgery"
end if
if theSlug is "oldmovieclub" then
set theSuggestion to "The Incomparable"
set theSlug to "theincomparable-oldmovieclub"
end if
set theShow to text returned of (display dialog "What show?" default answer theSuggestion) as string
set theShowNumber to text returned of (display dialog "What episode?" default answer theNumber) as string
set theEpisodeTitle to text returned of (display dialog "What episode title?" default answer "Episode Title") as string
set theEpisodeSummary to text returned of (display dialog "What\'s the description?" default answer "Enter Description") as string
if theSlug is "tpk" then
set monomode to "s"
set quality to "128"
else
set monomode to "m"
set quality to "64"
end if
set theLameCommand to ("/usr/local/bin/lame --noreplaygain --cbr -h -b " & quality & " --resample 44.1 -m " & monomode & " --tt \\"" & theShowNumber & ": " & theEpisodeTitle & "\\" --tc \\"" & theEpisodeSummary & "\\" --ta \\"The Incomparable\\" --tl \\"" & theShow & "\\" --ty `date \'+%Y\'` --ti \\"${HOME}/Dropbox/Logo - The Incomparable/logo-" & theSlug & ".jpg\\" --add-id3v2 \\"" & (POSIX path of theFile) & "\\" \\"${HOME}/Desktop/" & theSlug & theNumber & ".mp3\\"")
do shell script theLameCommand
end run