Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Add iTunes song info to your AIM profile Internet
Have you ever wanted to let the world know what song you're currently listening to? If you use AIM (America Online's Instant Messenger), now you can! The following AppleScript takes the currently playing song and places it in your AIM profile for all to see.

Read the rest of the article for the script and instructions.

[Editor's note: I have not tried this myself, but it seems like an interesting trick and opens up some cool posibilities for other dynamic content.]


Thanks to my friend Rick A. for this idea. Here's the AppleScript:
--
-- Set AIM Profile to contain current iTunes track
-- by Ian Langworth - www.logicallemon.com
-- 2/3/2002 - thanks to Rick A. for the idea
-- shouts to Rick and Adam F.
--

-- put the contents of your profile between these quotes
-- (the track name will go above)
property profilebits : "
home page: www.logicallemon.com
my music: www.logicallemon.com/music
"

-- this is the prompt that'll precede the track
property prompt : "WHAT'S PLAYING: "

-- ------------------------------------------
try
tell application "iTunes"
set theSong to (artist of current track) & " - "" & (name of current track) & """
end tell
on error
set theSong to "(no song playing)"
end try

try
tell application "AOL Instant Messenger (SM)"
set profile to prompt & theSong & return & profilebits
end tell
end try
Now, save this as a file and put it in your crontab to run every two minutes:

1) run 'crontab -e' in a Terminal
2) insert this line and save:
2 * * * * osascript /Users/me/Documents/the_script_i_just_saved
    •    
  • Currently 2.80 / 5
  You rated: 3 / 5 (5 votes cast)
 
[26,655 views]  

Add iTunes song info to your AIM profile | 15 comments | Create New Account
Click here to return to the 'Add iTunes song info to your AIM profile' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
crontab error
Authored by: Embro on Feb 06, '02 01:10:11PM

You have it set to run at 2 minutes after every hour. I think you mean

*/2 * * * * osascript /Users/me/Documents/scriptname

to have it run every two minutes. I use CronniX to set this up.

Mark



[ Reply to This | # ]
crontab error
Authored by: Embro on Feb 06, '02 01:12:09PM

Ooops....I mean

*/1 * * * * osascript /Users/me/Documents/scriptname



[ Reply to This | # ]
crontab error
Authored by: Embro on Feb 06, '02 01:21:20PM

Agggghhh...too much caffeine

The first one was right

*/2



[ Reply to This | # ]
still won't work right
Authored by: Embro on Feb 06, '02 10:58:45PM

I've actually messed with this for some time now and not had great results. I set it to */2 to run every two minutes. Use cronniX to make your life easy. Read it's help for a full explanation of the crontab settings.

If I make the script a stand alone app and use /usr/bin/open /Users/me/Documents/myscript it runs properly although it actually switches out of the current app when it runs. That is too annoying.

I cannot get the osascript command to work right from cron. I get an error saying "syntax error: Can't get the application's event dictionary. (-2709)" although if I run this same command from terminal it works properly. This is with either just a text file or a compiled script I think.

Does this need to be put in the System Crontab rather than my user Crontab? Maybe I'll try that next.

If anyone knows how to fix this please share ;-)

Mark



[ Reply to This | # ]
Syntax errors, cron problems
Authored by: jacob on Feb 06, '02 10:58:47PM

There seem to be syntax errors in this script (all the quotes that should be displayed in the AIM profile are not escaped properly i.e. not preceded by backslashs).

Also, even after fixing this, I wasn't able to get this script to run. It works fine when run normally (from within Script Editor, using osascript on the shell, etc). However, when called from my crontab file, the script always throws (and catches) an error when it tries to set the profile.

Maybe this last error is just me...anyone else have any success getting this to work?



[ Reply to This | # ]
better solution..
Authored by: thenexus62 on Feb 06, '02 11:34:09PM

yeah i messed around with the script and cron like you guys, but i finally got pissed off and stumbled upon Script Timer 1.2 at http://www.theboss.net/appsmore/. It's shareware, but it's good enough for now. Also it creates a log file and when i have it set to update every minute, that can get big, but you can just write a script to delete the log file :P



[ Reply to This | # ]
forget crontab!
Authored by: Embro on Feb 07, '02 02:31:04AM
Try this script instead and forget the crontab stuff. Save it as an application and just double click it. It will run in the background without sucking too much processor time. It will update aim about every minute.

--
-- Set AIM Profile to contain current iTunes track
-- by Ian Langworth - www.logicallemon.com
-- 2/3/2002 - thanks to Rick A. for the idea
-- shouts to Rick and Adam F.
-- modified by Mark S. aka Embro
-- put the contents of your profile between these quotes
-- (the track name will go above)
property profilebits : "
Music makes the world go round
"
-- this is the prompt that'll precede the track
property prompt : "What I'm playing in iTunes right now: "
-- ------------------------------------------
repeat
set the theTime to (the (current date) + 60)
repeat until the (current date) is greater than theTime
delay 60
end repeat
try
tell application "iTunes"
set theSong to (artist of current track) & " - " & (name of current track) & ""
end tell
on error
set theSong to "(no song playing)"
end try
try
tell application "AOL Instant Messenger (SM)"
set profile to prompt & theSong & return & profilebits
end tell
end try
end repeat



[ Reply to This | # ]
forget crontab!
Authored by: MeStinkBAD on Feb 07, '02 09:15:01AM

Ummm... wouldn't the better approach be to create an script application that uses the idle handler? Something like this...

---

on display_iTunes_data()
tell application "Finder"
if not (exists process "iTunes") or not (exists process "AOL Instant Messenger (SM)") then
return true -- don't do anything if iTunes isn't running
end if
end tell

try
tell application "iTunes"
set theSong to (artist of current track) & " - "" & (name of current track) & """
end tell
on error
set theSong to "(no song playing)"
end try
try
tell application "AOL Instant Messenger (SM)"
set profile to prompt & theSong & return & profilebits
end tell
end try
end display_iTunes_data

on idle {}
display_iTunes_data()
return 60
end idle

---

I don't use AIM so I dunno if this will work, but it does compile! :)



[ Reply to This | # ]
AOL IM Script Trouble
Authored by: senecasax on Feb 21, '02 07:04:45PM

Ok, from what I can tell, AIM (newest X version) does not allow applescript to change the profile - (look at the dictionary). So how does one get this script to work???



[ Reply to This | # ]
IRC
Authored by: piddle spank on Feb 22, '02 03:33:58AM

anyone give me the code to get this to work in my IRC client? ("AthenaIRC 1.7") i am no good at apple script. i was hoping it would do the /me sort of thing preferably every song?



[ Reply to This | # ]
iTunes and Yahoo! Messenger status
Authored by: mlibbey on Feb 22, '04 03:38:36PM
Here's the applescript for Yahoo! Messenger to get the iTunes status message:


repeat
	set the theTime to (the (current date) + 60)
	repeat until the (current date) is greater than theTime
		delay 60
	end repeat
	try
		tell application "iTunes"
			set theSong to (artist of current track) & "-" & (name of current track)
		end tell
	on error
		set theSong to "(no song playing)"
	end try
	
	try
		tell application "Yahoo! Messenger"
			SetStatus 2 with "iTunes:" & theSong -- & return
		end tell
	end try
end repeat
There is a bug that I can't figure out -- this makes you appear 'busy' as well -- I don't know how to unset the busy flag. I tried using the 'on idle' version posted, but couldn't get it to work.

[ Reply to This | # ]
iTunes and Yahoo! Messenger status
Authored by: rmccrae on Aug 03, '04 05:55:28PM

I found that if you replace the line
SetStatus 2 with "iTunes:" & theSong -- & return
with
SetStatus 99 with "iTunes:" & theSong -- & return
it displays the status without the busy icon showing.



[ Reply to This | # ]
iTunes and Yahoo! Messenger status
Authored by: osxgnuorggurl22 on Apr 29, '05 05:26:52PM

Okay, how do I use this?



[ Reply to This | # ]
Add iTunes song info to your AIM profile
Authored by: mproud on Feb 26, '04 02:07:31AM

WHAT?? I have to edit out the backslashes??



[ Reply to This | # ]
Add iTunes song info to your AIM profile
Authored by: mproud on Feb 26, '04 06:11:48AM
This works, folks. And well. Might have a little trouble on exit, and it makes a brave attempt at preserving the previous profile. Anyway, the key is using terms from - that's necessary to actually get at the set profile command in AIM.
tell application "AOL Instant Messenger (SM)"
	using terms from application "AOL Instant Messenger (SM)"
		set lastProfile to profile
	end using terms from
end tell

idle {}

on idle {}
	tell application "Finder"
		if (not (exists process "iTunes")) or (not (exists process "AOL Instant Messenger (SM)")) then
			idle
		end if
	end tell
	update()
end idle

on update()
	try
		tell application "iTunes"
			if player state is playing then
				set trackName to name of current track
				set trackAlbum to album of current track
				set trackArtist to artist of current track
			else if player state is paused or player state is stopped then
				try
					using terms from application "AOL Instant Messenger (SM)"
						tell application "AOL Instant Messenger (SM)"
							set profile to lastProfile
						end tell
					end using terms from
				on error
					idle
				end try
				idle
			else if player state is fast forwarding or player state is rewinding then
				set trackName to name of current track
				set trackAlbum to album of current track
				set trackArtist to artist of current track
				
				repeat while player state is fast forwarding or player state is rewinding
				end repeat
				set trackName to name of current track
				set trackAlbum to album of current track
				set trackArtist to artist of current track
			end if
		end tell
		
		try
			using terms from application "AOL Instant Messenger (SM)"
				tell application "AOL Instant Messenger (SM)"
					set profile to "Now playing" & return & trackName & return & trackAlbum & return & trackArtist
				end tell
			end using terms from
		end try
		try
			tell application "iTunes" to delay (duration of current track) - player position
		on error
			tell application "Finder"
				using terms from application "AOL Instant Messenger (SM)"
					set profile to lastProfile
				end using terms from
			end tell
			idle
		end try
	on error
		idle
	end try
	update()
end update


[ Reply to This | # ]