Finding concerts with PowerShell and BandsInTown
The move to St. Louis was a success - nothing was broken in transit, and I’ve settled in pretty well. Now the game begins again! Let’s find suitable St. Louis alternatives to my favorite Rochester things. One area that is sorely lacking is upcoming concert schedules. My go-to source in Rochester was the WBER Concert Schedule. Unfortunately, it doesn’t appear that there is an easily parsable alternative in St. Louis.
I stumbled upon BandsInTown, but the forced integration with Facebook, and horrible perma-banner telling me to install the Facebook app quickly turned me off to the site. That’s a true shame, because in general the information looked up-to-date and easily searchable/parsable. I toyed with the idea of seeing if they had an rss feed I could use - when lo and behold, it turns out they have a REST API! Time to dig out my PowerShell skills and do something with this.
First off, they require no authentication, but ask for an app_id. Fair enough! My app will be called “wat”. With that in mind, here is a simple REST GET call to retrieve all events that NOFX is playing in the near future:
That’s pretty good, but let’s throw that in PowerShell. I can use
Invoke-WebRequest to get the proper api_version and app_id variables set, then use that for the
There appears to be a ton of information in that
$events variable (namely an array of events. Parsing JSON is very easy with PowerShell, so let’s take a look at the first event:
This event is taking place on 9-12-2014, in Humboldt Park, IL. Tickets are still available. That’s nice, but I’m not in Humboldt Park, I’m in St. Louis. I could individually call the rest of the 16 shows and look for St. Louis, but that’s not a good use of my time. Let’s provide this with a target city:
Let’s give that a shot. . . Oops, no output. I guess they’re not playing in St. Louis. Rather than guess if the process failed or not, I’ll put in a helpful message driven by the new
You may have noticed that I also parameterized the $TargetBand in that last sample - it enables me easily do things like search for multiple bands:
That’s it for today. In the next iteration, I’ll be looking to integrate with something like MapQuest’s API to set alternative cities - maybe I’d be willing to drive to Chicago for NOFX, but I definitely wouldn’t for Taking Back Sunday. I’ll also be cleaning up the output to make it more portable/emailable.