Add comments to iTunes tracks via Salling Clicker

Sep 14, '05 10:11:00AM

Contributed by: dednor

I've recently become so embedded in the Salling Clicker/iTunes/AirTunes combination that I wanted to try to find an easy way to add comments (to serve as meta-data for smart playlists) to the current track that's playing in iTunes. In doing this, I modified the Salling Clicker "iTunes Remote.scpt" in the following way.

This mod allows me to add comments like "Mellow," "Dinner Music," etc. to the current track playing in iTunes, so that I can easily build better, more dynamic smart playlists. This is how I organize most of my playlists, and it's pretty clear the advantage of doing so. Now it's even easier to cram in more information on the fly.

I'm relatively bad at writing AppleScript (still), so suggestions are welcome. First, under the Salling Clicker preference pane, edit the iTunes Remote Script. You should, of course, make a backup before you start chaing things -- this should be a no-brainer!

  1. You'll need to modify the large else if statement under the block associated with the ratings (in the key_was_depressed function). My additions happened to look like:
    else if keyCode is ("6" as Unicode text) then
        set thisCommentAddition to "Mellow"
       my addCommentData(thisCommentAddition)
    else if keyCode is ("7" as Unicode text) then
     set thisCommentAddition to "Dinner Music"
         my addCommentData(thisCommentAddition)
    else if keyCode is ("8" as Unicode text) then
     set thisCommentAddition to "Joe Only"
     my addCommentData(thisCommentAddition)
    else if keyCode is ("9" as Unicode text) then
     set thisCommentAddition to "Deb Only"
     my addCommentData(thisCommentAddition)
    else if keyCode is ("*" as Unicode text) then
     set thisCommentAddition to "Re-rip"
       my addCommentData(thisCommentAddition)
    else if keyCode is ("#" as Unicode text) then
     set thisCommentAddition to "Needs Artwork"
        my addCommentData(thisCommentAddition)
    else if keyCode is ("0" as Unicode text) then
     set thisCommentAddition to "Relevant"
     my addCommentData(thisCommentAddition)
  2. You'll need to add the addCommentData function to the end of the script file:
    on addCommentData(commentAddition)
      tell application "iTunes"
        set thisComment to comment of current track
        if thisComment is equal to "" then
          set thisDelimiter to ""
        else
          set thisDelimiter to ", "
        end if
        ignoring case, punctuation, hyphens and white space
          if thisComment contains commentAddition then
            tell application "SEC Helper"
              show screen message my currentOSDTrackInfo() ¬
              & return & "Already has " & commentAddition ¬
              & " Tag, skipping track"
            end tell
          else
            set thisComment to thisComment & thisDelimiter ¬
            & commentAddition
            set comment of current track to thisComment
            tell application "SEC Helper"
              show screen message my currentOSDTrackInfo() ¬
              & return & "Added '" & commentAddition & "' Tag"
            end tell
          end if
        end ignoring
      end tell
    end addCommentData
    
  3. If you want to have keys like 0, *, and # work, then you'll need to disable their default functions in the key_was_depressed and/or get_keymap functions where appropriate.
I think that's all ... I hope I didn't forget anything. Good luck.

Comments (2)


Mac OS X Hints
http://hints.macworld.com/article.php?story=2005091121172247