def createnewalbum(albumname, rights, gds, username): """Create new album with specified name and rights. Create new album with specified name, rights and return its feed url for posting. """ print 'Photos will be inserted in a newly-created album', albumname, 'with rights', rights # debug # prepare metadata gdata_entry = gdata.GDataEntry() gdata_entry.title = atom.Title(text=albumname) # create new albums as private gdata_entry.rights = atom.Rights(text=rights) # standard atom rights # extended rights definition in google namespace ext_rights = atom.ExtensionElement( tag='access', namespace='http://schemas.google.com/photos/2007') ext_rights.text = rights # setting the extended rights gdata_entry.extension_elements.append(ext_rights) # listing categories of gdata_entry (binding to picasa service) gdata_entry.category.append(atom.Category( scheme = gdata.GDATA_NAMESPACE + '#kind', term = 'http://schemas.google.com/photos/2007#album' )) # create new album entry by submitting gdata object try: album = gds.Post( gdata_entry, 'http://picasaweb.google.com/data/feed/api/user/' + username ) except: sys.exit('Error while creating new album: ' + sys.exc_info()[0]) # Note: here we have `album` as gdata.GDataEntry object return album.GetFeedLink().href # return album feed url
def createAlbum(self, folderName, public=True): gd_entry = gdata.GDataEntry() gd_entry.title = atom.Title(text=folderName) gd_entry.category.append( atom.Category(scheme='http://schemas.google.com/g/2005#kind', term='http://schemas.google.com/photos/2007#album')) rights = public and "public" or "private" gd_entry.rights = atom.Rights(text=rights) ext_rights = atom.ExtensionElement( tag='access', namespace='http://schemas.google.com/photos/2007') ext_rights.text = rights gd_entry.extension_elements.append(ext_rights) album_entry = self.Post( gd_entry, 'http://picasaweb.google.com/data/feed/api/user/' + self.email) return PicasaAlbum(self, album_entry)
def setUp(self): self.rights = atom.Rights()