• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!


AppleScript "Client"

Page history last edited by J Herskowitz 14 years, 5 months ago



I wanted to be able to use the track and artist name from the currently playing track in iTunes to automagically find/publish a free-range MP3 link for that track to Twitter. After digging around into AppleScript, I'm happy to say that I've got it basically working (see screencast).





This is the AppleScript (Mac only).  These scripts are far from elegant I know.  I'm hoping some of you have some ideas on how to clean it up a bit.


Playtapus.scpt.zip (free-range MP3s)

Playtapus Video.scptd.zip (YouTube music videos)

Grubapus.zip (posts metadata that Playgrub can consumer and send to Playdar)


Unzip the file and then place the script into (the source is also displayed at the bottom of this page):


(user) > applications > itunes > scripts (if the folder doesn't exist then create it)



To Use:


  • While listening to a song in iTunes, select the "Playtapus" script from the menu bar:



  • Enter your Twitter username and password (these currently are required every time you post a song - while painful it is useful when you have multiple and/or test Twitter accounts)



  • Your browser will then attempt to open a confirmation page (this is not desired but merely the way it is currently implemented).  If the page shows a result then your song was succesfully tweeted (with link to a hosted MP3 for that song).   If the page displays no results, then a match couldn't be found on the web - don't worry, in this case nothing has been tweeted on your behalf.



  • It will show up on Twitter within about 20 seconds.  Clicking the shortened URL, your followers will be able to listen to the song you just posted.  (Note:  Sometimes the links will be bad or dead links, this is a limitation of the current MP3 search results.)  This works in virtually all Twitter clients (AIR, iPhone, native, etc.).



  • If your followers are using Twitter's web interface (instead of a twitter client), they can then use the playTwitter bookmarklet and simply click it to spawn the javascript player.  It will embed play icons next to any/all songs that have been tweeted and open a player at the bottom of the page.





Needed Improvements:


  • Eliminate opening of browser window confirmation
  • Optionally return result to user for validation before posting
  • Optionally retrieve/store Twitter credentials in Keychain
  • Turn into real Menu bar/Systray application(s) - including support for multiple media players (e.g. Winamp, Songbird, Windows Media Player, etc.)
  • Roll back to YouTube video matches if no good free-range MP3 matches are found
  • More...




AppleScript Source


Below is the source of the script too:



"Share Track on Twitter" for iTunes

written by J Herskowitz


v1.0 march 5 2008

-- initial release


set baseURL to "http://pipes.yahoo.com/pipes/pipe.run?_id=12691e2678b37d459a55ee46cf4904cd&_render=rss&"

-- get properties of the playing track

tell application "iTunes"

    set thisTrack to current track

    set trackName to the name of thisTrack

    set trackArtist to thisTrack's artist

end tell

-- get login info

display dialog "What is your Twitter user name?" with title "Playtapus" default answer "Username" cancel button 1 default button 2 buttons {"Cancel", "Enter"}

set twitter_user to (text returned of result)

display dialog "What is your Twitter password?" with title "Playtupus" default answer "Password" cancel button 1 default button 2 buttons {"Cancel", "Send"} with hidden answer

set twitter_password to (text returned of result)

set twitter_login to twitter_user & ":" & twitter_password

tell application "Finder" to open location (baseURL & "artist_name=" & trackArtist & "&track_name=" & trackName & "&TwitterName=" & twitter_user & "&TwitterPass=" & twitter_password) as text




Comments (0)

You don't have permission to comment on this page.