# Random 10 and accounting for taste

Tomorrow being Friday, there will be a lot of bloggers posting “Random Ten” lists of songs from their iPods or computers. I thought it would be a public service for me grace the Internets with my good taste in music, so I began casting about for an AppleScript that would pull such a list out of iTunes. To my surprise, Doug’s Scripts didn’t have one and my Google search also came a cropper. Apparently, the folks who put up these lists do it by hand! Well, that just won’t do for me, so I banged together the following AppleScript:

tell application "iTunes"
set p to  playlist "****"
set songlist to (get name of every track of p)
set artistList to (get artist of every track of p)
set albumList to (get album of every track of p)
set textlist to ""
repeat with i from 1 to 10
set textlist to textlist & i & ". \"" & ¬
item i of songlist & ¬
"\" by " & item i of artistList & "
from *" & item i of albumList & "*
"
end repeat
set the clipboard to textlist
end tell


I called it “Ten From Playlist” and put it in ~/Library/iTunes/Scripts’. It gets the first ten songs from the playlist I usually listen to, formats them in a Markdown list, and puts them on the clipboard. Because I have the folder it’s in cataloged by Quicksilver, I can run the script with a few keystrokes while I’m writing my post—no need to switch back and forth between iTunes and TextMate.

If you post in HTML instead of Markdown, you could easily alter the long set textlist... line to put in explicit <li></li> and <cite></cite>` tags.

I wrote about how the “****” playlist is made in this post. It’s a smart playlist that

• is shuffled,
• has only songs I haven’t played in the past week, and
• excludes the crap in the iTunes Library that my wife, daughter, and son put there.

The exclusion may be violating the letter of the “Random Ten” rules, but I think it’s within the spirit, as these are the songs I actually listen to.

So here goes.

1. “My Generation” by The Who
from Live At Leeds
2. “Is That All?” by U2
from October
3. “Wild Horses” by The Rolling Stones
from Sticky Fingers
4. “Folsom Prison Blues” by Johnny Cash
from The Essential Johnny Cash 1955-1983 (Disc 1)
5. “Mr. Bad Example” by Warren Zevon
from Genius: The Best of Warren Zevon
6. “Through With You” by Maroon5
7. “Paths That Cross” by Patti Smith
from Land (1975-2002) (Disc 1)
8. “Pony Blues” by Charley Patton
from The Blues - A Smithsonian Collection of Classic Blues
9. “I’ll Tumble 4 Ya” by Culture Club
from At Worse…The Best Of Boy George And Culture Club
10. “Flying” by The Beatles
from Magical Mystery Tour

Well, that looks pretty good. I won’t apologize for the Boy George.