Friday, June 04, 2004

My Script is Alive! It's Aliiive!

After banging my head for 2 days straight, I finally managed to get my two-headed AppleScript/JavaScript monster to work.

Let me explain: On this blog's sidebar, below the links, there is a lone link called In My iPod. The whole purpose of that link is that anyone who visits can see what song I'm currently listening to or last played from iTunes. Not only that, but clicking it takes you directly to either the iTunes Music Store, where you can listen to the preview and purchase the song, or to the iTunes download page if it's not installed on the computer. Pretty nifty, huh? Well, it was no easy task!

I've been coding, copy-pasting, testing, and debugging this damn thing for a couple of days now. The process is the following:
  1. AppleScript opens iTunes and gets the names for the song, artist, and album currently being played.
  2. Then it filters the names for odd characters, like those miserable little apostophe's, which aren't very script friendly.
  3. Once that's done, the computer creates an empty JavaScript file.
  4. AppleScript then writes into the empty file the link, the way it has to be displayed in the browser, and saves it.
  5. A background process then uploads the file to the server where my blog resides.
  6. Upon refreshing the browser... voilá! The song title, artist, and link are updated!
So, now you know what it does. Simple, right? I'll keep working on it these next few days. I could leave it as it is now that it's working, but who do you think I am? Microsoft?

2 Comments:

At 5:52 PM, Tony said...

Heyyy if you are into the whole editing-Blogs-so-that-it-looks-cooler-than-everybody-elses then do some Java Stuff to mine. : )

 
At 12:43 AM, Anonymous said...

[itsreallyenvy]OMG WHAT A GEEK! [/itsreallyenvy]

my LiveJournal blog has that too, for the song currently playing on my player (be it MusicMatch or WinAmp)

 

Post a Comment

<< Home