Zorac (zorac) wrote,
Zorac
zorac

  • Mood:
  • Music:

The GIPppiest GIP that ever was GIPped!

See my new icon? That's today’s Dilbert strip - whatever day you're reading this (except Sundays at the moment). Nifty, huh? I have a bunch of perl which grabs the latest strip from the Dilbert website, cuts it up, resizes the parts to make an animated GIF then uploads it to LJ in place of the existing one.

The first part is grabbing the strip - slightly non-trivial as they stick a random number in the image name for exactly that purpose, but I did this years ago to grab the latest Dilbert and User Friendly for the company intranet each day.

Creating the icon was surprisingly straightforward using ImageMagick - a bit of manual inspection to figure out where the box boundaries are, then coding up a few simple crop and resize operations, and the save out as an animation works automagickally.

By far the hardest part was doing the upload, involving a whole bunch of HTTP requests:

  1. Hit the login page with the username and password to get session cookies.
  2. Grab the current edit pics page, saving all the existing icon names and which one is default (this info has to be sent back with the two updates), also to find the ID of the existing Dilbert icon.
  3. Post to the edit pics page to delete the existing icon.
  4. Upload the new icon, and parse the page to find out the new ID.
  5. Post to the edit pics page one final time to put the keyword on the newly uploaded icon.
The final step is to tie the three stages together and run them at a suitable time to catch the Dilbert site after it has been updated. Future plans include some code clean-up and handling the Sunday strip (if it will fit into 100KiB).

Update: W00t! It works! Todays strip is there completely sans human intervention.
Tags: geekery, lj
Subscribe

  • Eat, drink, and be merry!

    ...for tomorrow we diet. And by "tomorrow", I mean in two or three weeks when the assorted left-overs, snacks and sweetmeats have finally met their…

  • ZOMG Lightning!

    Digital cameras are fun. Alas catching a picture of a really good bit of lightning is pretty much impossible. Any sort of lightning at all requires…

  • Whether the weather...

    Well, it seems that the meltingly hot weather which made the working week such fun has done the traditional British thing of fleeing the moment the…

  • Post a new comment

    Error

    Comments allowed for friends only

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 12 comments
Super-nifty!

I would say that was lj_nifty-worthy, but l_n tends to be for things that people can do themselves at least as much as it is for people to show off.

But, hey... :-)
I want to do some code cleanup and the like before posting to lj_nifty - I'm sure that the upload script in particular could be useful to other folk.
O_o That's one of the neatest things I've ever seen.
Please do me. I'm begging.
Alas, my 'plane tickets are for a fortnight from now :-(
You bought your tickets?!
Yah. Somehow I forgot to mention it last night. They weren't getting any cheaper - in fact they looked liable to get more expensive if I waited any longer.
Oooooh!!!! *excited* Email me details?
Superb!
Copyright? ;-)
Well, yes. There is that. Although I suspect the same would apply to the more obvious target dilbert_feed.

Besides, I suspect that a good proportion of the userpics on LJ have some kind of copyright issues...
:O! Too cool!

  • Eat, drink, and be merry!

    ...for tomorrow we diet. And by "tomorrow", I mean in two or three weeks when the assorted left-overs, snacks and sweetmeats have finally met their…

  • ZOMG Lightning!

    Digital cameras are fun. Alas catching a picture of a really good bit of lightning is pretty much impossible. Any sort of lightning at all requires…

  • Whether the weather...

    Well, it seems that the meltingly hot weather which made the working week such fun has done the traditional British thing of fleeing the moment the…