Sunday, June 8, 2008

iTunes track names to Skype

Last week, I noticed that someone on my Skype contacts list had music titles appearing in their Skype "mood" status.
I believe that was accomplished with a Windows program, but it seemed like it shouldn't be a big deal to accomplish this with Applescript on the Mac.

global latest_song, moodprefix, qChar
on run
set moodprefix to ""

set latest_song to ""
set qChar to ASCII character 34

end run
on idle

set aplist to my running_apps()
if aplist contains "iTunes" and aplist contains "Skype" then

tell application "iTunes"
if player state is playing then
set current_tracks_name to moodprefix & qChar & the name of the current track & qChar & " by " & the artist of the current track as string
set current_tracks_name to ""
end if

if (current_tracks_name is not latest_song) then
copy current_tracks_name to latest_song
tell application "Skype"
send command "SET PROFILE MOOD_TEXT " & latest_song script name "iTunes2Skype"
end tell
end if
end tell
end if
return 10
end idle
on reopen
tell me to run
end reopen
on running_apps()
tell application "System Events"
return (get name of every process)
end tell
end running_apps

The above script runs in a "stay open" Applescript application.
Every 10 seconds it checks to see if the iTunes currently playing track has changed. If it has, it sets a new MOOD for Skype.

Download it here.

No comments:

Post a Comment

Please leave your comment here.