Auto Upload Photos and Video to Flickr

Now that Flickr has unlimited bandwidth and storage space and supports video I decided to have my pictures automatically upload to it each night. I'm already paying them so why not use them as off site backup?

Well it took some coding and a bit of learning about my Macbook, but I got it working.

To make this happen I started with a python script called by Cameron Mallory that uploads all the new photos in a director/folder to a flickr account. Life Hacker has this easy to follow explanation on how to install it and use didn't do everything I wanted so I rolled up my sleeves and made some changes to his script. My version does everything does and...

  1. It uploads videos!

  2. It only uploads a video if its length is under 90 seconds (the Flickr limit).

  3. It requires you install qt_tools for any of that video stuff to work.

  4. Theoretically everything but video will work if you don't install qt_tools.

  5. If you run ./ -markuploaded, the script will ignore all the existing images and videos in the directory so you don't re-upload the 15,000 photos you already manually uploaded. Only images added in the future will be uploaded.

  6. It supports multiple directories (or backing up multiple users pictures).

  7. It saves a log file which is comforting if your wondering if it ran.

Multiple directories is also big deal if you use iPhoto because there are two directories under iPhoto Library that you want (iPhoto Library/Original and iPhoto Library/Modified), and one that you don't (iPhoto Library/data) which only contains thumbnails images of the stuff in the other two directories.

After the script was working I made this AppleScript, saved it as an application called Monster Pirate Flickr Uploadr, changed it's icon to that pirate monster I found here and put it in the applications folder.

do shell script "cd /Users/Shared/bin/flickr-auto-uploader/; ./;" user name "yourusername" password "insertyourpasswordhere" with administrator privileges

Update 2008-04-26: There was a bug in the original script. I've fixed it above.

The Monster Pirate Flickr Uploadr application is so that either Christine or I can kick off the upload easily. The pirate icon is because Christine said it looked cool.

The next step is to get this thing running without me having to be George Jetson.

On Python: This was my first excuse to try out Python. For a language that cares about white space and doesn't use {brackets to wrap function content} it was surprisingly fun to use. It's like Perl with real objects. The one thing that got me was the syntax for "Else if" which is "elif" in Python. That's just plain weird...

Update 2008-11-08: Reciently the script started re-uploading pictures at random. It appears that DB I was using a pythong "shelve" construct has a maximum size of 5,222,400 bytes. We have so many pictures that we've exceeded that space just for storing their names in a database. I don'y have a fix for this so I simply changed the upload directory in the script to only upload this years files. It's a hack, but it works...