This post is part of Monetate’s (Work) Week of Wow. Each workday this week (Monday through Friday), our Engineering Blog will present a wow-worthy project by our software engineers.
Listening to Lynyrd Skynyrd? Then you’ll want to accompany it with “The Lynyrd Skynyrd“: 1 ounce of Canadian club whiskey and 1 ounce of coffee.
More in the mood for Nicki Minaj? Try “The Nicki Minaj“: 10 ounces of vodka, 10 ounces of Fassionola, and 8 ounces of orange juice. Combine in highball glass and serve. Garnish with sugar.
Blasting Justin Bieber’s latest album? Then you’ll want to drink “The Bieber“: a bottle of hand sanitizer.
These drink recommendations (okay, just the first two) are courtesy of Drinkify.org, a fun little site created at Music Hack Day Boston 2011.
The only down side to the service is that if you’ve got a playlist of multiple artists, it’s kind of a pain to constantly return to the site to determine what you should be drinking for the next three to six minutes.
To solve this problem, Monetate backend developer Jason Stelzer hacked together a little application that allows you to receive Growl notifications of Drinkify.org recommendations, based on an iTunes playlist. (Written, he says, one Sunday morning over mimosas.)
You can check out the project on GitHub.
In case you’re curious about the technical details, the application consists of two Python files: one that runs in the background, which uses appscript (a bridge between Python and Applescript) to check iTunes every 10 seconds to determine the currently playing song, and another that uses scrapy (a web-scraping framework) to fetch the Drinkify.org recommendation and displays it as a Growl notification.
Here’s how simple it is to interact with iTunes using appscript:
itunes = None
itunes = app("itunes")
print "Itunes is not running"
if itunes and itunes.isrunning:
track = None
track = itunes.current_track.get()
print "No current track playing"
artist = track.artist.get()
So load up your favorite playlist and get out your cocktail shakers — just remember to drink, and listen, responsibly.