1 post tagged “code”
So this morning the dogs decided that they really needed to get up at 6:30am. I convinced them they could wait until 7. Still, 7am on a day off is pretty early. Anyway, it was 7am and I was wide awake. I'd been wanting to track views on my Flickr photostream for some time now. I started keeping a Google spreadsheet, but there was no way I was going to keep that up. This was clearly a task that needed automation and now was as good a time as any to start.
Step One: Check the API
The last time I checked the Flickr API didn't have a way to get this particular piece of information. Turns out that it has been added to flickr.people.getInfo, but you only get it back if you are making a signed call on your own userid. That's okay, because that's all I wanted to do.
Step Two: Decide on a language
I honestly haven't written much (any?) code at work lately. Scott does the lion's share of that. Perl? Bleah. I'm sick of perl. PHP? I wasn't looking to make a web application out of this. Python? Not a huge fan of the snake, but beej does have API kit for python. Screw it...ruby with rflickr.
Step Three: Write code
Holy crap, how do I do this again? Yes, it's been a while and I'm not in the rails environment...just straight up ruby. I get all the auth/frob stuff out of the way and then what do I discover? The rflickr package doesn't support getting photostream views. Oh well, a quick hack to the source and we're on our way.
Okay, I have my views...now where do I put them? I could just append them to a text file. No, that sucks. It's way too easy. I decided I would take a crack at using ActiveRecord outside of rails. Okay, I finally get that wired up and put an @hourly cron job in and I'm done. Well, except that it does absolutely no error checking. It's disgusting code that I wouldn't wish upon anybody.
158,883 as of 2006-11-24 16:00:11. I'm sure you were just dying to know.