Skip to content

Instantly share code, notes, and snippets.

@kristianfreeman
Created August 13, 2012 20:15
Show Gist options
  • Save kristianfreeman/3343806 to your computer and use it in GitHub Desktop.
Save kristianfreeman/3343806 to your computer and use it in GitHub Desktop.
TE snippet for iTunes Now Playing Output

A simple TextExpander snippet for pasting a nice-looking version of your "Now Playing" from iTunes. Uses Applescript — if you have a different music player (Spotify, for example), it probably has similar Applescript support.

For example: ♫ "My Favourite Things" - John Coltrane (The Very Best of John Coltrane, 2000)

set the_string to ""

tell application "iTunes"
   if player state is playing then
      set the_string to "\"" & name of current track & "\""
      if artist of current track is not "" then
         set the_string to the_string & " - " & artist of current track
      end if
      if album of current track is "" and year of current track is 0 then
         set the_string to the_string
      else if album of current track is not "" and year of current track is not 0 then
         set the_string to "*" & "♫ " & the_string & " (" & album of current track & ", " & year of current track & ")"  & "*"
      else if year of current track is not 0 then
         set the_string to the_string & " (" & year of current track & ")"
      else if album of current track is not "" then
         set the_string to "*" & "♫ " & the_string & " (" & album of current track & ")" & "*"
      end if
   else
      set the_string to "Not Playing"
   end if
end tell

return the_string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment