Skip to content

Instantly share code, notes, and snippets.

@crmne
Created May 11, 2014 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crmne/a73a824253a4f1b39344 to your computer and use it in GitHub Desktop.
Save crmne/a73a824253a4f1b39344 to your computer and use it in GitHub Desktop.
Gets the name, artist and album of the current playing track in iTunes and passes it to Launchbar. Very useful to search the current track in Google, Discogs, and the likes.
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
set myTrack to ""
tell application "iTunes"
if player state is playing then
set myTrack to current track
set myTrack to (get name of myTrack) & " - " & (get artist of myTrack) & " (" & (get album of myTrack) & ")"
end if
end tell
open location "x-launchbar:select?string=" & replace_chars(myTrack, " ", "+")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment