Archive for November, 2010

Step 1: Hacking Pandora or My First run in with security!

Tuesday, November 2nd, 2010

My first step in the audio project was to see if I could actually figure out a way to control Pandora.  If you’re not aware, Pandora is an incredible music service which allows you to create “stations” based on music that you like.  It will then play other songs that it thinks you might like.  You can thumbs up or down songs and it will refine the songs it plays accordingly.

Anyway, I need to be able to change the stations remotely from a web interface on my phone.  To do that I searched for an API of some sort.  This was hard because the only thing I was able to find was a reference to a 2.0 api but no further details.  I eventually gleaned that this “API” was actually an undocumented set of javascripts accessible from the pandora site.  The javascripts are actually what Pandora uses to control content.

I read through the js files and realized that if I could get some of the javascript functions to execute that I would be in great shape.  Pandora allows you to switch stations from your profile page.  Although the player itself is a flash object which is inaccessible by the average bear (mostly me) the profile page is straight HTML.  It has links that execute js which changes the player on the player page.  My first idea was to create an html frameset.  From one frame I would execute the js in the frame that holds the pandora profile info.  Well, of course that was a waste of time since I quickly figured out that javascript security will not allow a script from one domain to execute a function from a script in another domain.  Good to prevent hackers, bad for me!  Strike one.

I was undeterred.  I use Firefox and am a big fan of the greasemonkey plugin.  The Greasemonkey plugin allows you to manipulate a page as it is loading and before it renders.  You can add or remove elements, and all kinds of other shenanigans.   Before you could wash a greasy monkey I had injected a little js in the page which would execute the pandora function for changing the currently playing station.  A few more lines of code and I was able to add an HTML parameter to the url of the profile page with the pandora station ID, and strip that out with greasemonkey and embed it into the pandora function I had gotten to work previously.  So now a url www.pandora.com/profileurl/?sttn=09990089899 (not a real url) for example, would cause the pandora player to switch to the station associated with the id 09990089899.  It was magical, and life was good.  Now I just have to figure out the rest of the stuff.  Detail, details.

Rube Goldberg was here

Monday, November 1st, 2010

I have started to explore my interest in electronics and have been reading and watching with eager eyes all of the possibilities that exist with modern electronic DIY. It’s pretty incredible. To this end I have come up with two projects that I think will be a lot of fun, and useful to me. The first is a home audio distribution system, the second is a home video distribution system.

Here are the specs for the Audio distribution system:

I have speaker wire that I have run throughout my house, I even have speakers in my kitchen ceiling. I have yet to wire any of this stuff together though. I want to hookup the kitchen speakers, and put in some patio speakers, and connect them to some sort of audio system. It has to be cheap (because I can’t justify the $1000+ expense of an audio system for this purpose) and it has be controllable from a device, such as my iPhone or my wife’s iTouch.

Here is my initial idea:

  • Setup a laptop running pandora
  • Buy/Build an audio amplifier/ controller that can support multiple rooms
  • Build some electronics that can control the amplifier
  • Interface the electronics to the laptop
  • Build a web interface to the computer that will allow me to change stations on pandora, and control the audio and room settings
  • figure out how to control pandora via said web interface
  • figure out how to control the amplifier through the web interface

I’m sure I’m missing something, but I’ll detail my progress as I go. The video distribution is something I will tackle later, but a lot of the same requirements hold through.   Seems fun, and really challenging considering I have never ever even soldered a piece of electronics in my life.  Yay!