Created
July 10, 2009 14:55
-
-
Save kylexlau/144571 to your computer and use it in GitHub Desktop.
upload photos to google picasa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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