Can I auto-seatch for guitar tabs?
May 3, 2009 6:53 PM   Subscribe

Can I somehow create a program (a Bot?) to automatically start a Google search of Pandora and/or Last.fm songs as they are playing?

My apologies if a similar question has already been posted-I really don't even know what this is called and therefore could not search for it.

I really enjoy pulling up guitar tabs as songs play in Pandora so I can play along with them, but it takes awhile to re-type the song into Google search to find the tablature. If I am listening to Last.fm, I cannot pause the song while I search for the tabs. This means that while I am hunting, the song continues to play and by the time I find and start playing along the song is almost over. What would be great is if a new tab pulled up in Firefox automatically as each song started ( + "tablature").

I know this is somewhat trivial (and makes me sound lazy I am sure), but I am as curious about learning about how to "automate" my searches as I am interested in solving this particular problem...does this sort of thing even exist? By the way, I don't even really know what a "Bot" is, obviously-is there somewhere I can become more familiar with this subject?

Thanks!
posted by jaseaco to Computers & Internet (2 answers total) 1 user marked this as a favorite
 
Best answer: Pandora has an "events" API available in the form of a Javascript file, at http://www.pandora.com/include/PandoraAPIv2.js. You can use it to invoke a callback function when songs are played or paused, or when new stations start. Pandora passes back the song title, artist, album art URL, and Pandora URL for the song, within a Javascript object literal.

Creating an app from that is pretty simple, and something like this should do the trick for your Google searching:
Pandora.setEventHandler("SongPlayed",
     function(songdata) {
          var artist = songdata.artistName;
          var song = songdata.songName;
          window.open("http://www.google.com/#hl=en&q="+artist+"+"+song+"+tablature");
     }
);
Paste that into your Firebug console (www.getfirebug.com) when you're at pandora.com, and hit enter. Ought to open a new tab or window with your Google search every time a new song plays.

Alternatively, create a framed setup that has Pandora in one frame and in the other frame, include the events API javascript and this function. Then, rather than going to Pandora, you could go to your framed site. Pandora would run nicely, and your Javascript would execute every time a new song plays.
posted by sellout at 10:38 PM on May 3, 2009


I guess I should also note that the events API is included within the Javascript that loads on Pandora.com by default, which is why Pandora.setEventsHandler can be called like this in Firebug, without adding any other extra code.
posted by sellout at 10:41 PM on May 3, 2009


« Older webhosting blues   |   How late can I pay a power bill? Newer »
This thread is closed to new comments.