A busy week coding Flickr Downloadr, messing with jflickr bugs and and being offline

Jul 16, 2007

I’m wrapping up a week that was kinda busy for me, even though I didn’t put too much time in my blog or anything else visible. I’ve still got to write some posts about my past travels, and then this weekend I went to the zoo :) one of the best that I’ve been to – and I’ve been to quite a few. I’m just uploading the pics now. I also did some repairs and shopping for our Luxembourg residence and went to see Die Hard and what not…

… but what I wanted to get to was that I mostly spent the week coding and packaging things up. I had to submit some code samples to my grad school to show them that I can program at some level, and so I’m sending them an old code sample (Moodgeist Pinger for Mac written in Objective-C if you have to know) which I documented and polished a bit. I also did a new thing.

The new thing was a simple Flickr Downloadr in Java whose mission is simply this: it lets you download complete photosets from Flickr, both for yourself and for other people. And the fun part about doing it in Java is that you get a truly multiplatform experience and stay on fairly high level with the code. I guess another way of doing multiplatform would be in Trolltech’s Qt, but then you’d have to work with C/C++ and worry about memory management and such and C really isn’t where I’m best at.

Here’s the Downloadr running on Mac OS X, Windows and Linux.

Now… why pick such a task? And why do it only half-way, leaving out authentication and photos not in a photoset and such?

Two reasons. First, I wanted to limit my scope, leaving out authentication and photos not in a photoset etc. This gave me smaller code size (I had some size guidelines from school) as well as a simpler UI.

The UI also brings me to the second point, which is – yes, the Downloadr has been previously done many many times. For different platforms. And even in Java. But I found that I didn’t like the previous implementations. Either they had a stupid UI – like, I don’t really care for thumbnails if I just want to download the goddamn complete set – or they actually didn’t work with the Flickr API properly, which is even worse, as you’ll end up with incomplete downloads and sets. By default, Flickr returns up to 500 results per query, e.g up to 500 photos per set. And some sets may easily have more (such as some of my own, which I couldn’t properly download with previous Downloadrs, which was part of the motivation for doing this Downloadr in the first place). So you’ll need to implement proper paging in your Downloadr to properly work with this limit (doing multiple queries per set if needed).

Many thanks to people doing the flickrj Java Flickr API, which I used. It’s a great API for working with Flickr in Java – once you manage to work around its bugs. Some of the method signatures don’t match in source, documentation and published binary version. For example, the signature of com.aetrion.flickr.photosets.PhotosetsInterface.getPhotos differs in the published API binary 1.0b3 and what you see in the source for 1.0b3, with the source being correct. I suspect they’ve not updated the published binary – so I ended up just grabbing the source and building my own 1.0b3, which worked fine and dandy.

I’m not sure if I’ll publicly and “properly” release the Downloadr – I don’t want to deal too much with versioning and maintenance and such. If you want, you can ask me for it and I’ll happily send it to you for now. You’ll need the Sun Java environment to run it, as I’m using Sun’s AWT and Swing classes for UI and it probably won’t work anywhere else.

I must say that it was a pretty good multiplatform experience and also a good one to work with a “web 2.0” API. Once I got around the quirks, everything worked as it was supposed to, and the Flickr API is quite convenient to work with through such a nice wrapper. And Java also has a nice Skype API, so maybe my next Java project would be the del.icio.us and Skype chat mashup requested by Sten, as I know people on both Mac and Windows who would use it. But I probably won’t do it as I can’t see the time before the end of the competition. But should check out Java Skype API nevertheless, and perhaps do an alternative Moodgeist pinger in Java or some other experiments.