← Back to List

TwiTunes Applescript

added on Friday, Mar 09, 2007 18:34 pm

Credits

This is a combination of Coda’s Tweet Quicksilver script and some lines from Doug’s Applescripts. Big thanks to both!

Installation

Download and expand TwiTunes.scpt.zip and drop it into /Users/username/Library/iTunes/scripts/. If you are missing the “scripts” folder there, just create it.

Also, the scripts needs your Twitter password to be able to post to your account. It looks for it in your Keychain. If you have not already done so, log in to Twitter, and click to save it to your keychain when prompted. You will get an ugly error message and no post if the password is not found there.

How to use TwiTunes.scpt

Now you can start the script from the scripts menu in iTunes.

If you are using Quicksilver (and btw: you really should!) you can also invoke TwiTunes that way.

You will see the window below. Here you can change the tweet to “is freaking out to” instead of just “listening to”, etc. Press send, done!

Caution!

As any new communications technology Twitter is endangered by misuse. Please do not overdo it, nobody wants to read about every single track you hear. Keep it to just the really mind-blowing experiences, tracks your friends should really know about. Thank you!

Customize!

You can open the TwiTunes script just like any other in the Script Editor. Edit anything to your liking, for example change the default text, drop the dialog box and send directly, etc.

The Icon

is certainly done by myself. That was a great excuse to draw some birdie icon.

The Source

-- get properties of the playing track
tell application "iTunes"
set thisTrack to current track
set trackName to the name of thisTrack
set trackArtist to thisTracks artist
end tell
--
-- change the status message to your liking here:
set tweet to "is listening to "" & trackName & "" by " & trackArtist & "."
--
-- let the user edit
display dialog "Edit your Twitter status" with title "TwiTunes" default answer tweet cancel button 1 buttons {"Cancel", "Send"}
set tweet to (text returned of result)
--
-- get login from keychain
tell application "Keychain Scripting"
set twitter_key to first Internet key of current keychain whose server is "twitter.com"
set twitter_login to quoted form of (account of twitter_key & ":" & password of twitter_key)
end tell
--
-- post to twitter
set twitter_status to quoted form of ("status=" & tweet)
set results to do shell script "curl --user " & twitter_login & " --data-binary " & twitter_status & " http://twitter.com/statuses/update.json"
display dialog "Twitter Status was updated.
" & tweet with title "TwiTunes" buttons "OK"
blog comments powered by Disqus