Created
May 11, 2014 14:56
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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