Hacking Flickr

So, thanks to a problem I had with rigging up Nick in “Sugar“, I’ve temporarily lost interest in animation.  This happens to me all the time, and I think I’ve mentioned it before in previous blog posts that I’m too lazy to look up before that I tend to gain and lose interest in my hobbies.  For example, I haven’t touched the Wii since I beat Mario Galaxy during Christmas and until this recent problem with “Sugar” happened, I hadn’t done any programming in about a year.  Even my interest in photography has ebbed so much that I let my subscription to Digital Camera Magazine lapse. 

My latest hobby to pick up again is programming.  I recently updated my Pydvdauthor software (since I had to make another DVD), worked on a Vietnamese Zodiac predictor, and now I’m hacking Flickr.  It’s just the way my mind works that when I get into a certain hobby, my creativity takes me to places that I never even had the smallest thought about previously.  Case in point, I knew that flickr had an API, but I never cared to mess with it.  I saw the mashups people were producing and I didn’t think that I wanted to do any of those.  However, those mashups are just the visible “web 2.0” stuff you can do with the API.  After a greasemonkey script (which I just started using) showed me that the API could detect whether or not my photos were in a certain group, a seed was planted.

Suddenly, out of left field today I get the idea to hack on the API so that I can tackle what I have considered one of my greatest annoyances in flickr – maintaining my participation in the Views: xx groups.  These are groups where you add in photos that have xx number of views and keep them there until they reach the next threshold.  It’s fun to watch and it gets more people to see your photos.  But until now I’ve had to manually go into each Views: xx group and then click into each photo to see if my photos were ready to move on.  This was excruciatingly slow!  But now I’m working on a program that will automatically detect this for me and let me know.

It only took me a few hours today and most of that was figuring out how to use the Python interface that some groovy programmers have written to help smooth things out.  I’m using Beej’s Python Flickr API and I find that it works extremely well.  Of course, it also helps that flickr has designed a WONDERFUL API interface page.  I’ve only done programming on two APIs so far – Google and flickr and I must say that flickr wins hands down!
 
Flickr’s services page has all the information you could possibly need to program on their API.  Here’s a great example of how well their API pages are written.  But even better than just having make-believe sample code is the API explorer they have on each of their APIs.  This takes you to a page that allows you to put in the same parameters you’d put into your program and see ACTUAL output!  Not only that, but they give you sample values on the right-hand side!  This is an API documentation in a class of its own.  If you look on this page you’ll see that easy programming is in no way constricted to Python.  If there’s a programming language you like, there’s probably an API kit for you.  They even have Lisp and REAL Basic!

So, here’s what my program does so far, after, as I said, a coupe to a few hours of hacking:

Status: ok
Title:  Clocktower Cornell 3    Views:  36      URL:  http://www.flickr.com/photos/ericsbinaryworld/8848073/
Title:  Clocktower Cornell 5    Views:  42      URL:  http://www.flickr.com/photos/ericsbinaryworld/8848074/
Title:  Kite Beach Day 1        Views:  39      URL:  http://www.flickr.com/photos/ericsbinaryworld/8770150/
Title:  Kite Beach Day 33       Views:  39      URL:  http://www.flickr.com/photos/ericsbinaryworld/8770151/
Title:  Kite Beach Day 49       Views:  38      URL:  http://www.flickr.com/photos/ericsbinaryworld/8770711/
Title:  The Raspberry from a kid who's not even 1!      Views:  37      URL:  http://www.flickr.com/photos/ericsbinaryworld/2165313220/
Title:  seagull5        Views:  37      URL:  http://www.flickr.com/photos/ericsbinaryworld/8823393/
Title:  Kite Beach Day 52       Views:  44      URL:  http://www.flickr.com/photos/ericsbinaryworld/8770714/
Title:  Kite Beach Day 53       Views:  43      URL:  http://www.flickr.com/photos/ericsbinaryworld/8770715/
Title:  seagull2        Views:  31      URL:  http://www.flickr.com/photos/ericsbinaryworld/8823392/

Now, this looks nicer on my computer than it will on this blog because the current blog theme I have only gives me 500 pixels for each post whereas on my screen I have a lot more space.

So, what are we seeing here?  These are the first ten photos I have in the Views:  25 group and you can see that none of them are ready to move to Views:  50.  I gave myself the URL so that if I needed to move it to the 50 group, I can.  

So what’s next?  Well, before I blogged this, I put everything into functions instead of one long series of commands so it should be quite trivial for me to add in all the rest of my Views groups.  After that it’s a matter of whether I want to move them into the new groups manually via following the URL or if I want to do it automatically via the script.  Yeah, the API is that powerful!

Current issues with my current methods are that I think I’m limited to 50 API queries per hour.  No problem, I’d just have to split my views groups into different scripts or load them in a commandline parameters. 

This has also sparked my interest as I’ve often found it annoying to load a bunch of pictures I’ve just uploaded into a bunch of groups.  It takes a lot longer than it should – I’ve always wanted a checkbox so I can do all of the groups at once.  Well, with the API, I just may be able to do this!  Yippie!

Yay for hacking!

Blogged with Flock

Tags: , , , , , , ,

Author: Eric Mesa

To find out a little more about me, see About Me

2 thoughts on “Hacking Flickr”

Comments are closed.