-- Copyright © 2011 Alex Sørlie -- on textualcmd() set listening to "/me is not currently running iTunes" tell application "System Events" tell application "System Events" to set is_running to exists (processes where name is "iTunes") end tell if is_running then tell application "iTunes" if player state is playing then set listening to "/me is listening to " if current stream title is not missing value then set listening to listening & name of current track & " streaming \"" set {art, nom} to my text_to_list(current stream title, " - ") set listening to listening & art & " - " & nom & "\"" else set the_kind to kind of current track set songsize to ((size of current track) / 1048576) set songsize to (round (songsize * 100)) / 100 set movie_list to {"Movies", "TV Shows", "Podcasts", "iTunes U"} set movie_kinds to {"MP4", "Movie", "WAV"} if the_kind contains "MPEG-3 audio file" then set the_kind to "MP3" if the_kind contains "MPEG-4 video file" then set the_kind to "MP4" if the_kind contains "QuickTime movie file" then set the_kind to "Movie" if the_kind contains "AAC" then set the_kind to "AAC" if the_kind contains "WAV" then set the_kind to "WAV" if the_kind contains "Apple Lossless" then set the_kind to "Apple Lossless" if name of current playlist is in movie_list and the_kind is in movie_kinds then set iartist to artist of current track if length of iartist is 0 then set listening to "/me is watching " & name of current track & " [" & time of current track & " mins] [" & bit rate of current track & " kbps " & the_kind & "] [" & songsize & " MB]" else set listening to "/me is watching " & artist of current track & " - " & name of current track & " [" & time of current track & " mins] [" & bit rate of current track & " kbps " & the_kind & "] [" & songsize & " MB]" end if else set listening to listening & artist of current track & " - " & name of current track & ", from the album " & album of current track & "" end if end if else set listening to "/me is not currently playing anything in iTunes" end if end tell end if return listening end textualcmd -- text_to_list AppleScript function from: -- on text_to_list(txt, delim) set saveD to AppleScript's text item delimiters try set AppleScript's text item delimiters to {delim} set theList to every text item of txt on error errStr number errNum set AppleScript's text item delimiters to saveD error errStr number errNum end try set AppleScript's text item delimiters to saveD return (theList) end text_to_list