From f224bf6246b5ed58c192b87a3798e36cc2e44ab4 Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Fri, 28 Oct 2022 17:58:01 +0200 Subject: capture-pipeline: Refactor output/shot/part name Signed-off-by: Paul Kocialkowski --- capture-pipeline | 118 ++++++++++++++++++++++++------------------------------- 1 file changed, 52 insertions(+), 66 deletions(-) diff --git a/capture-pipeline b/capture-pipeline index 4fb4820..f782dbf 100755 --- a/capture-pipeline +++ b/capture-pipeline @@ -116,29 +116,16 @@ def audio_output_base(sequence, shot): return base -def audio_output_name(sequence, shot, take, part = None): +def audio_output_name(sequence, shot, take, part): base = audio_output_base(sequence, shot) - label = shot_label(shot) - name = shot_name(shot) - - if part and "actions" in part: - actions = part["actions"] + name = shot_name(shot) + "-" - if len(actions) > 4: - actions = actions[:2] + actions[-2:] + part_name_part = part_name(part) + if part_name_part: + name += part_name_part + "-" - for action in actions: - name += action + "-" - - # remove separator - name = name[:-1] - elif label: - name = label - else: - return None - - if prefix: - name += "-" + prefix + # Remove final separator. + name = name[:-1] return name @@ -303,30 +290,14 @@ def video_output_base(sequence, shot): def video_output_name(sequence, shot, take, part): base = video_output_base(sequence, shot) - label = shot_label(shot) - name = shot_name(shot) + name = shot_name(shot) + "-" - if part and "actions" in part: - actions = part["actions"] + part_name_part = part_name(part) + if part_name_part: + name += part_name_part + "-" - if len(actions) > 4: - actions = actions[:2] + actions[-2:] - - if name: - name += "-" - else: - name = "" - - for action in actions: - name += action + "-" - - # Remove final separator. - name = name[:-1] - elif label: - if name: - name += "-" - else: - name = label + # Remove final separator. + name = name[:-1] return name @@ -466,6 +437,34 @@ def media_process(sequence, shot, take, part): audio_process(sequence, shot, take, part) video_process(sequence, shot, take, part) +# part + +def part_name(part): + name = "" + + if "subject" in part: + name += part["subject"] + "-" + + if "label" in part: + name += part["label"] + "-" + + if "actions" in part: + actions = part["actions"] + + if len(actions) > 2: + actions = actions[:1] + actions[-1:] + + for action in actions: + name += action + "-" + + if len(name) == 0: + return None + + # Remove final separator. + name = name[:-1] + + return name + # take def take_register(sequence, shot, take): @@ -490,41 +489,28 @@ def take_process(sequence, shot, take): # shot -def shot_prefix(shot): - label = "" - separator = "" +def shot_name(shot): + name = "" if "value" in shot: - label += separator + shot["value"] - separator = "-" + name += shot["value"] + "-" if "position" in shot: - label += separator + shot["position"] - separator = "-" + name += shot["position"] + "-" if "subject" in shot: - label += separator + shot["subject"] - separator = "-" + name += shot["subject"] + "-" - return label - -def shot_label(shot): if "label" in shot: - return shot["label"] + name += shot["label"] + "-" - return None + if len(name) == 0: + return None -def shot_name(shot): - prefix = shot_prefix(shot) - label = shot_label(shot) + # Remove final separator. + name = name[:-1] - if label: - if prefix: - return prefix + "-" + label - else: - return label - else: - return prefix + return name def shot_process(sequence, shot): print("- shot: " + shot_name(shot)) -- cgit v1.2.3