Guest User

Untitled

a guest
Mar 9th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #!/usr/bin/python
  2. # upload photos to google picasa
  3.  
  4. import gdata.photos.service
  5. import getpass
  6. import socket
  7. import glob
  8. import sys
  9. import os
  10.  
  11. if len(sys.argv) < 3:
  12. print 'Usage:'
  13. print '%s new_album_name pattern' % sys.argv[0]
  14. sys.exit(1)
  15.  
  16. album_name = sys.argv[1]
  17.  
  18. pattern = os.path.expanduser(sys.argv[2])
  19. username = raw_input('username: ')
  20.  
  21. gd_client = gdata.photos.service.PhotosService()
  22. gd_client.email = username + '@gmail.com'
  23. gd_client.password = getpass.getpass()
  24. gd_client.source = socket.gethostname()
  25. gd_client.ProgrammaticLogin()
  26.  
  27. album_id=gd_client.InsertAlbum(title=album_name, summary='').gphoto_id.text
  28.  
  29. album_url = '/data/feed/api/user/%s/albumid/%s' % (username, album_id)
  30.  
  31. for f in glob.glob(pattern):
  32. print 'Uploading %s...' % f
  33. gd_client.InsertPhotoSimple(album_url, os.path.split(f)[-1], '', f)
Add Comment
Please, Sign In to add comment