Mostly Software

July 20, 2006

Lisping Flickr

Filed under: Photography, Software — schani @ 8:32 pm

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!

About these ads

118 Comments

  1. 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).

    Comment by Mathias Dahl — July 26, 2006 @ 9:25 pm

  2. 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…

    Comment by Priyadarshan — August 2, 2006 @ 8:15 pm

  3. [...] Juggling, Photography, Software, and Atheism Lisping Flickr [...]

    Pingback by Logg for Aslak Raanes :: Juggling, Photography, Software, and Atheism Lisping Flickr — August 9, 2006 @ 11:26 am

  4. [...] I’ve just released version 0.2 of Clickr, my Common Lisp bindings to the Flickr API, which can be downloaded here. [...]

    Pingback by Juggling, Photography, Software, and Atheism » Clickr 0.2 — August 15, 2006 @ 3:39 pm

  5. Great info. After reading the first time, I am a bit lost. Need time to digest the info. Thanks for the info.

    Comment by Edward Han — November 26, 2006 @ 11:28 am

  6. Great info. After reading the first time, I am a bit lost. Need time to digest the info. Thanks for the info.

    Comment by sun bingo — December 12, 2006 @ 7:31 pm

  7. Cool :)

    Comment by scrapbidule — December 26, 2006 @ 9:45 am

  8. 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.

    Comment by GrafxExtreme — December 28, 2006 @ 10:12 pm

  9. great work

    Comment by soccer team — December 29, 2006 @ 11:30 pm

  10. LISP = Lost In Single Pare.. just kidding. Very good and efficient tool you’ve created!

    Comment by Mick Software — January 12, 2007 @ 10:07 am

  11. [...] Clickr – for accessing the Flickr API [...]

    Pingback by Marc Abramowitz » Common Lisp libraries for Yahoo! APIs — March 4, 2007 @ 12:56 am

  12. [...] kom over ei side kor nokon har laga eit API til Flickr i Common Lisp, kalla CLickr, eg synst det var litt gøy, du kan f.eks. finne kor mange av dei brukarane som du har [...]

    Pingback by Kognitiv vitenskap » Blog Archive » Emacs + Slime + CL = Common LISP-heaven! — March 28, 2007 @ 8:45 pm

  13. Thanks Schani. Keep up the good work.

    Comment by James — April 24, 2007 @ 2:27 pm

  14. health general

    one tools

    Trackback by One Tools — June 10, 2007 @ 6:07 pm

  15. plus size, clothing, plus sizes

    informative blog. Thanks for sharing.

    Trackback by News about Plus Sizes Clothing — June 11, 2007 @ 4:30 am

  16. dog, cat

    Welcome to my site

    Trackback by My Website — June 11, 2007 @ 3:12 pm

  17. google

    Nice information on here.

    Trackback by google — June 14, 2007 @ 12:32 am

  18. ebay

    Nice information on here.

    Trackback by ebay — June 14, 2007 @ 12:47 am

  19. yahoo

    Nice information on here.

    Trackback by yahoo — June 14, 2007 @ 1:02 am

  20. youtube

    Nice information on here.

    Trackback by youtube — June 14, 2007 @ 1:17 am

  21. msn

    Nice information on here.

    Trackback by msn — June 14, 2007 @ 9:17 am

  22. tea

    Nice information on here.

    Trackback by tea — June 14, 2007 @ 12:18 pm

  23. teambuilding, team building, coaching, lederteambuilding, teamevents

    Company providing innovative teambuilding courses for all size companies

    Trackback by teambuilding kompagniet — June 15, 2007 @ 10:24 pm

  24. Learn Spanish Online, Learn Spanish fast, Learn Spanish free, how to Learn Spanish, Learn Spanish

    Trackback by Learn Spanish Online — June 16, 2007 @ 9:00 pm

  25. autism, autism treatment, autism symptoms, autism condition, adult autism

    Thank you for posting this information. It is very helpful

    Trackback by Autism Information — June 16, 2007 @ 9:07 pm

  26. hearing hearing devices hearing aid

    nice site…

    Trackback by Hearing Aids Help — June 17, 2007 @ 8:14 am

  27. cheaphotel, flightravel , disneytravel

    Nice blog , very useful information thanks for sharing

    Trackback by Travel — June 17, 2007 @ 5:30 pm

  28. loan guarantee

    Great site. Lots of nice information.

    Trackback by Loan Guarantees — June 17, 2007 @ 5:51 pm

  29. computer upgrades pc

    Great site. Lots of nice information.

    Trackback by PC Upgrade Site — June 17, 2007 @ 8:24 pm

  30. medicaltechnology , pharmacytechnology

    Nice blog here , very interesting information , thanks for sharing

    Trackback by Technology — June 18, 2007 @ 7:07 am

  31. precious metal gold silver platinum

    Great site. Lots of nice information.

    Trackback by Precious Metals Info — June 18, 2007 @ 10:28 am

  32. heart, heartware, cholesterol, defibrillator, heart attack

    Trackback by Heartware - lower your cholesterol — June 18, 2007 @ 5:28 pm

  33. accounting,financial statement,business,accounting principles

    What are the best accounting resources available?

    Trackback by Best accounting resources? — June 19, 2007 @ 7:31 am

  34. laptop computers dell apple sony

    Nice post!

    Trackback by Laptop Help Desk — June 22, 2007 @ 4:16 pm

  35. laptops apple computers dell

    great!

    Trackback by laptopunlimited.info — June 22, 2007 @ 7:07 pm

  36. mortgage financial loans

    nice siteï¾…

    Trackback by pgmortgage.info — June 22, 2007 @ 7:23 pm

  37. mortgage financial loans

    nice siteï¾…

    Trackback by mortgageb.info — June 22, 2007 @ 7:37 pm

  38. mortgage financial loans

    nice siteï¾…

    Trackback by freemortgageapproval.info — June 22, 2007 @ 7:52 pm

  39. Adoption Information Adoption Photolisting Foster Care International Adoption

    nice site…

    Trackback by Adoption Help — June 22, 2007 @ 11:33 pm

  40. Bankruptcy Help Bankruptcy Lawyers Filing Bankruptcy After Bankruptcy

    nice site…

    Trackback by Bankruptcy Help — June 22, 2007 @ 11:48 pm

  41. About Dating Christian Dating Sites Online Dating Date Ideas

    nice site…

    Trackback by Dating Help — June 23, 2007 @ 12:03 am

  42. Digital Camera Digital Camera Prints Digital Photo Imaging Learn Digital Photography

    nice site…

    Trackback by Digital Photography Help — June 23, 2007 @ 12:19 am

  43. Adware Spyware Spyware Cleaner Download Spyware Removal Spyware Removal Software Review

    nice site…

    Trackback by Spyware Help — June 23, 2007 @ 12:33 am

  44. Teeth Whitener Professional Teeth Whitening Teeth Whitening Kits Teeth Whitening Strips

    nice site…

    Trackback by Teeth Whitening Help — June 23, 2007 @ 12:48 am

  45. Airfare Prices Cheap Airfare Airline Tickets Book Airfare

    nice site…

    Trackback by Airfare Help — June 23, 2007 @ 1:04 am

  46. Architect Design Architecture Building Architecture Jobs Architecture Software

    nice site…

    Trackback by Architect Help — June 23, 2007 @ 1:18 am

  47. Wedding Dresses Wedding Rings Wedding Cake Wedding Favor Wedding Invitation

    nice site…

    Trackback by Wedding Help — June 23, 2007 @ 1:49 am

  48. health economy finances technology computers

    I totally agree!

    Trackback by Unique Host, Technology, Real State — June 23, 2007 @ 6:39 pm

  49. real state property mortgage homes for sale

    Great site!

    Trackback by International real State — June 23, 2007 @ 7:49 pm

  50. quit smoking info ebook

    Nice!

    Trackback by Free Quit Smoking Tips — June 23, 2007 @ 11:56 pm

  51. credit cards mortgage loans finance

    Great site!

    Trackback by Credit — June 24, 2007 @ 9:41 am

  52. health dell computers domains diabetes

    Great site!

    Trackback by Health and tech Info Blog — June 24, 2007 @ 10:29 am

  53. health healthy healthiness health care health insurance health food healthy living

    Great site, very informative. Many thanks for sharing the information.

    Trackback by The Latest Health News — June 26, 2007 @ 5:24 pm

  54. cars health financial mortgage loans

    great site!

    Trackback by Cars, health and financial blog — June 26, 2007 @ 7:07 pm

  55. computers construction consumer credit cards

    Cool!

    Trackback by Computers — June 26, 2007 @ 8:13 pm

  56. education engeenering email english spanish

    Great Site!

    Trackback by Engineering and education blog — June 26, 2007 @ 9:33 pm

  57. technology computers podcasting digital camera internet laptop firewire usb

    Nice blog. Very informative. Thanks for sharing.

    Trackback by Technology Site Search - Your search site for anything technology related! — June 27, 2007 @ 2:56 am

  58. https://lowmortgagequote.org
    One easy form – 10 different lenders compete for your business.
    All credit and loan types accepted.

    Comment by low mortgage quote — June 27, 2007 @ 5:57 pm

  59. SEO, internet marketing, search engine optimization, blog

    Very interesting blog! You are an excelent writer… Nancy

    Trackback by SEO and internet marketing blog — June 28, 2007 @ 10:52 pm

  60. health healthy healthiness health care health insurance health food healthy living

    Excellent resouce on your website. Kudos.

    Trackback by The Most Up To Date Health News — July 2, 2007 @ 8:37 am

  61. 6e69a51e4975cd67637e6cfe8fe3462d

    6e69a51e4975cd67637e6cfe8fe3462d

    Trackback by 6e69a51e4975cd67637e6cfe8fe3462d — July 5, 2007 @ 1:58 am

  62. weddings matrimony reception bridal bride groomsmen groom tuxedo rings bouquet flowers dress flower girl honeymoon

    great site.thank you for sharing!

    Trackback by My Wedding Store — July 6, 2007 @ 12:23 am

  63. weddings matrimony reception bridal bride groomsmen groom tuxedo rings bouquet flowers dress flower girl honeymoon

    great site.thank you for sharing!

    Trackback by I The Wed — July 6, 2007 @ 12:54 am

  64. automotive automobile car

    This really is a useful website. A really good source of information.

    Trackback by Fast Automotive Info — July 7, 2007 @ 2:13 pm

  65. carnival festival cruise cruises

    This really is a useful website. A really good source of information.

    Trackback by Fast Carnival Info — July 7, 2007 @ 2:29 pm

  66. weddings matrimony reception bridal bride groomsmen groom tuxedo rings bouquet flowers dress flower girl honeymoon

    great site.thank you for sharing!

    Trackback by Online Wedding Supplies — July 7, 2007 @ 3:16 pm

  67. footstool, footstools, foot stool

    find footstool here…

    Trackback by FootStool — July 11, 2007 @ 6:55 am

  68. credit card apply application business offer online debt

    Thanks for sharing and keep up the good work.

    Trackback by Top-CreditCard — July 11, 2007 @ 6:58 am

  69. new york

    This really is a useful website. A really good source of information.

    Trackback by Fast New-York Info — July 12, 2007 @ 10:19 pm

  70. games gaming game

    Thank you for the information. I will look forward to seeing your updates for this site!

    Trackback by All Games Home — July 14, 2007 @ 2:16 am

  71. games, gaming, game

    Great website. I will definitely be coming back.

    Trackback by Gaming Site — July 14, 2007 @ 2:35 am

  72. auto, car, cars news

    I agree with your point of view.

    Trackback by Auto Resources — July 14, 2007 @ 2:54 am

  73. news car auto

    I\\\\\\\’m new here but it looks like a great place to hang out

    Trackback by Car News — July 14, 2007 @ 3:16 am

  74. shopping news jewelry antiques

    Thanks for the relevent information. I will do some more research on my own.

    Trackback by Jewelry — July 14, 2007 @ 3:42 am

  75. cars news information auto

    This is just what I was thinking. Great Site.

    Trackback by Automotive Information — July 14, 2007 @ 4:10 am

  76. cash money loans

    I love your website. I was thinking of creating one just like it.

    Trackback by Financial Information Resources — July 14, 2007 @ 4:23 am

  77. computers computer information

    Great website. I will definitely be coming back.

    Trackback by Computer Information Online — July 14, 2007 @ 4:41 am

  78. money cash resources online search

    Great website. I will definitely be back.

    Trackback by Financial Resources — July 14, 2007 @ 4:56 am

  79. kayaking hobbies sports

    Thank you for the information. I will look forward to seeing your updates for this site!

    Trackback by Kayaking Resource — July 14, 2007 @ 5:19 am

  80. weding dress marriage love

    Thanks. I have a freind who needs to see this site.

    Trackback by Wedding — July 17, 2007 @ 7:14 am

  81. blog,info,life,Art,Blogging,Books,Entertainment,Family,Food,Fun,Humor,Life,Love,Movies,Music,News,Personal,Photography,Politics,Random,Religion,Thoughts,Travel,Video,Work,Media,Technology,Writing

    Nice site. very good information. I really like it, keepthe good job. You can also visit my site at

    Trackback by Free best information on domainr — July 18, 2007 @ 3:04 am

  82. blog,info,life,Art,Blogging,Books,Entertainment,Family,Food,Fun,Humor,Life,Love,Movies,Music,News,Personal,Photography,Politics,Random,Religion,Thoughts,Travel,Video,Work,Media,Technology,Writing

    Nice site. very good information. I really like it, keepthe good job. You can also visit my site at

    Trackback by Free best information on secretss — July 18, 2007 @ 5:58 am

  83. computer computers news laptops

    This is just what I was thinking. Great Site.

    Trackback by Computer Info Web — July 19, 2007 @ 3:51 pm

  84. 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

    Comment by SEO — July 22, 2007 @ 7:24 am

  85. cars, car insurance, automobiles, trucks, auto

    Thanks for taking the time to write this.

    Trackback by Car Lovers Info — July 24, 2007 @ 3:23 am

  86. mortgages refinance loans financing remortgage equity crediti

    Sounds good … but nevertheless, I\\\\\\\’m not sure I agree with the idea.

    Trackback by Mortgaged To The Hilt — July 25, 2007 @ 10:42 am

  87. Keep up Good Work

    all about Home Equity Loan

    http://homeequity1.blogspot.com

    Comment by Henry — July 27, 2007 @ 4:19 pm

  88. mortgages loans financing equity

    Sounds good … but nevertheless, I am not totally sure I agree with the idea.

    Trackback by Find My Mortgage — July 31, 2007 @ 8:25 am

  89. mortgages loans financing equity

    Sounds good … but nevertheless, I am not totally sure I agree with the idea.

    Trackback by The Mortgage Game — July 31, 2007 @ 8:40 am

  90. mortgages loans financing equity

    Sounds good … but nevertheless, I am not totally sure I agree with the idea.

    Trackback by Mastering Mortgages — July 31, 2007 @ 9:11 am

  91. mortgages loans financing equity

    Sounds good … but nevertheless, I am not totally sure I agree with the idea.

    Trackback by Nationwide Mortgages — July 31, 2007 @ 9:25 am

  92. acupressure

    This really is a useful website. A really good source of information.

    Trackback by Fast free acupressure info — August 1, 2007 @ 6:39 pm

  93. attorney

    This really is a useful website. A really good source of information.

    Trackback by Fast free attorney info — August 1, 2007 @ 6:55 pm

  94. Great source of useful information thanks.

    Comment by Frank — August 7, 2007 @ 11:26 am

  95. career

    This really is a useful website. A really good source of information.

    Trackback by Fast free career Information — August 9, 2007 @ 9:51 pm

  96. Great site to share with!

    Comment by Starzlet — August 15, 2007 @ 4:49 pm

  97. diabetes diabetic diabetes illness type 2 diabetes

    Great information on your site. Thank you.

    Trackback by Your Diabetes Informer — August 15, 2007 @ 8:03 pm

  98. diabetes diabetic diabetes illness type 2 diabetes

    Wonderful website. Impressed with the content. Thumbs up.

    Trackback by Newest Information About Your Diabetes — August 15, 2007 @ 8:18 pm

  99. diabetes diabetic diabetes illness type 2 diabetes

    Great site, keep up the good work. Thanks.

    Trackback by All About Diabetes — August 15, 2007 @ 8:33 pm

  100. credit card credit cards

    Great site, very informative. Many thanks for sharing the information.

    Trackback by The Latest Credit Card News — August 15, 2007 @ 8:48 pm

  101. credit card credit cards

    Excellent resouce on your website. Kudos.

    Trackback by The Most Up To Date Credit Card News — August 15, 2007 @ 9:05 pm

  102. credit card credit cards

    Great information on your site. Thank you.

    Trackback by Your Credit Card Informer — August 15, 2007 @ 9:19 pm

  103. credit card credit cards

    Wonderful website. Impressed with the content. Thumbs up.

    Trackback by Newest Information About Your Credit Card — August 15, 2007 @ 9:33 pm

  104. 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

    Comment by Justin — August 18, 2007 @ 11:55 am

  105. Thanks for your sharing on flickr applications
    and uses. Sure found that useful.

    Cheers,
    Gabriel

    Comment by Gabriel — August 18, 2007 @ 11:57 am

  106. The best cheap remortgage in the UK

    Comment by Joe — September 3, 2007 @ 10:18 pm

  107. good links

    Comment by Joe — September 3, 2007 @ 10:23 pm

  108. Are you really looking for an adverse credit remortgage?

    Comment by Joe — September 5, 2007 @ 3:23 am

  109. 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

    Comment by Scott — September 12, 2007 @ 11:04 pm

  110. A browsable repository or just the source tree(s) would also be nice. You could read around without downloading the entire thing.

    Comment by XTL — September 13, 2007 @ 4:29 am

  111. 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.

    Comment by exsmoker — September 26, 2007 @ 7:22 am

  112. 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

    Comment by markofando — October 2, 2007 @ 4:40 am

  113. Love it! I’m new to LISP but this is awesome!

    Comment by Software at Cost — February 21, 2008 @ 6:27 pm

  114. 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.

    Comment by Wedding Flowers by Mansion House Florists — May 2, 2008 @ 12:31 pm

  115. I don’t get your Groups ID

    (defgroup ‘top-f
    “23561440@N00″
    :max-batch 1)

    Comment by Raheel — June 11, 2008 @ 4:40 pm

  116. [...] Common Lisp: Clickr [...]

    Pingback by Trabajando con el API de Flickr — November 21, 2008 @ 4:44 am

  117. 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

    Comment by spyware_expert — December 15, 2008 @ 9:19 pm

  118. [...] Common Lisp: Clickr [...]

    Pingback by TodoLinks » Blog Archive » Trabajando con el API de Flickr — December 29, 2008 @ 3:49 pm


RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

The Shocking Blue Green Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: