Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Open link list for the 5by5 show currently playing in iTunes
tell application "System Events"
set itunesRunning to count of (every process whose name is "iTunes")
if itunesRunning is 0 then return
end tell
tell application "iTunes"
if player state is stopped then return
set shows to {{title:"Hypercritical", slug:"hypercritical"}, {title:"The Talk Show", slug:"talkshow"}, {title:"Build and Analyze", slug:"buildanalyze"}, {title:"After Dark", slug:"afterdark"}, {title:"The Pipeline", slug:"pipeline"}, {title:"5by5 Specials", slug:"specials"}, {title:"Back To Work", slug:"b2w"}, {title:"Mac Power Users", slug:"mpu"}, {title:"The Incomparable", slug:"incomparable"}, {title:"The Cocktail Napkin", slug:"tcn"}, {title:"Latest in Paleo", slug:"paleo"}, {title:"Critical Path", slug:"criticalpath"}, {title:"The Big Web Show", slug:"bigwebshow"}, {title:"Content Talks", slug:"contenttalks"}, {title:"Founders Talk", slug:"founderstalk"}, {title:"The Ihnatko Almanac", slug:"ia"}, {title:"Geek Friday", slug:"geekfriday"}, {title:"Internet Superhero", slug:"superhero"}, {title:"The Web Ahead", slug:"webahead"}, {title:"5by5 at the Movies", slug:"movies"}, {title:"Systematic", slug:"systematic"}, {title:"The B&B Podcast", slug:"bb"}, {title:"Amplified", slug:"amplified"}, {title:"In Beta", slug:"inbeta"}, {title:"The Comic Shack", slug:"comicshack"}, {title:"The Nickel", slug:"nickel"}, {title:"Screen Time", slug:"screentime"}}
repeat with theShow in shows
if title of theShow is (album of current track) then
copy (get name of current track) to trackName
set AppleScript's text item delimiters to {":"}
set epNumber to last word of text item 1 of trackName
--trim non-digits from episode number (e.g. #)
set epNumber to do shell script "echo " & quoted form of epNumber & "| tr -cd '[[:digit:]]'"
set showUrl to "http://5by5.tv/" & (slug of theShow) & "/" & epNumber & "/#links_block"
tell application "Finder" to open location showUrl
exit repeat
end if
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment