Skip to main content

Download media with python

The python client for Tator provides a utility called download_media that makes downloading media files easy. The example below will download all media in a project.

import tator
api = tator.get_api(host='https://cloud.tator.io', token=MY_TOKEN)
medias = api.get_media_list(PROJECT_ID)
for media in medias:
out_path = f"/tmp/{media.name}"
print(f"Downloading {media.name}...")
for progress in tator.util.download_media(api, media, out_path):
print(f"Download progress: {progress}%")

Like the web interface, the utility downloads the highest resolution file available. You can specify a resolution or role (streaming, archival, image, thumbnail, or thumbnail_gif) using additional arguments, for example:

for media in medias:
out_path = f"/tmp/{media.name}"
print(f"Downloading {media.name}...")
for progress in tator.util.download_media(api, media, out_path, 720, 'streaming'):
print(f"Download progress: {progress}%")