Paul Hopper (paulhopper) wrote,
Paul Hopper

  • Mood:
  • Music:

the lazy way

I'm quite proud of myself lately. You see, I'm all about being lazy. You just have to be smart about being lazy. You can't be lazy in such a way that things don't get done, because it'll all catch up with you in the end. But you can sometimes find ways of getting things done smarter so that you can get away with being lazy. :-)

LiveJournal used to have a feed for the comic strip "The Boondocks", one of my favorites since I first noticed it in the university paper. But LiveJournal was asked to take down the feed for, presumably, copyright issues. This means I can no longer get the latest edition of the comic on friends page every morning! Sure, I could simply go to and read it there, but that's really asking too much from such a lazy person as myself who's used to having it magically appear on my friends page every morning along with everything else!

So, I took a little time this past weekend and wrote a little program to do all the work for me, of course! :-) It's a Windows service that runs in the background and checks every day, once an hour for the latest strip on the website that hosts it, saves it to my computer, then makes a LiveJournal post to a separate journal with the comic so that I can still get my daily Boondocks fix, all without any extra effort from me. And, while I was at it, I set it up so that it'll do the same for several other favorite comics on and other sites. I'd been manually saving each comic to my hard drive every day anyway, so now I don't even have to do that.

The project uses four database tables: comics, downloadQueue, downloadFailures, and postQueue. A history table will be added soon.

The comics table maintains the list of comics and the parameters for determining the filename of the current comic. For instance, the image for any given day's can be found at[four-digit year]/bo[last two digits of the year][two-digit month][two-digit day of month].gif. So I just fill in the blanks. Calvin and Hobbes, on the other hand, is in reruns. So I have a field in the comics table for a date offset.

Every hour, the program checks to see if there are any items in the comics table that haven't been added to the downloadQueue yet for today. If not, it adds it. Then, again, every hour, it runs through the downloadQueue table, filling in the blanks, and tries to download the comic from whatever website is hosting it. If it fails, it records that and will try again every 12 hours for one week before moving it from the downloadQueue table to the downloadFailures table, where I can take a look and see if the url for the comic has changed and needs to be updated. If it succeeds, it removes that record from the downloadQueue and adds an entry to the postQueue.

Every hour, the program attempts to post any comics in the postQueue to LiveJournal. If it can't connect to LiveJournal's server for whatever reason, it'll just leave it there and try again in another hour.

The history table will be used to keep a log of every comic posted so that if, for instance, I change where I store the comics on my computer, I can more easily write a little program to go through and update the links in all the old posts to reflect the change, rather than leave them as broken links.

Because I wouldn't want to get into trouble over any copyright issues or have my ISP complain about how much bandwidth I'm consuming, the journal I use to post the comics to is secret and every post is friends-only so nobody else can see them. So I can't show off my work, but oh well. You'll just have to take my word for it.

See... a very simple program that took very little time to create and allows me to continue to be lazy. I'm rather pleased. :-)
  • Post a new comment


    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.