Aditunes – Make your duck sing!

A while ago I wrote a plugin/script for Adium. It facilitates sharing the current song in iTunes with your chat partner. It is/was quite popular with over 16.000 downloads and an average score of 4.2 out of 5. Unfortunately I didn’t have the time to support the script anymore, that’s why “Adium” kicked it off the extras site. Below is a link where you can still download the script. I’m hoping someone likes the idea and maybe improve it. All the code is public and open for anyone to alter.
The plugin page.
PS. Please don’t ask me for technical support, as I said I don’t have time for it anymore. There is a read me included with instructions and tips if you run into trouble.

"AdiTunes" for Adium in combination with iTunes
written by Mark Pith (mark.pith [at]

Inspired by the TrackURL script by jrigby, special thanks to Erik Koldenhof.
I've used a large portion of "Save Album Art to Album Folder" for iTunes, written by Doug Adam (thanks!).
As it is distributed under the GPL, I'm, as far as I understand, obligated to do so as well.
Thanks Wesley Underwood, Adam Betts and Laura Natcher for the Adium Ducky artwork.
The HTML layout is inspired by a template from .
I would like to thank Tony Yazbeck; my beta tester and text corrector!
A very big thanks to all the Adium developers!

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Get a copy of the GNU General Public License by writing to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

or visit
-- check if iTunes is running, if so send result, else send message "iTunes not running"
on substitute()
tell application "System Events"
set iTunesRunning to (name of processes) contains "iTunes"
end tell
if iTunesRunning is true then
return EndResult()
return "I'm sorry, iTunes is not running."
end if
end substitute

--get info from iTunes, Finder, System and Internet, and send message to Substitute
on EndResult()
tell application "iTunes"
set TrackTitle to name of current track as string
set TrackArtist to artist of current track as string
set TrackAlbum to album of current track as string
set trackLocation to location of current track
if exists artworks of current track then
set trackArtwork to (data of artwork 1) of current track
set trackArtworkFormat to (format of artwork 1) of current track as string
set trackArtwork to ""
set trackArtworkFormat to ""
end if

end tell
set wanip to GetWanIP()
set User to do shell script "whoami" as string
set startupdisk to path to startup disk as string
set AdiTunesfolder to startupdisk & "Library:WebServer:Documents:" & User & ":AdiTunes:" as string
my MakeImage(trackArtwork, trackArtworkFormat, AdiTunesfolder)
my MakeResult(TrackTitle, TrackArtist, TrackAlbum, trackLocation, wanip, trackArtworkFormat, AdiTunesfolder, User)
return "Listen to my iTunes: " & "\"" & TrackTitle & "\"" & " by " & "\"" & TrackArtist & "\"" & ""
end EndResult

-- result subroutine
on MakeResult(Title, Artist, Album, location, wanip, ArtworkFormat, AdiTunesfolder, User)
-- get local URL of file
tell application "System Events"
set localURL to URL of location
end tell
-- change local URL to online URL
set trackURL to searchReplace(localURL, "file://localhost/", "")
-- analyzise URL and change local URL to online URL
set trackList to stringToList for trackURL from "/"
set listCount to count (trackList)
set onlineURL to ("../AdiTunes/Music/" & item (listCount - 2) of trackList & "/" & item (listCount - 1) of trackList & "/" & item (listCount) of trackList) as string
set Body to HTMLcode(onlineURL, Title, Artist, Album, ArtworkFormat)
my WriteFile(Body, AdiTunesfolder)
end MakeResult

-- Create an image (jpg or png) from iTunes' Artwork data, read above for more information.
on MakeImage(Artwork, ArtworkFormat, AdiTunesfolder)
if ArtworkFormat contains "JPEG" then
set extension to ".jpeg"
my saveArtwork(Artwork, extension, AdiTunesfolder)
else if ArtworkFormat contains "PNG" then
set extension to ".png"
my saveArtwork(Artwork, extension, AdiTunesfolder)
do shell script "cp " & (POSIX path of AdiTunesfolder) & "images/album.png " & (POSIX path of AdiTunesfolder) & "album.png"
end if
end MakeImage

on saveArtwork(Artwork, extension, AdiTunesfolder)
-- filename
set filename to "album" & extension
set tempname to "temp" & extension
-- set filepath to target_folder
set tempFile to (AdiTunesfolder & tempname) as text
set finalFile to AdiTunesfolder & filename
-- write temp file
set the tempFile to open for access file tempFile with write permission
write Artwork to the tempFile starting at 0
close access the tempFile
set Artwork to ""
-- strip good parts, delete temp file
do shell script "cd " & quoted form of (POSIX path of AdiTunesfolder) & ";¬
tail -c+223 " & quoted form of tempname & "> " & ¬
quoted form of filename & ";rm " & quoted form of tempname
end saveArtwork

-- getting ipaddress subroutine
on GetWanIP()
set dyndns to (do shell script "curl -f")
set firstresult to searchReplace(dyndns, "Current IP checkCurrent IP Address: ", "")
set IPaddress to searchReplace(firstresult, "", "")
return IPaddress
end GetWanIP

-- writing information to HTML subroutine
on WriteFile(Body, AdiTunesfolder)
set LocalFile to (open for access AdiTunesfolder & "index.html" with write permission)
set eof of LocalFile to 0
write Body to LocalFile
close access LocalFile
end WriteFile

-- searchReplace subroutine
on searchReplace(theText, SearchString, ReplaceString)
set OldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to SearchString
set newText to text items of theText
set AppleScript's text item delimiters to ReplaceString
set newText to newText as text
set AppleScript's text item delimiters to OldDelims
return newText
end searchReplace

-- Analyze URL subroutine
on stringToList for theString from stringDelimiter
tell AppleScript
set oT to text item delimiters
set text item delimiters to stringDelimiter
set outList to text items of theString
set text item delimiters to oT
return outList
end tell
end stringToList

-- HTML code
on HTMLcode(link, Title, Artist, Album, ArtworkFormat)
if ArtworkFormat contains "JPEG" then
set extension to ".jpeg"
set extension to ".png"
end if
set code to
-- HTML code deleted for blogging purpose, please download the complete installer/script to view the HTML code
return code
end HTMLcode


14 thoughts on “Aditunes – Make your duck sing!

  1. You can use the code to create any other script. For example, have iTunes create a (locally hosted) website with the current song, everytime a new song starts.

  2. BTW- I’ve been reading about your script, i’ve read on multiple places that AdiTunes is not Tiger supported, i would like to say that i’ve been using it in tiger seamlessly since juneish, if you dont mind a bit of chatting; what part of the code isnt supported by tiger?

  3. Hi, the link seems to work for me. I think the comments about Tiger were about older versions of AdiTunes. The 1.0 version should be working with Tiger. Let me know if you keep having problems with the link.

  4. The link doesn’t seem to be working for me either, it’s the “download” link on the plugin page who doesn’t work:
    I used to have this extra in adium but I had to reinstall adium on my computer a few month ago and lost all of my extras, I would really like to have this one back, it’s a great plugin!! Do you have another link?

  5. Copyright Infringement Laws – Torrents themselves aren’t banned, because there’s probably some
    legitimate items you can download with them.

    If not, then there should be an option to begin downloading again.
    The Tor software program is contained in the Vidalia program.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s