Download original pictures from the picasaweb(only public photos)

Just download the public photos from the picasaweb of a given user.

Grab a piece of code from here revealPicasa to access public photos

#!/usr/bin/env python

	Download public photos with the original resolution for a given user name
	Use google data library

import gdata.geo
import urllib
import os
import sys
from optparse import OptionParser, OptionGroup

# public albums
URL_TO_GET_PUBLIC_PHOTOS 	= '/data/feed/base/user/%s/albumid/%s?kind=photo'

usage = "usage: %prog user_name"

def download_file( url, dir_name ):
	"Download the data at URL to the current directory"
	basename = url[url.rindex('/') + 1:] # figure out a good name for the downloaded file.
	url = url.replace(basename, "d/"+basename)

	urllib.urlretrieve(url, dir_name+"/"+basename)

def connect_to_picasa():
	gd_client =

	return gd_client

def get_albums( gd_client, user_id ):
	return gd_client.GetUserFeed(user = user_id)

def get_photos( albums, user_name ):
	base_dir_name = raw_input("Where do you want to save the files? ")
	if base_dir_name == "":
		base_dir_name = "."
	print "\nSave the photos in %s\n" %base_dir_name

	for album in albums.entry:
		downloaded_photos = 0
		print 'Album: %s (%s)' % (album.title.text, album.numphotos.text)

		album_dir_name = base_dir_name+"/"+album.title.text
		if not os.path.exists( album_dir_name ):
			os.makedirs( album_dir_name )

		photos = gd_client.GetFeed(URL_TO_GET_PUBLIC_PHOTOS % (user_name, album.gphoto_id.text))

		for photo in photos.entry:
			download_file( photo.content.src, album_dir_name )
			downloaded_photos += 1

			sys.stdout.write("\t%d/%s  %.1f %%\r" %(downloaded_photos, album.numphotos.text, 100.0*downloaded_photos/eval(album.numphotos.text)))

		print ""

if __name__ == '__main__':
	if len(sys.argv) >= 2:
		user_name = sys.argv[1]
		print usage

	gd_client = connect_to_picasa()
	albums = get_albums( gd_client, user_name )
	get_photos( albums, user_name )