Midem Music Hackday 2013

January 29, 2013 § Leave a comment

Carrying on from my post on the Mint site, I wanted to share a little more information on what I think was the coolest part of my MIDEM Music Hackday hack – the technology.

But first a quick recap of the idea for those in the dark:

To answer the question “what do you listen to?” I created an app that analyses your recent listening history and awards Artist, Genre, Guilty Pleasure and Hipster badges based on certain criteria.

With that out of the way…

The Tech
While the idea itself is hardly revolutionary, and the website itself is not quite all there (it would have looked a lot less pretty if hadn’t made those beautiful badges for me. Thanks again, Ben!), I tried something new on the back-end. The application is built in Rails, and contains 2 models – the User model and the Badge model – which run to 18 and 5 lines respectively. As I haven’t hooked up all the moving parts (you’ll notice I triggered everything from the command line in ), there are no real controllers. The traditional Rails code is so minimal because I made a real effort to pull “business logic” out into lib classes. This is the first time that I’ve really tried to do this, and I really tried to push the concept as far as I could. My ./lib folder looks something like this:


lib

├── badge_calculator.rb
├── echonest.rb
├── emo_badge.rb
├── fan_badge.rb
├── fetcher.rb
├── genre_badge.rb
├── guilty_pleasure.rb
├── hipster_badge.rb
├── listens.rb

I’ve omitted standard Rails boilerplate stuff, but you can see that there is a lot of logic in here. `badge_calculator.rb` kicks off the calculation process, and calls the calculate method defined in the classes of each badge, each of which is held in the appropriately named file. `fetcher.rb` does the fetching of the Last.fm data and Listens is a class that allows me to load that data in a nice Ruby format.

The result is highly modular code that was easy to test. I still need to push it further – all the badges should inherit from some kind of base badge class, and each badge duplicates pretty much the same awarding logic, which should be pulled out into a new class.

All in all I learned a hell of a lot in how to design a system like this. I’m sure it won’t be suitable in every situation, but it’s certainly something I will be doing more of in my work at Mint.

I also created a small Ruby gem to wrap the Gracenote Web API. It only does what I need it to right now, but I’ve stuck it up on GitHub so if you want to extend it, please do!

What next?
I still plan to work on this, make those changes mentioned above and hook everything up. When that’s done, I’ll push the app live and you can give it a go. I’m really interested in trying out the Facebook listens stuff too.

I’d love to hear any feedback. Do you love it? Hate it? Have an idea for a badge? Let me know.

Thanks again to , the MIDEM crew, SoundCloud all the participants and anyone that asked us questions, stopped by to say hello, or were confused about what the hell we were doing. You all made it a really, really great event!

Leave a Reply

What’s this?

You are currently reading Midem Music Hackday 2013 at Logical Friday.

meta

Follow

%d bloggers like this: