upicasa -- an upload script for PicasaWeb

So, as planned last time, I developed my PicasaWeb script a bit further. After I got home from a niece's first birthday party, I had some photos I wanted to upload, so I added the support for listing and creating albums. Then today I moved the authentication credentials out of module globals into a combination of a config file and interactive email/password query. With my password out of the source code it became ready for the initial import into a version control repository.

I chose Mercurial as a VCS just to try it out. Thus, Bitbucket was a natural place to host the repository. Unfortunately, yesterday evening it was inaccessible. Mercurial feels really fast and convenient.

Bitbucket was a total blast to get going. I registered in with my Launchpad OpenId, created a new repository for my project, uploaded my SSH pubkey, and was able to push my initial version within two or three minutes. Way to go, dudes! Very clear, simple, and good looking. A stark contrast with Launchpad, which leaves me confused whenever I try to do something that should be really simple. Here's the link to the upicasa hg repo on Bitbucket.

So, anyway, I wrote a setup.py script, a README file, polished the script a bit and released it to PyPI: upicasa 0.1. Writing the setup.py and the README in order to package the script took about the same time, if not more, than writing the script in the first place, but that's how it goes with Open Source, doesn't it?

The more I use PicasaWeb the more I like it. It has a nifty semi-automatic face recognition feature. It makes tagging people on photos pass the threshold of convenience where it becomes practial. Finally I'll be able to find a photo of someone I know I have. Full screen album display feature is also very nice.

So, now I have a warm fuzzy feeling of having done a useful weekend programming project. Tried something new. Learned a bit. Now it will be great to see whether other people will find it useful.


Sometimes Google is great

Last weekend we have been invited to a neighbour's 5th birthday party. It has taken place at a kids' entertainment park in a shopping centre. I took my camera, and the neighbours asked me to share the pictures.

So, I decided I want to post the pictures at PicasaWeb. It's web galleries are quite convenient and featureful, look like a good place to dump large amounts of photos someone wants you to share. Facebook, in contrast, scales them down to obscenely small sizes. Since I already have a Google account, I just had to click the Register button, and I got into my gallery with my Blogger avatar already in it. I created a new album, but the upload form for adding pictures was so 1990's. It had 5 file upload input fields. Even if new ones would appear as needed, it meant that I would have to select each and every photo individually.

I started looking for a tool for automatic upload into Picasa, but a stand-alone tool for that doesn't seem to exist in Ubuntu. There is, however, a python-gdata package with a Python API to Google online services. I googled "python gdata" and got the documentation in Google Code as the first hit. It has a section on PicasaWeb. 15 minutes later the photos were already on the way. Here is the script:

#!/usr/bin/env python
"""upicasa.py -- an upload script for PicasaWeb"""
import sys
import gdata.photos.service
import gdata.media
import gdata.geo

EMAIL = 'xxxx.xxxx@gmail.com'

def main():
gd_client = gdata.photos.service.PhotosService()
gd_client.email = EMAIL
gd_client.password = PASSWORD
gd_client.source = 'alga-upicasa-1'
print "Authenticating..."

## I used this to fish out the album id pasted below
#albums = gd_client.GetUserFeed(user=EMAIL)
#for album in albums.entry:
# print 'title: %s, number of photos: %s, id: %s' % (album.title.text,
# album.numphotos.text,
# album.gphoto_id.text)

album_id = '123123123123132123'
album_url = '/data/feed/api/user/%s/albumid/%s' % (EMAIL, album_id)
for photo in sys.argv[1:]:
print "uploading", photo
photo = gd_client.InsertPhotoSimple(album_url, 'New Photo',
'', # title
photo, content_type='image/jpeg')

if __name__ == '__main__':

It was really fun and empowering to get the photos programmatically uploading into online albums in such a short time. Top marks to Google for providing this simple, sensible way to manage data on Google. No app registration, no developer keys, no nonsense, just the Google login and password are needed to get started. I think I'll develop this script a bit to allow for managing the albums from command line and uploading photos into them, then add it to Python Package Index. Perhaps a simple GUI could also be useful.