From 8e91764c4c06aff57d158e853e3e51d191dcd3dd Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Tue, 23 Jun 2020 12:47:06 +0300 Subject: [PATCH] feat(resolve): create compound clip wip --- pype/hosts/resolve/lib.py | 34 ++++++++++++++++++++++++---------- pype/hosts/resolve/utils.py | 4 ++-- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/pype/hosts/resolve/lib.py b/pype/hosts/resolve/lib.py index 9232f8ec68..5a5980a462 100644 --- a/pype/hosts/resolve/lib.py +++ b/pype/hosts/resolve/lib.py @@ -1,4 +1,5 @@ import sys +import json from pype.api import Logger log = Logger().get_logger(__name__, "resolve") @@ -140,14 +141,14 @@ def create_compound_clip(clip_data, folder, presets): # get metadata mp_item = clip_item.GetMediaPoolItem() mp_props = mp_item.GetClipProperty() - metadata = get_metadata_from_clip(clip_item) + clip_attributes = get_clip_attributes(clip_item) mp = project.GetMediaPool() # keep original sequence sq_origin = sequence - # print(f"_ sequence: {sequence}") - # print(f"_ metadata: {pformat(metadata)}") + print(f"_ sequence: {sequence}") + print(f"_ metadata: {pformat(clip_attributes)}") # Set current folder to input media_pool_folder: mp.SetCurrentFolder(folder) @@ -163,7 +164,12 @@ def create_compound_clip(clip_data, folder, presets): # Create empty timeline in current folder and give name: cct = mp.CreateEmptyTimeline(name) - print(f"_ cct: {cct}") + + # check if clip doesnt exist already: + clips = folder.GetClipList() + cct = next((c for c in clips + if c.GetName() in name), None) + print(f"_ cct created: {cct}") # Set current timeline to created timeline: project.SetCurrentTimeline(cct) @@ -180,10 +186,19 @@ def create_compound_clip(clip_data, folder, presets): # Set current timeline to the working timeline: project.SetCurrentTimeline(sq_origin) - # Add collected metadata to the comound clip: - done = mp_item.SetClipProperty("pypeMetadata", metadata) + # Add collected metadata and attributes to the comound clip: + clip_attributes["VFX Notes"] = mp_item.GetMetadata( + "VFX Notes")["VFX Notes"] + clip_attributes = json.dumps(clip_attributes) + + for k, v in mp_item.GetMetadata().items(): + done = cct.SetMetadata(k, v) + + done = cct.SetMetadata("VFX Notes", clip_attributes) print(f"_ done2: {done}") + # # add clip item as take to timeline + # AddTake(cct, startFrame, endFrame) return cct @@ -203,15 +218,15 @@ def validate_tc(x): print('Invalid timecode. Try again.') -def get_metadata_from_clip(clip): +def get_clip_attributes(clip): """ - Collect all metadata from resolve timeline item + Collect basic atrributes from resolve timeline item Args: clip (resolve.TimelineItem): timeline item object Returns: - dict: all collected metadata as key: values + dict: all collected attributres as key: values """ mp_item = clip.GetMediaPoolItem() @@ -222,7 +237,6 @@ def get_metadata_from_clip(clip): "clipRightOffset": clip.GetRightOffset(), "clipMarkers": clip.GetMarkers(), "clipFlags": clip.GetFlagList(), - "sourceMetadata": mp_item.GetMetadata(), "sourceId": mp_item.GetMediaId(), "sourceProperties": mp_item.GetClipProperty() } diff --git a/pype/hosts/resolve/utils.py b/pype/hosts/resolve/utils.py index dcc92c5b8d..e11cc64b3b 100644 --- a/pype/hosts/resolve/utils.py +++ b/pype/hosts/resolve/utils.py @@ -70,9 +70,9 @@ def get_resolve_module(): sys.exit() # assign global var and return bmdvr = bmd.scriptapp("Resolve") - bmdvf = bmd.scriptapp("Fusion") + # bmdvf = bmd.scriptapp("Fusion") resolve.bmdvr = bmdvr - resolve.bmdvf = bmdvf + resolve.bmdvf = bmdvr.Fusion() log.info(("Assigning resolve module to " f"`pype.hosts.resolve.bmdvr`: {resolve.bmdvr}")) log.info(("Assigning resolve module to "