Skip to content

Instantly share code, notes, and snippets.

@kylexlau
Created July 10, 2009 14:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kylexlau/144571 to your computer and use it in GitHub Desktop.
Save kylexlau/144571 to your computer and use it in GitHub Desktop.
upload photos to google picasa
#!/usr/bin/python
# upload photos to google picasa
import gdata.photos.service
import getpass
import socket
import glob
import sys
import os
if len(sys.argv) < 3:
print 'Usage:'
print '%s new_album_name pattern' % sys.argv[0]
sys.exit(1)
album_name = sys.argv[1]
pattern = os.path.expanduser(sys.argv[2])
username = raw_input('username: ')
gd_client = gdata.photos.service.PhotosService()
gd_client.email = username + '@gmail.com'
gd_client.password = getpass.getpass()
gd_client.source = socket.gethostname()
gd_client.ProgrammaticLogin()
album_id=gd_client.InsertAlbum(title=album_name, summary='').gphoto_id.text
album_url = '/data/feed/api/user/%s/albumid/%s' % (username, album_id)
for f in glob.glob(pattern):
print 'Uploading %s...' % f
gd_client.InsertPhotoSimple(album_url, os.path.split(f)[-1], '', f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment