In the article I’ll explain how I use iTunes and my Mac to do DJ preparation whilst working – quickly adding tracks to playlists while listening.
Why I made it
I spend a lot of time working on my computer. When this work is non-audio I listen to music using iTunes on my Mac.
I wanted a quick way to add the currently playing piece of music to an iTunes playlist of my choice. Manually switching to iTunes interfered with my focus on the work I was doing, and took too ling, so I looked for a faster way to do it…
What it does
At the press of a keyboard button I can bring up a list of all iTunes playlists and double click one to add the currently playing track to that playlist.
Notifications are sent to the OS X Notification Centre to tell you if the track has successfully been added or not.
To achieve this I have created an AppleScript and set it to launch when I press key F7. You can use your favourite app launcher to trigger this using a keyboard key or you could put it in your dock etc. My recommended app launchers are: FastScripts and Alfred.
Download the ready to run Mac OS X app here:
Download the app (.zip) »
App Tips:
Add an icon to the app. I copy the iTunes icon so that the notifications are easily identifiable as music ones.
- Find iTunes.app in your applications folder
- Right click on iTunes.app
- Select ‘Get info’
- Left click on the iTunes icon at the top left of the ‘Get Info’ window.
- cmd + c to copy this icon.
- ‘Get Info’ on the app you’ve just downloaded form here
- Left click on the icon at the top left of the ‘Get info’ window for the new app
- cmd + v to paste the iTunes logo
- Now this app will have the iTunes logo!
Feel free to use the code however you want- here is the AppleScript code
-- iTunes DJ Script - edited by https://acidfudge.uk tell application "iTunes" set thePlaylists to (name of every playlist) end tell set currentApp to current application tell currentApp activate set thePlaylist to (choose from list thePlaylists with prompt "Select a playlist:" OK button name "Choose" cancel button name "Cancel") as text end tell --exit if they didn't enter anyting if thePlaylist is "false" then display notification "You didn't choose a playlist" with title "Unsuccessful!" if thePlaylist is "false" then return --make sure itunes is running set okflag to my itunes_is_running() if okflag then tell application "iTunes" if player state is not playing then display notification "No track is currently playing." with title "Unsuccessful!" set oldfi to fixed indexing set fixed indexing to true set thisTrack to (get location of current track) set dbid to (get database ID of current track) if thePlaylist is not "false" then set currentList to playlist thePlaylist --see if the track exists on the playlist set currentIDs to {} try if exists (track 1 of currentList) then -- if there are some tracks - at least one -- get their ids copy (get database ID of every track of currentList) to currentIDs -- list end if on error errText number errnum if errText does not contain "Invalid index." then error errstr number errnum end if end try --add the track to playlist or show error if currentIDs does not contain dbid then -- if id not already present add the track add thisTrack to currentList display notification "Track added to playlist '" & thePlaylist & "'" with title "Success!" else display notification "The current track has previously been added to playlist '" & thePlaylist & "'" with title "Unsuccessful!" end if set fixed indexing to oldfi end if end tell end if on itunes_is_running() tell application "System Events" to return (exists process "iTunes") end itunes_is_running -- iTunes DJ Script - edited by https://acidfudge.uk
Credits: I edited this script from a similar one that I found while searching the Internet a few years ago. I have since forgotten where I found it so if you are the original author please contact me so I can credit you here.
If you find this article useful, please post a comment saying so, or if you have any feedback I’d love to hear it. You can use the comment form at the bottom of this page. Thanks 🙂
Leave a Reply