Esempio n. 1
0
def delete_all_tracks():
    """Create a bundle, add tracks, delete them."""

    # Create a bundle with no track.
    print '*** Creating a bundle with no tracks...'
    bundle_ref = clarify.create_bundle(name='track tester')
    href = bundle_ref['_links']['clarify:tracks']['href']

    # Add three tracks.
    print '*** Adding a track to the bundle...'
    clarify.create_track(href, media_url=MEDIA_URL1, label='first label')
    print '*** Adding a track to the bundle...'
    clarify.create_track(href, media_url=MEDIA_URL2, label='second label')
    print '*** Adding a track to the bundle...'
    clarify.create_track(href, media_url=MEDIA_URL3, label='third label')

    # List the tracks.
    track_list = clarify.get_track_list(href)
    for track in track_list['tracks']:
        print_track_quiet(track)

    # Update the track.
    print '*** Deleting all tracks...'
    clarify.delete_track_at_index(href)

    # List the tracks.
    track_list = clarify.get_track_list(href)
    for track in track_list['tracks']:
        print_track_quiet(track)
Esempio n. 2
0
def delete_track_using_href():
    """Delete a track using its href."""

    # Create a bundle with no track.
    print '*** Creating a bundle with no tracks...'
    bundle_ref = clarify.create_bundle(name='track tester')
    href = bundle_ref['_links']['clarify:tracks']['href']

    # Add a track.
    print '*** Adding a track to the bundle...'
    track_ref = clarify.create_track(href,
                                     media_url=MEDIA_URL1,
                                     label='short-lived track')

    # List the tracks.
    track_list = clarify.get_track_list(href)
    for track in track_list['tracks']:
        print_track_quiet(track)

    # Delete the track.
    print '*** Deleting track by href...'
    track_href = track_ref['_links']['self']['href']
    clarify.delete_track(track_href)

    # List the tracks.
    track_list = clarify.get_track_list(href)
    for track in track_list['tracks']:
        print_track_quiet(track)
Esempio n. 3
0
def delete_track_using_href():
    """Delete a track using its href."""

    # Create a bundle with no track.
    print '*** Creating a bundle with no tracks...'
    bundle_ref = clarify.create_bundle(name='track tester')
    href = bundle_ref['_links']['clarify:tracks']['href']

    # Add a track.
    print '*** Adding a track to the bundle...'
    track_ref = clarify.create_track(href, media_url=MEDIA_URL1,
                                     label='short-lived track')

    # List the tracks.
    track_list = clarify.get_track_list(href)
    for track in track_list['tracks']:
        print_track_quiet(track)

    # Delete the track.
    print '*** Deleting track by href...'
    track_href = track_ref['_links']['self']['href']
    clarify.delete_track(track_href)

    # List the tracks.
    track_list = clarify.get_track_list(href)
    for track in track_list['tracks']:
        print_track_quiet(track)
Esempio n. 4
0
def metadata_create():
    """Create metadata and create a bundle with it."""

    # Create a bundle with metadata.
    # Note that all examples below are valid.
    print '*** Creating a bundle with mythical metadata...'
    data = {'wife': 'Medea', 'husband': 'Jason'}
    # data = {'wife': 'Medea', 'lovers': ['Aegisthus', 'Pancreon']}
    # data = {'daughters': 1, 'sons': 3}
    # data = {'hot': True, 'cold': False, 'tepid': None}
    bundle_ref = clarify.create_bundle(name='md test', metadata=data)

    #
    # 3 different ways to retrieve our metadata!
    #

    # (1) Retrieve the metadata from bundle reference.  Print it.
    print '*** Retrieving metadata from bundle reference...'
    href = bundle_ref['_links']['clarify:metadata']['href']
    metadata = clarify.get_metadata(href)
    print_metadata_info_quiet(metadata)

    # (2) Retrieve the bundle, then retrieve the metadata.  Print it.
    print '*** Retrieving the bundle then the metadata...'
    href = clarify.get_bundle(bundle_ref['_links']['self']['href'])
    metadata = clarify.get_metadata(href['_links']['clarify:metadata']['href'])
    print_metadata_info_quiet(metadata)

    # (3) Retrieve the bundle with the metadata embedded.  Print it.
    print '*** Retrieving the bundle with embedded metadata...'
    href = clarify.get_bundle(bundle_ref['_links']['self']['href'],
                              embed_metadata=True)
    metadata = href['_embedded']['clarify:metadata']
    print_metadata_info_quiet(metadata)
Esempio n. 5
0
def delete_all_tracks():
    """Create a bundle, add tracks, delete them."""

    # Create a bundle with no track.
    print '*** Creating a bundle with no tracks...'
    bundle_ref = clarify.create_bundle(name='track tester')
    href = bundle_ref['_links']['clarify:tracks']['href']

    # Add three tracks.
    print '*** Adding a track to the bundle...'
    clarify.create_track(href, media_url=MEDIA_URL1, label='first label')
    print '*** Adding a track to the bundle...'
    clarify.create_track(href, media_url=MEDIA_URL2, label='second label')
    print '*** Adding a track to the bundle...'
    clarify.create_track(href, media_url=MEDIA_URL3, label='third label')

    # List the tracks.
    track_list = clarify.get_track_list(href)
    for track in track_list['tracks']:
        print_track_quiet(track)

    # Update the track.
    print '*** Deleting all tracks...'
    clarify.delete_track_at_index(href)

    # List the tracks.
    track_list = clarify.get_track_list(href)
    for track in track_list['tracks']:
        print_track_quiet(track)
def metadata_create():
    """Create metadata and create a bundle with it."""

    # Create a bundle with metadata.
    # Note that all examples below are valid.
    print "*** Creating a bundle with mythical metadata..."
    data = {"wife": "Medea", "husband": "Jason"}
    # data = {'wife': 'Medea', 'lovers': ['Aegisthus', 'Pancreon']}
    # data = {'daughters': 1, 'sons': 3}
    # data = {'hot': True, 'cold': False, 'tepid': None}
    bundle_ref = clarify.create_bundle(name="md test", metadata=data)

    #
    # 3 different ways to retrieve our metadata!
    #

    # (1) Retrieve the metadata from bundle reference.  Print it.
    print "*** Retrieving metadata from bundle reference..."
    href = bundle_ref["_links"]["clarify:metadata"]["href"]
    metadata = clarify.get_metadata(href)
    print_metadata_info_quiet(metadata)

    # (2) Retrieve the bundle, then retrieve the metadata.  Print it.
    print "*** Retrieving the bundle then the metadata..."
    href = clarify.get_bundle(bundle_ref["_links"]["self"]["href"])
    metadata = clarify.get_metadata(href["_links"]["clarify:metadata"]["href"])
    print_metadata_info_quiet(metadata)

    # (3) Retrieve the bundle with the metadata embedded.  Print it.
    print "*** Retrieving the bundle with embedded metadata..."
    href = clarify.get_bundle(bundle_ref["_links"]["self"]["href"], embed_metadata=True)
    metadata = href["_embedded"]["clarify:metadata"]
    print_metadata_info_quiet(metadata)
Esempio n. 7
0
def create_15_bundles():
    """Create 15 bundles without any media."""

    for i in range(0, 15):
        bundle_ref = clarify.create_bundle(str(i))
        href = bundle_ref['_links']['self']['href']
        bundle = clarify.get_bundle(href)
        print '*** Created bundle ' + href + ' with name: ' + bundle['name']
def metadata_delete():
    """Create a bundle with metadata, print it, delete it, print it."""

    # Create a bundle with some metadata.
    print '*** Creating a bundle with mythical metadata...'
    data = {'wife': 'Medea', 'husband': 'Jason'}
    bundle_ref = clarify.create_bundle(name='metadata update test',
                                       metadata=data)

    # Retrieve the metadata and print it.
    print '*** Retrieving metadata...'
    metadata_href = bundle_ref['_links']['clarify:metadata']['href']
    metadata = clarify.get_metadata(metadata_href)
    print_metadata_info_quiet(metadata)

    # Delete the metadata and print it.
    print '*** Deleting metadata...'
    clarify.delete_metadata(metadata['_links']['self']['href'])

    # Retrieve the metadata and print it.
    print '*** Retrieving metadata...'
    metadata = clarify.get_metadata(metadata_href)
    print_metadata_info_quiet(metadata)
def create_and_update():
    """Create a bundle with metadata, print it, update it, and print it."""

    # Create a bundle with some metadata.
    print '*** Creating a bundle with mythical metadata...'
    data = {'wife': 'Medea', 'husband': 'Jason'}
    bundle_ref = clarify.create_bundle(name='metadata update test',
                                       metadata=data)

    # Retrieve the metadata and print it.
    print '*** Retrieving metadata...'
    href = bundle_ref['_links']['clarify:metadata']['href']
    metadata = clarify.get_metadata(href)
    print_metadata_info_quiet(metadata)

    # Change the metadata
    print '*** Changing metadata...'
    data2 = {'wife': 'Clytemnestra', 'husband': ['Agamemnon', 'Aegisthus']}
    clarify.update_metadata(href, data2)

    # Retrieve the metadata and print it.
    print '*** Retrieving metadata...'
    metadata = clarify.get_metadata(href)
    print_metadata_info_quiet(metadata)
Esempio n. 10
0
def create_and_update():
    """Create a bundle with metadata, print it, update it, and print it."""

    # Create a bundle with some metadata.
    print '*** Creating a bundle with mythical metadata...'
    data = {'wife': 'Medea', 'husband': 'Jason'}
    bundle_ref = clarify.create_bundle(name='metadata update test',
                                       metadata=data)

    # Retrieve the metadata and print it.
    print '*** Retrieving metadata...'
    href = bundle_ref['_links']['clarify:metadata']['href']
    metadata = clarify.get_metadata(href)
    print_metadata_info_quiet(metadata)

    # Change the metadata
    print '*** Changing metadata...'
    data2 = {'wife': 'Clytemnestra', 'husband': ['Agamemnon', 'Aegisthus']}
    clarify.update_metadata(href, data2)

    # Retrieve the metadata and print it.
    print '*** Retrieving metadata...'
    metadata = clarify.get_metadata(href)
    print_metadata_info_quiet(metadata)
Esempio n. 11
0
def track_create_and_list():
    """Create a bundle with a track, print it, add a track, print them."""

    print '*** Creating a bundle with a track...'

    # Create a bundle with a track.
    bundle_ref = clarify.create_bundle(name='track tester',
                                       media_url=MEDIA_URL1)

    # List the tracks.
    track_list_ref = bundle_ref['_links']['clarify:tracks']['href']
    track_list = clarify.get_track_list(track_list_ref)
    for track in track_list['tracks']:
        print_track_quiet(track)

    print '*** Adding a track to the bundle...'

    # Add a track.
    clarify.create_track(track_list_ref, media_url=MEDIA_URL2)

    # List the tracks.
    track_list = clarify.get_track_list(track_list_ref)
    for track in track_list['tracks']:
        print_track_quiet(track)
Esempio n. 12
0
def track_create_and_list():
    """Create a bundle with a track, print it, add a track, print them."""

    print '*** Creating a bundle with a track...'

    # Create a bundle with a track.
    bundle_ref = clarify.create_bundle(name='track tester',
                                       media_url=MEDIA_URL1)

    # List the tracks.
    track_list_ref = bundle_ref['_links']['clarify:tracks']['href']
    track_list = clarify.get_track_list(track_list_ref)
    for track in track_list['tracks']:
        print_track_quiet(track)

    print '*** Adding a track to the bundle...'

    # Add a track.
    clarify.create_track(track_list_ref, media_url=MEDIA_URL2)

    # List the tracks.
    track_list = clarify.get_track_list(track_list_ref)
    for track in track_list['tracks']:
        print_track_quiet(track)