Flickr provides an API for which there are numerous language bindings. A binding for Lisp was, however, missing, and because I wanted to write an application for automating some tasks in Flickr (more on that later on), I decided some time ago to start by implementing bindings to the Flickr API for Common Lisp, aptly named “Clickr”.
Instead of telling you how great my bindings are I think it’s best if I just demonstrate how they work:
Let’s get my Flickr user first and see what my name is:
CL-USER> (defvar *schani* (user-with-name “schani”))
*SCHANI*
CL-USER> (user-realname *schani*)
“Mark Probst”
How many favorites do I have?
CL-USER> (length (user-favorites *schani*))
1675
Every bit of information that Clickr gets from the API is stored. If you request it again, Clickr will used that stored information instead of making the same API calls again. Also, every Flickr object that Clickr knows about corresponds to exactly one Clickr object. If you get, say, the same photo via two different routes, Clickr will give you the same photo object twice.
Let’s do some more complicated stuff! What’s the number of users whose photos are in my favorites?
CL-USER> (defvar *fav-users* (remove-duplicates (mapcar #’photo-owner (user-favorites *schani*))))
*FAV-USERS*
CL-USER> (length *fav-users*)
805
How many of those have faved at least one of my photos?
CL-USER> (length (remove-if-not #'(lambda (user)
(find-if #'(lambda (photo)
(eq (photo-owner photo) *schani*))
(user-favorites user)))
*fav-users*))
183
This last query makes a huge number of API calls, so try it at your own risk! The second time you do it, though, it’s lightning fast!
Clickr can even provide you with some information not available through the API:
CL-USER> (photo-num-views (first (user-photos *schani*)))
127
CL-USER> (photo-num-faves (first (user-photos *schani*)))
3
I need that information for my little application, and since the Flickr API still doesn’t provide it, Clickr has to fetch the photo page and extract those numbers from the HTML code.
On to my application, which I’ve called “Automatr”! There are lots of groups on Flickr, like top-f or top-v, whose only posting requirements are that your photo fulfills some simple “counting” rule. In the case of top-f the rule is that you can post any image provided that it has at least 25 faves. Being very lazy I wanted a tool that did those posting jobs for me automatically, which is why I wrote Automatr.
Right now Automatr can do five things: Adding and removing tags, adding and removing photos to and from groups and adding photos to sets. Let’s look at the simplest job, adding a tag! Let’s say that I want to add the tag “top-f25” to all my photos which have at least 25 faves. Here’s the Automatr rule for that:
(add-action ‘add-top-f25-tag
‘(add-tag “top-f25”)
‘(>= (count faves) 25))
The first argument is just the name of the rule and can be anything. The second argument is the action and the third argument is the condition under which the action is to be applied. Of course Automatr is smart enough not to try to add the tag a second time, so it’s not necessary to specify that only photos without that same tag be tagged.
Groups are more complicated in that they need to be declared first. Here’s the declaration of the top-f group:
(defgroup ‘top-f
“23561440@N00”
:max-batch 1)
The main argument here is the ID of the group. The easiest way to get to it that I know of is to look it up in the HTML source of the group page. Yeah, it sucks. Clickr should be able to do that automatically if you provide it with the group URL, but I was too lazy to implement that. Anyway, the “max-batch” argument specifies how many photos Automatr is allowed to add to that group in one batch. In this case it’s one, meaning that even if I had a hundred photos eligible for entry, Automatr would post only one, determined at random. Here’s the rule for posting photos to top-f:
(add-action ‘top-f
‘(add-to-group top-f)
‘(>= (count faves) 25))
Pretty straightforward. Here’s a more complicated group declaration:
(defgroup ‘top-v
“56022122@N00”
:max-batch 1
:max-posted 11)
The “max-posted” argument tells Automatr that at any point in time there can be at most 11 photos posted to that group (by the user in question). If Automatr wants to post an additional photo to the group, it has to delete one of the 11 first. The photo to be deleted is, again, chosen at random.
That’s basically it. If you want to play around with Clickr and Automatr yourself, just download it and follow the README file in the package. If you do something with it, I’d love to hear from you!
Cool! I’ve been fiddling with an interface to Flickr in Emacs Lisp myself, and I will probably publish that up on EmacsWiki Any Time Soon (TR).
Great! This is one of the most interesting tools for Flickr, and it is done in Lisp, my one and only language! Let me know if you have updates…
Great info. After reading the first time, I am a bit lost. Need time to digest the info. Thanks for the info.
Great info. After reading the first time, I am a bit lost. Need time to digest the info. Thanks for the info.
Cool :)
Cool. I’m a graphic designer and just had a client contact me about flickr. I had never heard of it. Now, I’m quicly playing catch up on this great image tool.
I cant’ wait to see how it works or how I can incorporate the website graphics I create or even my photography with it. I’m currently looking for tutorials similar to the video photoshop tutorials on the flickr. Thank you for the information.
great work
LISP = Lost In Single Pare.. just kidding. Very good and efficient tool you’ve created!
Thanks Schani. Keep up the good work.
https://lowmortgagequote.org
One easy form – 10 different lenders compete for your business.
All credit and loan types accepted.
My main concern is that you can’t guarantee every page of your website will be included in the SERPs. Considering I’m constantly adding new products to my company’s website, I need to be sure that customers can find them as soon as possible.http://www.seoptimizerz.com
Keep up Good Work
all about Home Equity Loan
http://homeequity1.blogspot.com
Great source of useful information thanks.
Great site to share with!
Hey,
You have some nice flickr skills up your sleeves.
Thank you for sharing with us. Looking forward for
more of your stuff.
Later,
Justin
Thanks for your sharing on flickr applications
and uses. Sure found that useful.
Cheers,
Gabriel
The best cheap remortgage in the UK
good links
Are you really looking for an adverse credit remortgage?
Hi schani..I realise this post is a year old but what it sounds like you’ve created is similar to what I wanted to do with my images. Not being a programmer, is there a “simpler” way to explain your Automatr? Sorry for the noob question.
Cheers though for what you’ve done, I’ll keep messing around with it
A browsable repository or just the source tree(s) would also be nice. You could read around without downloading the entire thing.
Hello All,
I was reading around some of the posts here and I found interesting things that you guys talk about, I just made a blog about quitting smoking resources and ideas that you might want to check out.
If someone is interested in this topic just go to; http://endthehabitnow.blogspot.com and let me know what you think.
Thanks in advance.
Want to start your private office arms race right now?
I just got my own USB rocket launcher :-) Awsome thing.
Plug into your computer and you got a remote controlled office missile launcher with 360 degrees horizontal and 45 degree vertival rotation with a range of more than 6 meters – which gives you a coverage of 113 square meters round your workplace.
You can get the gadget here: http://tinyurl.com/2qul3c
Check out the video they have on the page.
Cheers
Marko Fando
Love it! I’m new to LISP but this is awesome!
The LISP API stuff doesn’t mean much to me but i love your photo’s Mark black and white always strike up an atmosphere.
I don’t get your Groups ID
(defgroup ‘top-f
“23561440@N00″
:max-batch 1)
Nice site,
Get a top Spyware software program clean your PC with confidence get back all the power and speed that your computer had in the first place. Don’t wait before it’s too late..
spyware_expert