I am a guitarist and I wanted a way to quickly get tabulature for the music I was listening to in iTunes. So, I made this little script that will search harmony-central.com for the artist and track title of the currently playing track in iTunes or the selected track if it isn't playing. You can save this script to ~/Library -> iTunes -> Scripts, and it will be in the AppleScript menu in iTunes.
tell application "iTunes"
if player state is playing then
set artist_name to artist of current track
set track_name to name of current track
else
set artist_name to the artist of selection of browser window 1
set track_name to the name of selection of browser window 1
end if
end tell
set the artist_name to replace_chars(artist_name, " ", "+")
set the track_name to replace_chars(track_name, " ", "+")
tell application "Safari"
activate
set the URL of the front document to ¬
"http://rhythm.harmony-central.com/olga-query.php?key=" & artist_name ¬
& "+" & track_name
end tell
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
[robg adds: Although I'm not a guitarist :-), I can verify that the script works as described...]
Mac OS X Hints
http://hints.macworld.com/article.php?story=20030714201412852