January 20th, 2007

fox yawn

Flickr scripting Friday

West Lake

While scripting Flickr, one revelation just led to another and another and so on. Yesterday, I figured out why the script wasn't seeing all of the group pool. Some users were posting non-public photos to the pool. As admin, I see those, of course, but the script wasn't getting them in the photo list. The reason? I didn't add the authentication token correctly. Okay, so I fixed that. The script still wasn't retrieving those photo pages! (In order to get the view counts, of course. Nothing evil there. However, people really should not be posting non-public photos to groups. What's the point in doing that anyway? Aren't they aware that all the admins can see those photos?) The reason for that was pretty obvious. The script's user agent hasn't logged in.

As I was searching the web for a good way to do that, hopefully a script where someone else had already done the work, I came across WWW::Mechanize. This is one amazing module! In just a few lines of code, I had the script fill in the Flickr login form, submit it, and follow the redirect thrown back by Flickr to get the login cookie. From there on, it retrieved those pesky photo pages with no further problems.

And now, I get to run the script all over again on the views group pools to moderate the photos it missed the first twenty or thirty times I ran it. Uhh... maybe in a week's time when it'll actually have something to chew on.

Nothing much else done today aside from work. I did get out to Quiznos in Ramsey for a honey bacon club.

Friday FiveCollapse )