Assistance on Fetching Media Files (Shots and Sequences) Using Python ShotGrid API

Dear ShotGrid Community Team,

I hope this message finds you well. I am currently learning and exploring how to integrate ShotGrid with my web application using the ShotGrid Python API. So far, I’ve successfully been able to fetch thumbnails and images associated with shots and sequences. However, I am looking for further assistance on how I can fetch and display full media files (like videos) for shots and sequences using the API.

Here is an outline of my progress and goals:

  • Progress: I am currently able to retrieve thumbnails and images for individual shots using the ShotGrid API. These are displayed on my application without any issues.
  • Goal: My objective is to fetch the actual media content (such as video files or playable sequences) associated with shots, rather than just thumbnails. I would like to understand the correct approach or API methods that can be used to achieve this.

Could you please provide guidance on how I can retrieve shot media (in video format) via the Python ShotGrid API and how I can display these media files on my web application?

Additionally, if there are specific API endpoints or best practices for handling media retrieval and playback, I would greatly appreciate your insights.

Thank you in advance for your time and assistance. I look forward to any advice or resources that can help me better understand how to work with media assets in ShotGrid.

Hi, the API docs are pretty good, if you haven’t seen them yet. Here is how to download an attachment:
https://developers.shotgridsoftware.com/python-api/reference.html#shotgun_api3.shotgun.Shotgun.download_attachment

Videos are usually associated with Version entities in ShotGrid, Versions are linked to Shots, Tasks, Projects, etc.
Note that the media associated with a Version can be either uploaded as an attachment, or linked to a local file (since studios have their local network filesystem and that is faster than moving videos in and out of ShotGrid storage).

1 Like

Hello!

If you can get the attachment_id, then you can download it’s actual file like so:

    sg = shotgun_api3.Shotgun('host', 'user', 'key')
    stream = sg.download_attachment(attachment_id)

    file = open('path/to/destination', 'wb')
    file.write(stream)
    file.close()