Skip to content

Commit

Permalink
Update shotgrid integration to have path to movie and path to frame
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementHector committed Feb 10, 2022
1 parent 93b6094 commit 6913a2d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
import pyblish.api

class IntegrateShotgridPublish(pyblish.api.InstancePlugin):
""" Commit components to server. """
"""
Create published Files from representations and add it to version. If
representation is tagged add shotgrid review, it will add it in
path to movie for a movie file or path to frame for an image sequence.
"""

order = pyblish.api.IntegratorOrder+0.499
label = "Shotgrid Published Files"
Expand All @@ -18,9 +22,42 @@ def process(self, instance):
for representation in instance.data.get("representations", []):

local_path = representation.get("published_path")

code = os.path.basename(local_path)

if "thumbnail" in representation.get("tags", []):
continue

if "shotgridreview" in representation.get("tags", []):
self.log.info(
"Upload review: {} for version shotgrid {}".format(
local_path, shotgrid_version.get("id"))
)
self.sg.upload(
"Version",
shotgrid_version.get("id"),
local_path,
field_name="sg_uploaded_movie"
)

data_path_to = {}
if representation["ext"] in ["mov", "avi"]:
data_path_to["sg_path_to_movie"] = local_path
elif representation["ext"] in ["jpg", "png", "exr", "tga"]:
data_path_to["sg_path_to_frames"] = local_path

self.sg.update(
"Version",
shotgrid_version.get("id"),
data_path_to
)
continue

published_file = self._find_existing_publish(
code,
context,
shotgrid_version
)

published_file_data = {
"project": context.data.get("shotgridProject"),
"code": code,
Expand All @@ -29,13 +66,6 @@ def process(self, instance):
"version": shotgrid_version,
"path": {"local_path": local_path}
}

published_file = self._find_existing_publish(
code,
context,
shotgrid_version
)

if not published_file:
published_file = self._create_published(published_file_data)
self.log.info(
Expand All @@ -51,18 +81,6 @@ def process(self, instance):
"Update Shotgrid PublishedFile: {}".format(published_file)
)

if "shotgridreview" in representation.get("tags", []):
self.log.info(
"Upload review: {} for version shotgrid {}".format(
local_path, shotgrid_version.get("id"))
)
self.sg.upload(
"Version",
shotgrid_version.get("id"),
local_path,
field_name="sg_uploaded_movie"
)

if instance.data["family"] == 'image':
self.sg.upload_thumbnail(
published_file["type"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ def process(self, instance):
self.log.info("Create Shotgrid version: {}".format(version))
else:
self.log.info("Use existing Shotgrid version: {}".format(version))
self.sg.update("Version", version['id'], _additional_version_data(context))

data_to_update = {}
status = context.data.get("intent", {}).get("value")
if status:
data_to_update["sg_status_list"] = status

self.log.info("Update Shotgrid version with {}".format(data_to_update))
self.sg.update("Version", version['id'], data_to_update)

instance.data["shotgridVersion"] = version

Expand All @@ -57,16 +64,4 @@ def _create_version(self, code, context):
"code": code,
}

version_data.update(_additional_version_data(context))

return self.sg.create("Version", version_data)


def _additional_version_data(context):
data = {}

status = context.data.get("intent", {}).get("value")
if status:
data["sg_status_list"] = status

return data

0 comments on commit 6913a2d

Please sign in to comment.