Skip to content

collect_clip_instances

CollectClipInstance

Bases: InstancePlugin

Collect clip instances and resolve its parent

Source code in client/ayon_traypublisher/plugins/publish/collect_clip_instances.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
class CollectClipInstance(pyblish.api.InstancePlugin):
    """Collect clip instances and resolve its parent"""

    label = "Collect Clip Instances"
    order = pyblish.api.CollectorOrder - 0.081

    hosts = ["traypublisher"]
    families = [
        "plate",
        "review",
        "audio",
        "model",
        "camera",
        "render",
        "image",
        "workfile",
    ]

    def process(self, instance):
        creator_identifier = instance.data["creator_identifier"]
        if creator_identifier not in [
            "editorial_plate",
            "editorial_plate_advanced",
            "editorial_audio",
            "editorial_audio_advanced",
            "editorial_review",
            "editorial_model_advanced",
            "editorial_camera_advanced",
            "editorial_render_advanced",
            "editorial_image_advanced",
            "editorial_workfile_advanced",
        ]:
            return

        instance.data["families"].append("clip")

        parent_instance_id = instance.data["parent_instance_id"]
        edit_shared_data = instance.context.data["editorialSharedData"]
        instance.data.update(
            edit_shared_data[parent_instance_id]
        )

        if "editorialSourcePath" in instance.data.keys():
            instance.data["families"].append("trimming")

        repres = instance.data.pop("prep_representations", None)

        if not repres:
            return

        representations = []
        for repre in repres:
            tags = repre.get("tags", [])
            custom_tags = repre.get("custom_tags", [])
            content_type = repre["content_type"]

            if content_type == "thumbnail":
                tags.append("thumbnail")

            # single file type should be a string
            new_repre_files = repre["files"]
            if len(new_repre_files) == 1:
                new_repre_files = new_repre_files[0]

            # create new representation data
            new_repre_data = {
                "ext": repre["ext"],
                "name": repre["name"],
                "files": new_repre_files,
                "stagingDir": repre["dir_path"],
                "tags": tags,
                "custom_tags": custom_tags,
            }

            # add optional keys
            if "outputName" in repre.keys():
                new_repre_data["outputName"] = repre["outputName"]

            representations.append(new_repre_data)

        instance.data["representations"] = representations

        self.log.debug(pformat(instance.data))