Exemple #1
0
    try:
        # Print only albums's title (if present, otherwise None)
        print(next(album_iterator).get("title"))
    except (StopIteration, TypeError) as e:
        # Handle exception if there are no media left
        print("No (more) shared albums.")
        break

# Create a test album and share it
# create and share
print("Create and share a new album")

album_manager = Album(service)
created_album = album_manager.create('test shared album')
id_album = created_album.get("id")
share_info = album_manager.share(id_album)
token = share_info.get('shareToken')

# Using get() for info retrieval on the shared album
print("Getting album's info")
print(sharing_manager.get(token))

# Trying to join the shared album
print("Trying to join it")
try:
    sharing_manager.join(token)
except HttpError as e:
    print("Can't join albums already joined\n{}".format(e))

# Trying to leave the shared album
print("Trying to leave it, then")
id_album = None
# Create new album and get its Id if no error
print("Let's create a new album!")
try:
    new_album = album_manager.create('test album')
except HttpError as e:
    print("Failed to create new album.\n{}".format(e))
else:
    id_album = new_album.get("id")

if id_album is not None:
    # Share the album
    print("Sharing it...")
    try:
        album_manager.share(id_album)
    except HttpError as e:
        print("Failed to share.\n{}".format(e))

    # Unshare the album
    print("Unsharing it...")
    try:
        album_manager.unshare(id_album)
    except HttpError as e:
        print("Failed to unshare.\n{}".format(e))

    # Add enrichments

    # Add Text enrichment and get its id
    print("We add text to the new album")
    try: