conformtools 0.6.9 → 0.6.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/account-GFIQC77T.js +3 -0
  2. package/dist/analysis-engine-4K5K6L53.js +3 -0
  3. package/dist/{bridge-SX5TW4LC.js → bridge-73XMEZLH.js} +1 -1
  4. package/dist/browser/timeline_core_bg.wasm +0 -0
  5. package/dist/chunk-2MJAQROY.js +5 -0
  6. package/dist/{chunk-TXQR2HI2.js → chunk-56EEBHP2.js} +1 -1
  7. package/dist/{chunk-GM6QKY7W.js → chunk-6HZP2OJA.js} +1 -1
  8. package/dist/{chunk-VIBEEWPC.js → chunk-7QUSVHO2.js} +2 -2
  9. package/dist/chunk-CJYLQ3UM.js +5 -0
  10. package/dist/chunk-DFDXSIMI.js +39 -0
  11. package/dist/{chunk-3D3Z4TBR.js → chunk-DGXZB7MO.js} +1 -1
  12. package/dist/{chunk-PLRB2YXJ.js → chunk-DNS4ZYIO.js} +1 -1
  13. package/dist/chunk-DPA26AOI.js +3 -0
  14. package/dist/chunk-E5ENIKNR.js +7 -0
  15. package/dist/{chunk-A7FNR3T5.js → chunk-EEDLRRKU.js} +1 -1
  16. package/dist/{chunk-GTJ3EM6H.js → chunk-GM262EDM.js} +1 -1
  17. package/dist/{chunk-D4WPRRBT.js → chunk-ISKNIQVO.js} +1 -1
  18. package/dist/chunk-JHTMYXJM.js +20 -0
  19. package/dist/chunk-JKOB3U54.js +3 -0
  20. package/dist/{chunk-2BPR6LK6.js → chunk-JXTRQ3UG.js} +1 -1
  21. package/dist/chunk-NQNS4Y2B.js +3 -0
  22. package/dist/chunk-QHXX5GDD.js +440 -0
  23. package/dist/{chunk-NFJHWZJX.js → chunk-TDIY4NRQ.js} +1 -1
  24. package/dist/chunk-UGVGRL5M.js +3 -0
  25. package/dist/chunk-WJ5EWXP2.js +3 -0
  26. package/dist/chunk-XDI6CPPV.js +3 -0
  27. package/dist/chunk-XJNWAQON.js +7 -0
  28. package/dist/chunk-Y2QHZUGL.js +5 -0
  29. package/dist/{chunk-GK4YYKJ6.js → chunk-YC7QDS5U.js} +2 -2
  30. package/dist/chunk-YUO3UWPH.js +3 -0
  31. package/dist/chunk-ZVUKOFUX.js +6 -0
  32. package/dist/{claude-setup-IIWUB4CE.js → claude-setup-OKOPPDMB.js} +1 -1
  33. package/dist/cli.js +2 -2
  34. package/dist/conformtools-analyze +0 -0
  35. package/dist/conformtools-decode +0 -0
  36. package/dist/{cr3-wasm-HLJWEV2S.js → cr3-wasm-NYCB34ND.js} +1 -1
  37. package/dist/{dng-wasm-CQDLPM5V.js → dng-wasm-XCPPBXPZ.js} +1 -1
  38. package/dist/{dpx-wasm-TLGMM7BO.js → dpx-wasm-XACWNFPB.js} +1 -1
  39. package/dist/engine-274GQLUB.js +5 -0
  40. package/dist/{exr-wasm-2NPKPTVB.js → exr-wasm-FQBUR6QT.js} +1 -1
  41. package/dist/flame/hook/conformtools_flame/verbs.py +9 -9
  42. package/dist/framing-BKTUEUZO.js +3 -0
  43. package/dist/gfx-worker.js +1 -1
  44. package/dist/{h264-JJMZSUWW.js → h264-B2TLLEMI.js} +1 -1
  45. package/dist/{h264-mxf-DCUOGLDU.js → h264-mxf-3GED5PBT.js} +1 -1
  46. package/dist/host-relink-PTV44KXF.js +10 -0
  47. package/dist/hosts-D3TR2QEV.js +3 -0
  48. package/dist/http.js +2 -2
  49. package/dist/{inspect-FJKYPEXL.js → inspect-D3WEYL2W.js} +3 -3
  50. package/dist/{isobmff-VJOWP4MH.js → isobmff-C5A2EFKH.js} +1 -1
  51. package/dist/{mc-video-5MGGOQN4.js → mc-video-ARKIHPA7.js} +1 -1
  52. package/dist/mcp.js +1 -1
  53. package/dist/{media-NZYVREUF.js → media-3YMIZSSF.js} +1 -1
  54. package/dist/media_core-XOKN7UUF.js +9 -0
  55. package/dist/mxf-CQSI6H5T.js +3 -0
  56. package/dist/nuke/panel/python/conformtools_nuke/verbs.py +5 -5
  57. package/dist/{ops-X7NAREC4.js → ops-BCTGDBXT.js} +1 -1
  58. package/dist/peer-kit/ctpeer/__init__.py +1 -1
  59. package/dist/peer-kit/ctpeer/neutral.py +10 -10
  60. package/dist/premiere-uxp/lib/edit.js +94 -9
  61. package/dist/premiere-uxp/lib/markers.js +12 -11
  62. package/dist/premiere-uxp/lib/probe.js +6 -3
  63. package/dist/premiere-uxp/lib/verbs.js +1 -1
  64. package/dist/premiere-uxp/manifest.json +1 -1
  65. package/dist/{probe-F7WQHMIA.js → probe-COWUTQGN.js} +1 -1
  66. package/dist/{r3d-T5O6IIZZ.js → r3d-FX7V4BIE.js} +1 -1
  67. package/dist/{r3d-CXUNG6VS.js → r3d-I6EYEYX7.js} +1 -1
  68. package/dist/resolve-bridge.py +725 -88
  69. package/dist/sequence-patch-JVEZW24V.js +3 -0
  70. package/dist/{still-P4JJNTEO.js → still-WUCFH2WX.js} +1 -1
  71. package/dist/{still-wasm-DN5LPASS.js → still-wasm-RTPOMH7S.js} +1 -1
  72. package/dist/store-SZKXADGI.js +3 -0
  73. package/dist/{tiff-wasm-BPRDR6EB.js → tiff-wasm-N2S267IA.js} +1 -1
  74. package/dist/timeline-PEUC3G7K.js +3 -0
  75. package/dist/timeline_core-ZKQQHUA2.js +3 -0
  76. package/dist/wasm/media_core_bg.wasm +0 -0
  77. package/dist/wasm-threads/media_core_bg.wasm +0 -0
  78. package/dist/{wav-64SC6P7U.js → wav-HSCUCY4U.js} +1 -1
  79. package/package.json +1 -1
  80. package/dist/account-M53GEV7P.js +0 -3
  81. package/dist/chunk-5BSXYKLN.js +0 -20
  82. package/dist/chunk-623EA3TK.js +0 -6
  83. package/dist/chunk-AMRJXYL4.js +0 -3
  84. package/dist/chunk-DQGINJDV.js +0 -5
  85. package/dist/chunk-GRQJGEGV.js +0 -378
  86. package/dist/chunk-HNBA43BF.js +0 -5
  87. package/dist/chunk-J2JXLEAI.js +0 -3
  88. package/dist/chunk-MWDF2R26.js +0 -7
  89. package/dist/chunk-PFISREY4.js +0 -3
  90. package/dist/chunk-QVH44I66.js +0 -39
  91. package/dist/chunk-RJ6JA2LZ.js +0 -3
  92. package/dist/chunk-SGLQY53R.js +0 -3
  93. package/dist/chunk-WN53ARHJ.js +0 -3
  94. package/dist/chunk-XCKQHL4G.js +0 -9
  95. package/dist/engine-P6H5P6HP.js +0 -5
  96. package/dist/framing-3XIVHSUZ.js +0 -3
  97. package/dist/host-relink-UWML4C7W.js +0 -10
  98. package/dist/hosts-SRS5TEM6.js +0 -3
  99. package/dist/media_core-YZ3PABEG.js +0 -9
  100. package/dist/mxf-FJSRFLJC.js +0 -3
  101. package/dist/store-53BBZBND.js +0 -3
  102. package/dist/timeline-C3OZJBCZ.js +0 -3
  103. package/dist/timeline_core-IOENXK4Z.js +0 -3
@@ -68,7 +68,9 @@ def project_or_fail(resolve):
68
68
 
69
69
 
70
70
  def timelines(project):
71
- return [project.GetTimelineByIndex(i + 1) for i in range(int(project.GetTimelineCount() or 0))]
71
+ # Resolve can answer None for an index inside GetTimelineCount (seen on 21.1 in a project with deleted
72
+ # timelines): skipped, or every timeline after it could not be found by name
73
+ return [t for t in (project.GetTimelineByIndex(i + 1) for i in range(int(project.GetTimelineCount() or 0))) if t]
72
74
 
73
75
 
74
76
  def find_timeline(project, name):
@@ -111,19 +113,29 @@ def a_current(resolve, _args):
111
113
  "project": p.GetName(),
112
114
  "timelines": [x.GetName() for x in timelines(p)],
113
115
  "timeline": t.GetName() if t else None,
114
- "tracks": tracks_of(t) if t else [],
116
+ "tracks": tracks_of(p, t) if t else [],
115
117
  "page": resolve.GetCurrentPage(),
116
118
  "db": pm.GetCurrentDatabase() or {},
117
119
  }
118
120
 
119
121
 
120
- def tracks_of(t):
121
- """Every track of a timeline: kind, 1-based index, name, enabled, locked."""
122
+ def track_enabled(p, t, kind, i):
123
+ """Is the track on? Resolve 21 answers GetIsTrackEnabled False for EVERY track of a timeline that is not the
124
+ current one (measured 2026-10-27, 21.1: TOOLS_TL [False, False] while another was open, [True, True] once
125
+ current; its own .drt says on). So off the current timeline the answer is unknown: None, read as on."""
126
+ cur = p.GetCurrentTimeline()
127
+ if cur is None or cur.GetUniqueId() != t.GetUniqueId():
128
+ return None
129
+ return bool(t.GetIsTrackEnabled(kind, i))
130
+
131
+
132
+ def tracks_of(p, t):
133
+ """Every track of a timeline: kind, 1-based index, name, enabled (None: not the current timeline, unknown), locked."""
122
134
  out = []
123
135
  for kind in ("video", "audio", "subtitle"):
124
136
  for i in range(1, int(t.GetTrackCount(kind) or 0) + 1):
125
137
  out.append({"kind": kind, "index": i, "name": t.GetTrackName(kind, i),
126
- "enabled": bool(t.GetIsTrackEnabled(kind, i)), "locked": bool(t.GetIsTrackLocked(kind, i))})
138
+ "enabled": track_enabled(p, t, kind, i), "locked": bool(t.GetIsTrackLocked(kind, i))})
127
139
  return out
128
140
 
129
141
 
@@ -164,7 +176,9 @@ def _project(resolve, p, args):
164
176
  for c in clips:
165
177
  pr = c.GetClipProperty() or {}
166
178
  row = {"id": c.GetUniqueId(), "name": c.GetName(), "file": pr.get("File Path") or "", "start_tc": pr.get("Start TC") or "",
167
- "usage": pr.get("Usage") or "", "folder": path, "type": pr.get("Type") or ""}
179
+ "usage": pr.get("Usage") or "", "folder": path, "type": pr.get("Type") or "",
180
+ # Grade Tracer's camera-roll clue (0.9.5 metadata.py: "Camera #", else "Camera")
181
+ "camera": pr.get("Camera #") or pr.get("Camera") or ""}
168
182
  rows.append(row)
169
183
  for q in finds:
170
184
  if ("/" in q and row["file"] and os.path.normpath(row["file"]) == os.path.normpath(q)) or (
@@ -185,9 +199,73 @@ def _project(resolve, p, args):
185
199
  j["CompletionPercentage"] = st.get("CompletionPercentage")
186
200
  jobs.append(j)
187
201
  t = find_timeline(p, args.get("timeline")) if (args.get("timeline") or p.GetCurrentTimeline()) else None
202
+ used = None
203
+ if args.get("used"):
204
+ # every media pool clip any timeline holds (Unused Media): the pool's Usage count is stale until a timeline is
205
+ # read, so the timelines are walked here, ids only, in one call
206
+ used = set()
207
+ for x in timelines(p):
208
+ for kind in ("video", "audio"):
209
+ for n in range(1, int(x.GetTrackCount(kind) or 0) + 1):
210
+ for it in x.GetItemListInTrack(kind, n) or []:
211
+ mpi = it.GetMediaPoolItem()
212
+ if mpi:
213
+ used.add(mpi.GetUniqueId())
214
+ extra = {}
215
+ if args.get("export_dir"):
216
+ # every timeline as its own .drt (Grade Tracer reads another project in one visit)
217
+ extra["exported"] = [_export(resolve, p, {"timeline": x.GetName(), "out_path": os.path.join(
218
+ args["export_dir"], "%02d_%s.drt" % (i, safe_name(x.GetName())))}) for i, x in enumerate(timelines(p))]
219
+ if args.get("grades"):
220
+ extra["grades"] = _grab_grades(resolve, p, args["grades"], args["grades_dir"])
221
+ pm = resolve.GetProjectManager()
188
222
  return {"ok": True, "project": p.GetName(), "pool": walk(mp.GetRootFolder(), ""), "found": found,
189
- "jobs": jobs, "timeline": t.GetName() if t else None, "tracks": tracks_of(t) if t else [],
190
- "timelines": [x.GetName() for x in timelines(p)], "page": resolve.GetCurrentPage()}
223
+ "projects": [n for n in (pm.GetProjectListInCurrentFolder() or []) if n != p.GetName()], **extra,
224
+ "jobs": jobs, "timeline": t.GetName() if t else None, "tracks": tracks_of(p, t) if t else [],
225
+ "timelines": [x.GetName() for x in timelines(p)], "page": resolve.GetCurrentPage(),
226
+ **({"used": sorted(used)} if used is not None else {})}
227
+
228
+
229
+ def _grab_grades(resolve, p, items, out_dir):
230
+ """Each item's grade {key, timeline, track, start (record frames from the timeline start)} as a gallery still
231
+ .drx in out_dir (GrabStill + ExportStills: a grade leaves its project only this way; 0.9.5 listed other projects'
232
+ matches and never applied them). The tracks above the item are off while it is grabbed (the Color page grades
233
+ the topmost clip at the playhead) and the clip under the playhead is checked to be the item. Stills are deleted
234
+ from the gallery after; timeline, tracks, playhead and page put back. {key: path} or {key: {"error": why}}."""
235
+ os.makedirs(out_dir, exist_ok=True)
236
+ page, prev = resolve.GetCurrentPage(), p.GetCurrentTimeline()
237
+ album = p.GetGallery().GetCurrentStillAlbum()
238
+ got = {}
239
+ for x in items:
240
+ t = find_timeline(p, x["timeline"])
241
+ p.SetCurrentTimeline(t)
242
+ track, f0 = int(x["track"]), int(t.GetStartFrame())
243
+ off = [i for i in range(track + 1, int(t.GetTrackCount("video") or 0) + 1) if t.GetIsTrackEnabled("video", i)]
244
+ set_video_tracks(resolve, t, off, False)
245
+ tc0 = t.GetCurrentTimecode()
246
+ fps = float(t.GetSetting("timelineFrameRate") or 24)
247
+ n, f = int(round(fps)), f0 + int(x["start"])
248
+ resolve.OpenPage("color")
249
+ # ponytail: non-drop timecode (as a_still)
250
+ t.SetCurrentTimecode("%02d:%02d:%02d:%02d" % (f // (3600 * n), f // (60 * n) % 60, f // n % 60, f % n))
251
+ time.sleep(0.3)
252
+ cur = t.GetCurrentVideoItem()
253
+ before = set(os.listdir(out_dir))
254
+ if not cur or int(cur.GetStart()) != f:
255
+ got[x["key"]] = {"error": "the Color page did not land on the clip at %s" % x["start"]}
256
+ else:
257
+ still = t.GrabStill()
258
+ ok = still and album.ExportStills([still], out_dir, "g%s" % x["key"], "drx")
259
+ if still:
260
+ album.DeleteStills([still])
261
+ new = sorted(n_ for n_ in set(os.listdir(out_dir)) - before if n_.endswith(".drx"))
262
+ got[x["key"]] = os.path.join(out_dir, new[0]) if ok and new else {"error": "Resolve exported no grade"}
263
+ t.SetCurrentTimecode(tc0)
264
+ set_video_tracks(resolve, t, off, True)
265
+ if prev:
266
+ p.SetCurrentTimeline(prev)
267
+ resolve.OpenPage(page)
268
+ return got
191
269
 
192
270
 
193
271
  def a_export(resolve, args):
@@ -273,7 +351,7 @@ def _export_clip(resolve, p, args):
273
351
 
274
352
  def a_clip_lut(resolve, args):
275
353
  """The grade of the video clip at (track, start: record frames from the timeline start) as Resolve's own 3D LUT
276
- (TimelineItem.ExportLUT, 33-point .cube): its colour function through every node, for the app's viewer to paint
354
+ (TimelineItem.ExportLUT, 33-point .cube): its color function through every node, for the app's viewer to paint
277
355
  the clip as Resolve shows it. Spatial tools (blur, windows, NR) are not in a LUT."""
278
356
  _pm, p = project_or_fail(resolve)
279
357
  t = find_timeline(p, args.get("timeline"))
@@ -360,6 +438,36 @@ def pool_ids(folder):
360
438
  return ids
361
439
 
362
440
 
441
+ def _append_piece(mp, t, clip, pc, track, t0):
442
+ """One piece (pc: src_in / src_out source frames, start / end record frames from the head) of `clip` onto `track`
443
+ of the CURRENT timeline. AppendToTimeline takes endFrame EXCLUSIVE and lands within a frame or two on a source at
444
+ another rate (0.9.5, measured 2026-09-08): read back, and when the length is off re-appended with the window
445
+ scaled (3 tries). Returns (item or None, exact)."""
446
+ want = int(pc["end"]) - int(pc["start"])
447
+ src = max(1, int(pc["src_out"]) - int(pc["src_in"]))
448
+ got, item = None, None
449
+ for attempt in range(3):
450
+ res = mp.AppendToTimeline([{"mediaPoolItem": clip, "startFrame": int(pc["src_in"]), "endFrame": int(pc["src_in"]) + src,
451
+ "recordFrame": t0 + int(pc["start"]), "trackIndex": track, "mediaType": 1}]) or []
452
+ item = res[0] if res else None
453
+ got = int(item.GetEnd()) - int(item.GetStart()) if item else None
454
+ if got is None or got == want or got <= 0 or attempt == 2 or not t.DeleteClips([item]):
455
+ break
456
+ src = max(1, int(round(src * want / got)))
457
+ return item, item is not None and got == want and int(item.GetStart()) == t0 + int(pc["start"])
458
+
459
+
460
+ def pool_by_uid(folder, uids, out=None):
461
+ """{unique id: media pool item} for the clips named, anywhere under `folder`."""
462
+ out = {} if out is None else out
463
+ for c in folder.GetClipList() or []:
464
+ if c.GetUniqueId() in uids:
465
+ out[c.GetUniqueId()] = c
466
+ for sub in folder.GetSubFolderList() or []:
467
+ pool_by_uid(sub, uids, out)
468
+ return out
469
+
470
+
363
471
  def mislinked(tl, named, before):
364
472
  """Items linked to a clip that was in the pool BEFORE the import and is a file the timeline file
365
473
  does not name: [(clip, frame, linked path)]. Clips the import made are its own (any path form)."""
@@ -467,12 +575,132 @@ def a_open(resolve, args):
467
575
  notes = []
468
576
  if tl.GetName() != name: # Resolve may name it after the file
469
577
  tl.SetName(name)
578
+ settings = None
579
+ if args.get("settings_from"):
580
+ # the new timeline carries the source timeline's settings, verified, or it is deleted (0.9.5 timeline_settings.py)
581
+ src = find_timeline(p, args["settings_from"])
582
+ try:
583
+ settings = inherit_settings(p, src, tl)
584
+ except BridgeFail as e:
585
+ mp.DeleteTimelines([tl])
586
+ restored = restore()
587
+ fail("settings_failed", "%s; the new timeline was deleted, nothing changed" % e.message, restored=restored, failed=e.extra.get("failed", []))
588
+ notes += settings.get("notes", [])
470
589
  got = tl.GetName()
471
590
  restored = restore() if not args.get("stay") else False
472
591
  if not opts.get("sourceClipsPath") and args.get("media_dir"):
473
592
  notes.append("media_dir was not used" + (" (link_existing links to clips already in the pool)" if link else ""))
474
593
  return {"ok": True, "project": p.GetName(), "timeline": got, "folder": folder_name if folder else None,
475
- "linked_existing": link, "restored": restored, "notes": notes}
594
+ "linked_existing": link, "restored": restored, "notes": notes,
595
+ **({"settings": settings["inheritance"]} if settings else {})}
596
+
597
+
598
+ # ── timeline settings: a generated timeline is the source's in every setting, or it does not exist ─────────────
599
+ # Ported from the 0.9.5 app (python/resolve_bridge/utils/timeline_settings.py, 2026-07 field incidents): a
600
+ # generated timeline silently on project defaults shipped wrong color science / data levels / SDI config.
601
+ SETTINGS_CRITICAL = ("timelineResolutionWidth", "timelineResolutionHeight", "timelineFrameRate", "colorScienceMode",
602
+ "colorSpaceTimeline", "colorSpaceTimelineGamma", "colorSpaceInput", "colorSpaceInputGamma",
603
+ "colorSpaceOutput", "colorSpaceOutputGamma", "separateColorSpaceAndGamma", "videoDataLevels",
604
+ "videoMonitorFormat", "videoMonitorSDIConfiguration", "videoMonitorUse444SDI")
605
+ # only meaningful under a colour-managed / ACES science: plain YRGB reads them '' whatever was written
606
+ SETTINGS_MANAGED_ONLY = ("colorSpaceInput", "colorSpaceInputGamma", "colorSpaceOutput", "colorSpaceOutputGamma",
607
+ "separateColorSpaceAndGamma")
608
+ # Resolve's API refuses these on a custom-settings timeline under YRGB + split gamma (20.3.3, verified then): only a
609
+ # project-following timeline resolves them
610
+ SETTINGS_UNWRITABLE_SPLIT = ("colorSpaceInput", "colorSpaceInputGamma", "colorSpaceOutputGamma")
611
+
612
+
613
+ class BridgeFail(Exception):
614
+ def __init__(self, message, **extra):
615
+ super().__init__(message)
616
+ self.message, self.extra = message, extra
617
+
618
+
619
+ def _set_norm(v):
620
+ """A setting as Resolve compares it: "24" == "24.0" == 24.0, "1" == "true"."""
621
+ s = str(v).strip()
622
+ low = s.lower()
623
+ if low in ("true", "yes", "on"):
624
+ return "1"
625
+ if low in ("false", "no", "off"):
626
+ return "0"
627
+ try:
628
+ f = float(s)
629
+ return repr(int(f)) if f == int(f) else repr(f)
630
+ except (ValueError, OverflowError):
631
+ return low
632
+
633
+
634
+ def _set_value(v):
635
+ """The string SetSetting accepts: 25.0 → "25" (it refuses "25.0"), True → "1"."""
636
+ if isinstance(v, bool):
637
+ return "1" if v else "0"
638
+ if isinstance(v, float):
639
+ return str(int(v)) if v == int(v) else format(v, "g")
640
+ if isinstance(v, int):
641
+ return str(v)
642
+ if isinstance(v, str):
643
+ try:
644
+ f = float(v.strip())
645
+ if f == int(f) and ("." in v or "e" in v.lower()):
646
+ return str(int(f))
647
+ except (ValueError, OverflowError):
648
+ pass
649
+ return v
650
+
651
+
652
+ def inherit_settings(p, src, tl):
653
+ """Give `tl` (just made) `src`'s settings and prove it. A project-following source → the new timeline follows the
654
+ project too and every critical key's effective value is compared (nothing written: the only way split-gamma keys
655
+ come out right). A custom source → custom settings flipped first (nothing else sticks before it), every setting
656
+ applied, the interdependent monitor keys re-applied until they settle, and the critical ones read back. A critical
657
+ key that does not match raises BridgeFail (the caller deletes the timeline)."""
658
+ follows = _set_norm(src.GetSetting("useCustomSettings") or "0") != "1"
659
+ science = str(src.GetSetting("colorScienceMode") or "").lower()
660
+ managed = "colormanaged" in science or "aces" in science
661
+ critical = [k for k in SETTINGS_CRITICAL if managed or k not in SETTINGS_MANAGED_ONLY]
662
+ # the user's live output re-clocks on every monitor key while the new timeline is current (SDI crash, 0.9.5):
663
+ # settings are written with the source current
664
+ cur = p.GetCurrentTimeline()
665
+ p.SetCurrentTimeline(src)
666
+ try:
667
+ if follows:
668
+ tl.SetSetting("useCustomSettings", "0")
669
+ applied = 0
670
+ else:
671
+ tl.SetSetting("useCustomSettings", "1")
672
+ if _set_norm(tl.GetSetting("useCustomSettings")) != "1":
673
+ raise BridgeFail("Resolve would not switch the new timeline to custom settings", failed=["useCustomSettings"])
674
+ want = dict((k, v) for k, v in (src.GetSetting() or {}).items() if k != "useCustomSettings" and v not in (None, ""))
675
+ for k in ("timelineResolutionWidth", "timelineResolutionHeight", "timelineOutputResolutionWidth", "timelineOutputResolutionHeight"):
676
+ v = src.GetSetting(k)
677
+ if v not in (None, ""):
678
+ want[k] = v
679
+ # only keys this timeline owns: bulk GetSetting leaks project-scope keys a timeline refuses honestly
680
+ want = dict((k, _set_value(v)) for k, v in want.items() if tl.GetSetting(k) not in (None, ""))
681
+ applied = sum(1 for k, v in want.items() if tl.SetSetting(k, v))
682
+ for _ in range(2): # convergence: a monitor key's legal values depend on its siblings' current values
683
+ pending = [(k, v) for k, v in want.items() if _set_norm(tl.GetSetting(k)) != _set_norm(v)]
684
+ if not pending or not any(tl.SetSetting(k, v) for k, v in pending):
685
+ break
686
+ failed, notes = [], []
687
+ for k in critical:
688
+ w = src.GetSetting(k)
689
+ if w in (None, ""):
690
+ continue
691
+ if _set_norm(tl.GetSetting(k)) != _set_norm(w):
692
+ if not follows and not managed and k in SETTINGS_UNWRITABLE_SPLIT:
693
+ notes.append("Resolve's scripting cannot set %s on a custom-settings timeline: set it in Timeline Settings > Color Management" % k)
694
+ continue
695
+ failed.append(k)
696
+ if follows and _set_norm(tl.GetSetting("useCustomSettings") or "0") == "1":
697
+ failed.insert(0, "useCustomSettings")
698
+ if failed:
699
+ raise BridgeFail("the new timeline did not take the source's %s" % ", ".join(failed), failed=failed)
700
+ return {"inheritance": "project-following" if follows else "custom (%d settings)" % applied, "notes": notes}
701
+ finally:
702
+ if cur:
703
+ p.SetCurrentTimeline(cur)
476
704
 
477
705
 
478
706
  def tc_frames(tc, fps):
@@ -542,6 +770,8 @@ def a_render_start(resolve, args):
542
770
  if p.IsRenderingInProgress():
543
771
  fail("busy", "Resolve is already rendering; we never interrupt someone else's render")
544
772
  target = args["target_dir"]
773
+ if args.get("queue") and args.get("disable_tracks"):
774
+ fail("invalid_args", "a queued job cannot leave tracks out: they would have to stay off until someone renders it")
545
775
  if not os.path.isdir(target):
546
776
  os.makedirs(target)
547
777
  page = resolve.GetCurrentPage()
@@ -575,6 +805,12 @@ def a_render_start(resolve, args):
575
805
  def _queue_and_start(resolve, p, tl, args, target, page, prev_tl, off):
576
806
  keep = "%s%d_%d" % (KEEP_PREFIX, os.getpid(), int(time.time() * 1000))
577
807
  kept = bool(p.SaveAsNewRenderPreset(keep))
808
+ # our job is ONE file of the range: in "Individual clips" mode (the artist's Deliver page can be left there) Resolve
809
+ # renders each clip under the range whole, at its source TC, named <name>_00000000 (live, 21.1: a 1-frame marker
810
+ # came out as its 72-frame clip). Single clip for our job; the artist's mode is put back once it is queued.
811
+ mode = p.GetCurrentRenderMode() if hasattr(p, "GetCurrentRenderMode") else None
812
+ if mode not in (None, 1):
813
+ p.SetCurrentRenderMode(1)
578
814
  routed, rejected = None, []
579
815
  if args.get("renderplugin") is not None:
580
816
  args["preset"] = QC_PRESET
@@ -607,6 +843,17 @@ def _queue_and_start(resolve, p, tl, args, target, page, prev_tl, off):
607
843
  p.DeleteRenderPreset(routed)
608
844
  if kept:
609
845
  p.LoadRenderPreset(keep)
846
+ if mode not in (None, 1):
847
+ p.SetCurrentRenderMode(mode)
848
+ if args.get("queue"):
849
+ # left in the queue for the artist (0.9.5 Marker Batch Renderer's "Add to Queue"): nothing started, their
850
+ # settings (loaded back above), timeline and page put back now
851
+ if kept:
852
+ p.DeleteRenderPreset(keep)
853
+ if prev_tl and prev_tl.GetName() != tl.GetName():
854
+ p.SetCurrentTimeline(prev_tl)
855
+ resolve.OpenPage(page)
856
+ return {"ok": True, "job_id": job, "queued": True, "timeline": tl.GetName(), "project": p.GetName(), "rejected_settings": rejected}
610
857
  # Starting a job loads ITS settings into the Deliver panel (measured on 21.1.1: ProRes 422 HQ
611
858
  # before a renderplugin scan, the plugin codec after), so the snapshot is kept and loaded again
612
859
  # when the job ends (render_finish), then deleted.
@@ -831,7 +1078,8 @@ def _write_qc_config(folder, config):
831
1078
  for k, v in params.items():
832
1079
  if k != "enabled":
833
1080
  lines.append("%s.%s=%s" % (check, k, int(v) if isinstance(v, bool) else v))
834
- with open(path, "w") as fh:
1081
+ # "\n" on every platform: Windows' text mode would end each line "\r\n" (the codec's lines then carry a "\r")
1082
+ with open(path, "w", newline="\n") as fh:
835
1083
  fh.write("\n".join(lines) + "\n")
836
1084
 
837
1085
 
@@ -840,12 +1088,33 @@ def a_clips(resolve, args):
840
1088
  what maps a measured frame to the clip that composites it."""
841
1089
  _pm, p = project_or_fail(resolve)
842
1090
  t = find_timeline(p, args.get("timeline"))
843
- out = []
1091
+ out, props = [], {}
844
1092
  for track in range(1, int(t.GetTrackCount("video") or 0) + 1):
1093
+ on = track_enabled(p, t, "video", track)
845
1094
  for i, it in enumerate(t.GetItemListInTrack("video", track) or []):
846
- out.append({"id": "%d:%d" % (track, i), "name": it.GetName(), "start": int(it.GetStart()),
847
- "end": int(it.GetEnd()), "track": track})
848
- return {"ok": True, "timeline": t.GetName(), "start_frame": int(t.GetStartFrame()),
1095
+ row = {"id": "%d:%d" % (track, i), "name": it.GetName(), "start": int(it.GetStart()),
1096
+ "end": int(it.GetEnd()), "track": track}
1097
+ if args.get("conform"):
1098
+ # Master QC's conform checks (0.9.5 build_timeline_model): enabled, the pool clip (a transition
1099
+ # has none) and its file / raster / codec, and with `grades` the node graph (count, LUTs, labels)
1100
+ mpi = it.GetMediaPoolItem()
1101
+ mid = str(mpi.GetUniqueId()) if mpi else ""
1102
+ if mid and mid not in props:
1103
+ props[mid] = mpi.GetClipProperty() or {}
1104
+ pr = props.get(mid, {})
1105
+ en = it.GetClipEnabled()
1106
+ row.update(enabled=en if isinstance(en, bool) else True, track_enabled=on if isinstance(on, bool) else True,
1107
+ mpi_id=mid, path=str(pr.get("File Path") or ""), resolution=str(pr.get("Resolution") or ""),
1108
+ codec=str(pr.get("Video Codec") or ""))
1109
+ if args.get("grades") and mid:
1110
+ try: # best effort, as 0.9.5 _node_graph: an older build without these reads leaves the row as is
1111
+ n = int(it.GetNumNodes() or 0)
1112
+ row.update(nodes=n, luts=[str(x) for x in (it.GetLUT(k) for k in range(1, n + 1)) if x],
1113
+ labels=[str(x) for x in (it.GetNodeLabel(k) for k in range(1, n + 1)) if x])
1114
+ except Exception:
1115
+ pass
1116
+ out.append(row)
1117
+ return {"ok": True, "project": p.GetName(), "timeline": t.GetName(), "start_frame": int(t.GetStartFrame()),
849
1118
  "end_frame": int(t.GetEndFrame()),
850
1119
  "width": int(float(t.GetSetting("timelineResolutionWidth") or 0)),
851
1120
  "height": int(float(t.GetSetting("timelineResolutionHeight") or 0)),
@@ -853,39 +1122,75 @@ def a_clips(resolve, args):
853
1122
 
854
1123
 
855
1124
  def a_markers(resolve, args):
856
- """Place or clear OUR markers on a timeline. Ours carry customData starting with the tag; a marker
857
- someone else placed is never edited or deleted, and a frame they occupy is skipped and reported."""
1125
+ """Place or clear OUR markers on a timeline, or on its video clips (a place with `clip: {track, start}`: frames from
1126
+ the timeline head; the marker sits at its offset into the clip, 0.9.5 Master QC "markers on clips"). Ours carry
1127
+ customData starting with the tag; a marker someone else placed is never edited or deleted: ours takes the next free
1128
+ frame. `reconcile`: ours from an earlier run, on the timeline or on any video clip, whose finding is gone turn green
1129
+ RESOLVED."""
858
1130
  _pm, p = project_or_fail(resolve)
859
1131
  t = find_timeline(p, args.get("timeline"))
860
- prefix = args["tag"]
1132
+ prefix, t0 = args["tag"], int(t.GetStartFrame())
1133
+ clips = {}
1134
+ for k in range(1, int(t.GetTrackCount("video") or 0) + 1):
1135
+ for it in t.GetItemListInTrack("video", k) or []:
1136
+ clips[(k, int(it.GetStart()) - t0)] = it
1137
+ hosts = {None: t} # None = the timeline; (track, start) = a clip
861
1138
 
862
- def ours_by_frame():
863
- return dict((int(f), m) for f, m in (t.GetMarkers() or {}).items()
864
- if str(m.get("customData") or "").startswith(prefix))
1139
+ def ours(h):
1140
+ return dict((int(f), m) for f, m in (h.GetMarkers() or {}).items() if str(m.get("customData") or "").startswith(prefix))
865
1141
 
866
1142
  cleared = 0
867
1143
  if args.get("clear"):
868
- for f in ours_by_frame():
869
- if t.DeleteMarkerAtFrame(f):
870
- cleared += 1
871
- placed, skipped = 0, []
1144
+ for h in [t] + list(clips.values()):
1145
+ for f in ours(h):
1146
+ cleared += int(bool(h.DeleteMarkerAtFrame(f)))
1147
+ placed, skipped, wanted = 0, [], set() # wanted: (host key, frame)
872
1148
  for m in args.get("place") or []:
873
- f = int(m["frame"]) # relative to the timeline start, as Resolve counts markers
874
- everyone = t.GetMarkers() or {}
875
- if f in ours_by_frame():
876
- t.DeleteMarkerAtFrame(f) # re-running replaces our own marker, never stacks a second
877
- elif f in everyone or float(f) in everyone:
878
- skipped.append(f) # someone else's: leave it
879
- continue
880
- if t.AddMarker(f, m.get("color", "Red"), m.get("name", "conform.tools"), m.get("note", ""),
881
- max(1, int(m.get("duration", 1))), m.get("tag", prefix)):
1149
+ key = (int(m["clip"]["track"]), int(m["clip"]["start"])) if m.get("clip") else None
1150
+ h = clips.get(key) if key else t
1151
+ f, dur, note = int(m["frame"]), max(1, int(m.get("duration", 1))), m.get("note", "")
1152
+ if key and h is None:
1153
+ key, h = None, t # no clip there now: the timeline holds it
1154
+ if key:
1155
+ f -= key[1] # a clip marker counts from the clip's first frame
1156
+ dur = max(1, min(dur, int(h.GetEnd()) - int(h.GetStart()) - f))
1157
+ hosts[key] = h
1158
+ everyone, mine = h.GetMarkers() or {}, ours(h)
1159
+ if f in mine and (key, f) not in wanted:
1160
+ h.DeleteMarkerAtFrame(f) # re-running replaces our own marker, never stacks a second
1161
+ else:
1162
+ # someone else's marker (or one this run already placed) holds the frame: Resolve keeps one per frame,
1163
+ # so ours takes the next free one and says so (bridge marker_add's rule); theirs is never touched
1164
+ g = f
1165
+ while (g in everyone or float(g) in everyone) and not (g in mine and (key, g) not in wanted):
1166
+ g += 1
1167
+ if g in mine:
1168
+ h.DeleteMarkerAtFrame(g)
1169
+ if g != f:
1170
+ note = "%s · %df after its frame (a marker was there)" % (note, g - f)
1171
+ f = g
1172
+ if h.AddMarker(f, m.get("color", "Red"), m.get("name", "conform.tools"), note, dur, m.get("tag", prefix)):
882
1173
  placed += 1
1174
+ wanted.add((key, f))
883
1175
  else:
884
1176
  skipped.append(f)
885
- return {"ok": True, "timeline": t.GetName(), "placed": placed, "cleared": cleared, "skipped": skipped}
886
-
887
-
888
- # ── live edits: what the IR does not hold (clip colour, flags, grades, versions, pool names) ─────
1177
+ resolved = 0
1178
+ if args.get("reconcile"):
1179
+ # a re-scan (0.9.5 reconcile_markers): ours whose finding is gone turn green "RESOLVED | …" on their frame,
1180
+ # never deleted, so the colorist sees what got fixed; one already resolved stays as it is
1181
+ done_tag = prefix + ":resolved"
1182
+ for key, h in [(None, t)] + list(clips.items()):
1183
+ for f, m in ours(h).items():
1184
+ if (key, f) in wanted or str(m.get("customData") or "").startswith(done_tag):
1185
+ continue
1186
+ note = m.get("note") or ""
1187
+ if h.DeleteMarkerAtFrame(f) and h.AddMarker(f, "Green", m.get("name") or "conform.tools", note if note.startswith("RESOLVED |") else "RESOLVED | " + note,
1188
+ max(1, int(m.get("duration") or 1)), done_tag):
1189
+ resolved += 1
1190
+ return {"ok": True, "timeline": t.GetName(), "placed": placed, "cleared": cleared, "skipped": skipped, "resolved": resolved}
1191
+
1192
+
1193
+ # ── live edits: what the IR does not hold (clip color, flags, grades, versions, pool names) ─────
889
1194
  #
890
1195
  # The tools decide in TypeScript, on the session read from this same timeline; `apply` only carries
891
1196
  # out a list of edits and reads each one back. A timeline item is addressed by kind + 1-based track
@@ -896,7 +1201,7 @@ def a_markers(resolve, args):
896
1201
  PROPS = ("Pan", "Tilt", "ZoomX", "ZoomY", "ZoomGang", "RotationAngle", "AnchorPointX", "AnchorPointY", "Pitch",
897
1202
  "Yaw", "FlipX", "FlipY", "CropLeft", "CropRight", "CropTop", "CropBottom", "CropSoftness", "CropRetain",
898
1203
  "DynamicZoomEase", "CompositeMode", "Opacity", "Distortion", "RetimeProcess", "MotionEstimation", "Scaling",
899
- "ResizeFilter")
1204
+ "ResizeFilter", "AudioVolume") # AudioVolume: an audio item's level, dB (0.9.5 Edit Index+)
900
1205
  VERSION_TYPE = {"local": 0, "remote": 1}
901
1206
 
902
1207
 
@@ -912,6 +1217,11 @@ def _item_index(t):
912
1217
  return by_pos, by_id
913
1218
 
914
1219
 
1220
+ def _marker_data(h):
1221
+ """{frame: customData} of the markers that carry one (0.9.5's marker "keyword"; a timeline file has none)."""
1222
+ return dict((str(int(f)), m.get("customData")) for f, m in (h.GetMarkers() or {}).items() if m.get("customData"))
1223
+
1224
+
915
1225
  def _item_row(it, kind, track, t0):
916
1226
  mpi = it.GetMediaPoolItem()
917
1227
  v = it.GetCurrentVersion() or {} if kind == "video" else {}
@@ -920,11 +1230,16 @@ def _item_row(it, kind, track, t0):
920
1230
  "id": it.GetUniqueId(), "name": it.GetName(), "color": it.GetClipColor() or "",
921
1231
  "flags": list(it.GetFlagList() or []), "enabled": bool(it.GetClipEnabled()),
922
1232
  "version": v.get("versionName", ""), "version_type": v.get("versionType"),
923
- "group": g.GetName() if g else "", "markers": len(it.GetMarkers() or {}),
1233
+ "group": g.GetName() if g else "", "markers": len(it.GetMarkers() or {}), "marker_data": _marker_data(it),
1234
+ "versions": list(it.GetVersionNameList(0) or []) if kind == "video" else [],
924
1235
  "nodes": int(it.GetNodeGraph().GetNumNodes() or 0) if kind == "video" and it.GetNodeGraph() else 0,
925
1236
  "stacks": _stacks(it) if kind == "video" else [],
926
1237
  "media_id": mpi.GetUniqueId() if mpi else "",
927
1238
  "src_in": _int_or_none(it.GetSourceStartFrame) if kind == "video" else None,
1239
+ # 21.1: the clip's retime and fades (Reconform carries them; Edit Index+ lists them)
1240
+ "speed": (it.GetSpeed() or {}).get("Percentage") if hasattr(it, "GetSpeed") else None,
1241
+ "zoom_x": it.GetProperty("ZoomX") if kind == "video" else None,
1242
+ "fades": (it.GetFades() or {}) if hasattr(it, "GetFades") else None,
928
1243
  "keywords": (mpi.GetMetadata("Keywords") or "") if mpi else ""}
929
1244
 
930
1245
 
@@ -960,7 +1275,7 @@ def _onto_local_version(it, name):
960
1275
 
961
1276
  def a_items(resolve, args):
962
1277
  """The live attributes of every item (or one kind/track) that a timeline file does not carry:
963
- clip colour, flags, enabled, grade version, colour group, node count, unique ids, keywords.
1278
+ clip color, flags, enabled, grade version, color group, node count, unique ids, keywords.
964
1279
  `into: scratch` reads our scratch project (as apply)."""
965
1280
  return _in_scratch(resolve, args, lambda p: _items(p, args))
966
1281
 
@@ -1070,11 +1385,14 @@ def _items(p, args):
1070
1385
  out.append(_item_row(it, kind, track, t0))
1071
1386
  groups = [g.GetName() for g in (p.GetColorGroupsList() or [])]
1072
1387
  return {"ok": True, "timeline": t.GetName(), "start_frame": t0, "items": out, "color_groups": groups,
1073
- "layers": int(p.GetSetting("nodeStackLayers") or 1)}
1388
+ "layers": int(p.GetSetting("nodeStackLayers") or 1), "marker_data": _marker_data(t),
1389
+ "playhead_tc": t.GetCurrentTimecode() or "",
1390
+ "raster": list(_raster(t)),
1391
+ **({"output_blanking": _blanking_px(t, *_raster(t))} if hasattr(t, "GetOutputBlanking") else {})}
1074
1392
 
1075
1393
 
1076
1394
  def _graph(it, t, where):
1077
- """A grade graph: {"layer": n} on the clip (1 = the first), "pre"/"post" = its colour group's
1395
+ """A grade graph: {"layer": n} on the clip (1 = the first), "pre"/"post" = its color group's
1078
1396
  pre/post-clip graph, "timeline" = the timeline grade."""
1079
1397
  w = where or {"layer": 1}
1080
1398
  if w.get("timeline"):
@@ -1082,7 +1400,7 @@ def _graph(it, t, where):
1082
1400
  if w.get("pre") or w.get("post"):
1083
1401
  g = it.GetColorGroup()
1084
1402
  if not g:
1085
- raise ValueError("the clip is in no colour group")
1403
+ raise ValueError("the clip is in no color group")
1086
1404
  return g.GetPreClipNodeGraph() if w.get("pre") else g.GetPostClipNodeGraph()
1087
1405
  return it.GetNodeGraph(int(w.get("layer", 1)))
1088
1406
 
@@ -1098,6 +1416,29 @@ def _same_value(a, b):
1098
1416
  return a == b
1099
1417
 
1100
1418
 
1419
+
1420
+ def _raster(t):
1421
+ return int(t.GetSetting("timelineResolutionWidth") or 1920), int(t.GetSetting("timelineResolutionHeight") or 1080)
1422
+
1423
+
1424
+ def _same_page(fn):
1425
+ """Resolve 21.1's Get/SetOutputBlanking (timeline and item) open the Color page by themselves (measured: from the
1426
+ Edit page, one call lands on Color; every other item read stays put). Run `fn` and put the artist's page back."""
1427
+ page = _RESOLVE.GetCurrentPage() if _RESOLVE else None
1428
+ try:
1429
+ return fn()
1430
+ finally:
1431
+ if page and _RESOLVE.GetCurrentPage() != page:
1432
+ _RESOLVE.OpenPage(page)
1433
+
1434
+
1435
+ def _blanking_px(t, w, h):
1436
+ """The timeline's output blanking in pixels per edge (Resolve answers edge coordinates; none = the full raster)."""
1437
+ e = _same_page(t.GetOutputBlanking) or {}
1438
+ f = lambda k, d: float(e.get(k, d) if e.get(k) is not None else d)
1439
+ return {"top": max(0, round(f("Top", 0))), "bottom": max(0, round(h - f("Bottom", h))),
1440
+ "left": max(0, round(f("Left", 0))), "right": max(0, round(w - f("Right", w)))}
1441
+
1101
1442
  def _op(p, t, op, find):
1102
1443
  """One edit → {ok, undo:[ops], detail?}. Raises on a bad address; returns ok False when Resolve refuses."""
1103
1444
  kind = op["op"]
@@ -1108,6 +1449,14 @@ def _op(p, t, op, find):
1108
1449
  here = (h.GetMarkers() or {})
1109
1450
  old = here.get(f) or here.get(float(f))
1110
1451
  addr = {"item": op["item"]} if op.get("item") else {}
1452
+ if kind == "marker_add" and old and op.get("data") and (old.get("customData") or "") != op["data"]:
1453
+ # Resolve holds one marker per frame and AddMarker over it replaces it: a tool's marker (tagged `data`)
1454
+ # never takes the frame of someone else's (the artist's, another tool's); it goes to the next free frame
1455
+ g = f + 1
1456
+ while here.get(g) or here.get(float(g)):
1457
+ g += 1
1458
+ op = dict(op, frame=g, note=("%s · %df after its frame (a marker was there)" % (op.get("note") or "", g - f)).lstrip(" ·"))
1459
+ f, old = g, None
1111
1460
  if kind == "marker_delete":
1112
1461
  if not old:
1113
1462
  return {"ok": True, "undo": [], "detail": "no marker there"}
@@ -1137,12 +1486,60 @@ def _op(p, t, op, find):
1137
1486
  if not ok and old: # put the old one back rather than lose it
1138
1487
  h.AddMarker(f, old["color"], old["name"], old["note"], int(old["duration"]), old.get("customData", ""))
1139
1488
  return {"ok": bool(ok), "undo": undo if ok else []}
1489
+ if kind == "timeline_output_blanking":
1490
+ # the timeline's output blanking (21.1+), as pixels per edge; Resolve speaks edge coordinates (0.9.5
1491
+ # utils/output_blanking.py, measured 21.1.0.14): {Top: 132, Bottom: 948, Left: 0, Right: 1920} is 132 px bars top and bottom
1492
+ if not hasattr(t, "SetOutputBlanking"):
1493
+ return {"ok": False, "undo": [], "detail": "output blanking needs Resolve 21.1 or later"}
1494
+ w, h = _raster(t)
1495
+ old = _blanking_px(t, w, h)
1496
+ want = {k: max(0, int(op.get(k) or 0)) for k in ("top", "bottom", "left", "right")}
1497
+ if want["top"] + want["bottom"] >= h or want["left"] + want["right"] >= w:
1498
+ return {"ok": False, "undo": [], "detail": "that blanking leaves no picture in %dx%d" % (w, h)}
1499
+ _same_page(lambda: t.SetOutputBlanking({"Top": want["top"], "Bottom": h - want["bottom"], "Left": want["left"], "Right": w - want["right"]}))
1500
+ got = _blanking_px(t, w, h) # a write Resolve did not keep is a failure, never a success
1501
+ return {"ok": got == want, "undo": [dict(op="timeline_output_blanking", **old)] if got == want else [],
1502
+ **({} if got == want else {"detail": "Resolve kept %s, not %s" % (got, want)})}
1140
1503
  if kind == "playhead": # navigation, not an edit: show the frame a finding is about
1141
1504
  return {"ok": bool(t.SetCurrentTimecode(op["tc"])), "undo": []}
1142
1505
  if kind == "timeline_rename":
1143
1506
  tl = find_timeline(p, op.get("timeline")) if op.get("timeline") else t
1144
1507
  old = tl.GetName()
1145
1508
  return {"ok": bool(tl.SetName(op["name"])), "undo": [{"op": "timeline_rename", "timeline": op["name"], "name": old}]}
1509
+ if kind == "pool_refresh":
1510
+ # files rewritten on disk (Odd Image Fixer): every pool clip on one of `paths` re-read with ReplaceClip on the same
1511
+ # path (0.9.5 odd_image_fix.execute), so Resolve takes the new size. Nothing to undo: it reads what is on disk.
1512
+ want = set(op.get("paths") or [])
1513
+ n, missed = 0, []
1514
+
1515
+ def walk(folder):
1516
+ nonlocal n
1517
+ for c in folder.GetClipList() or []:
1518
+ path = c.GetClipProperty("File Path") or ""
1519
+ if path in want:
1520
+ if c.ReplaceClip(path):
1521
+ n += 1
1522
+ else:
1523
+ missed.append(path)
1524
+ for sub in folder.GetSubFolderList() or []:
1525
+ walk(sub)
1526
+ walk(p.GetMediaPool().GetRootFolder())
1527
+ return {"ok": not missed, "refreshed": n, "undo": [], **({"detail": "Resolve did not re-read: " + ", ".join(os.path.basename(x) for x in missed)} if missed else {})}
1528
+ if kind == "timeline_discard":
1529
+ # 0.9.5 Reconformer's Discard: a built copy deleted by name — only one whose name ends _RECONFORMED, so this never
1530
+ # deletes a real timeline; when it is open, B (its name without the suffix) is opened first. No undo (said).
1531
+ name = str(op.get("timeline") or "")
1532
+ if not name.endswith("_RECONFORMED"):
1533
+ return {"ok": False, "undo": [], "detail": "only a ..._RECONFORMED timeline (a Reconform build) can be discarded"}
1534
+ tl = find_timeline(p, name) if name in [x.GetName() for x in timelines(p)] else None
1535
+ if tl is None:
1536
+ return {"ok": True, "undo": [], "detail": "already gone"}
1537
+ cur = p.GetCurrentTimeline()
1538
+ if cur is not None and cur.GetUniqueId() == tl.GetUniqueId():
1539
+ base = name[: -len("_RECONFORMED")]
1540
+ if base in [x.GetName() for x in timelines(p)]:
1541
+ p.SetCurrentTimeline(find_timeline(p, base))
1542
+ return {"ok": bool(p.GetMediaPool().DeleteTimelines([tl])), "undo": [], "detail": "deleted (a deleted timeline cannot be undone)"}
1146
1543
  if kind == "timeline_duplicate":
1147
1544
  # a copy of the timeline under a name no other timeline has (Reconform builds the new cut on one: B is
1148
1545
  # never edited); it becomes the open timeline. Undo leaves it: deleting a timeline is the artist's call.
@@ -1195,16 +1592,174 @@ def _op(p, t, op, find):
1195
1592
  p.SetCurrentTimeline(was)
1196
1593
  ok = placed == len(op["at"])
1197
1594
  return {"ok": ok, "clips": ids, "already": len(ids) - len(added), "placed": placed, "undo": undo}
1595
+ if kind == "history_track":
1596
+ # 0.9.5 Reconformer's HISTORY track: A's program (pieces: pool clip, Resolve's source window, record frame
1597
+ # from the timeline start) cut onto a new video track of this timeline, named and switched off. AppendToTimeline
1598
+ # takes endFrame EXCLUSIVE and lands within a frame or two on a source at another rate (0.9.5, measured
1599
+ # 2026-09-08): each piece is read back and, when its length is off, re-appended with the window scaled (3 tries);
1600
+ # one still off is counted, never dropped. Undo deletes the track.
1601
+ mp = p.GetMediaPool()
1602
+ was = p.GetCurrentTimeline()
1603
+ p.SetCurrentTimeline(t) # AppendToTimeline lays clips on the current timeline only
1604
+ try:
1605
+ t.AddTrack("video")
1606
+ k = int(t.GetTrackCount("video"))
1607
+ t0 = int(t.GetStartFrame())
1608
+ pool = pool_by_uid(mp.GetRootFolder(), {pc["media_id"] for pc in op["pieces"]})
1609
+ placed, off, missing = 0, 0, []
1610
+ for pc in op["pieces"]:
1611
+ clip = pool.get(pc["media_id"])
1612
+ if clip is None:
1613
+ missing.append(pc.get("name") or pc["media_id"])
1614
+ continue
1615
+ item, exact = _append_piece(mp, t, clip, pc, k, t0)
1616
+ if item is not None:
1617
+ placed += 1
1618
+ off += int(not exact)
1619
+ t.SetTrackName("video", k, op.get("name") or "V1 HISTORY")
1620
+ if _RESOLVE is not None and _RESOLVE.GetCurrentPage() != "edit": # SetTrackEnable lands on the Edit page only (21.1)
1621
+ _RESOLVE.OpenPage("edit")
1622
+ t.SetTrackEnable("video", k, False)
1623
+ finally:
1624
+ if was and was.GetUniqueId() != t.GetUniqueId():
1625
+ p.SetCurrentTimeline(was)
1626
+ return {"ok": placed == len(op["pieces"]), "track": k, "placed": placed, "off_by_frame": off,
1627
+ **({"detail": "not in the media pool: " + ", ".join(missing)} if missing else {}),
1628
+ "undo": [{"op": "track_delete", "kind": "video", "index": k}]}
1629
+ if kind == "drop_in":
1630
+ # 0.9.5 Reconformer "Drop in VFX": finished comps (files) into the pool's VFX bin and onto a new top video track,
1631
+ # each over its plate (pieces: path, comp frames src_in / src_out, record start / end from the head, the plate
1632
+ # {track, start}); the plate's sizing copied when the rasters agree (copy_sizing), plates switched off when asked,
1633
+ # a marker on each comp. Undo: the track, the comps this put in the pool, the plates back on.
1634
+ mp = p.GetMediaPool()
1635
+ cur = mp.GetCurrentFolder() # before the bin is made: Resolve makes a new bin current
1636
+ folder, _ = pool_folder(mp, op.get("folder") or "VFX", create=True)
1637
+ before = pool_ids(mp.GetRootFolder())
1638
+ mp.SetCurrentFolder(folder)
1639
+ try:
1640
+ paths = list(dict.fromkeys(pc["path"] for pc in op["pieces"]))
1641
+ clips = dict(zip(paths, mp.ImportMedia(paths) or []))
1642
+ finally:
1643
+ mp.SetCurrentFolder(cur)
1644
+ added = [c.GetUniqueId() for c in clips.values() if c.GetMediaId() not in before]
1645
+ was = p.GetCurrentTimeline()
1646
+ p.SetCurrentTimeline(t)
1647
+ undo, placed, off, why = [], 0, 0, []
1648
+ try:
1649
+ t.AddTrack("video")
1650
+ k = int(t.GetTrackCount("video"))
1651
+ t.SetTrackName("video", k, op.get("name") or "VFX")
1652
+ t0 = int(t.GetStartFrame())
1653
+ undo.append({"op": "track_delete", "kind": "video", "index": k})
1654
+ for pc in op["pieces"]:
1655
+ clip = clips.get(pc["path"])
1656
+ if clip is None:
1657
+ why.append("%s: Resolve did not import it" % os.path.basename(pc["path"]))
1658
+ continue
1659
+ item, exact = _append_piece(mp, t, clip, pc, k, t0)
1660
+ if item is None:
1661
+ why.append("%s: Resolve refused it at %d" % (os.path.basename(pc["path"]), int(pc["start"])))
1662
+ continue
1663
+ placed += 1
1664
+ off += int(not exact)
1665
+ plate = next((x for x in t.GetItemListInTrack("video", int(pc["plate"]["track"])) or []
1666
+ if int(x.GetStart()) - t0 == int(pc["plate"]["start"])), None) if pc.get("plate") else None
1667
+ if plate is not None and pc.get("copy_sizing"):
1668
+ for prop in ("Pan", "Tilt", "ZoomX", "ZoomY", "ZoomGang", "RotationAngle", "AnchorPointX", "AnchorPointY",
1669
+ "FlipX", "FlipY", "CropLeft", "CropRight", "CropTop", "CropBottom"):
1670
+ v = plate.GetProperty(prop)
1671
+ if v is not None and v != item.GetProperty(prop):
1672
+ item.SetProperty(prop, v)
1673
+ if plate is not None and op.get("disable_plates") and plate.GetClipEnabled():
1674
+ plate.SetClipEnabled(False)
1675
+ undo.append({"op": "enabled", "item": {"track": int(pc["plate"]["track"]), "start": int(pc["plate"]["start"])}, "on": True})
1676
+ item.AddMarker(0, "Cyan", "VFX drop-in", pc.get("note") or "", 1, "ConformTools:vfx-dropin")
1677
+ finally:
1678
+ if was and was.GetUniqueId() != t.GetUniqueId():
1679
+ p.SetCurrentTimeline(was)
1680
+ if added:
1681
+ undo.append({"op": "pool_delete", "clips": added})
1682
+ return {"ok": placed == len(op["pieces"]), "track": k, "placed": placed, "off_by_frame": off,
1683
+ **({"detail": "; ".join(why)} if why else {}), "undo": undo}
1684
+ if kind == "split_clip":
1685
+ # 0.9.5 Reconformer 2.4 (split_clip): one clip cut at record frames `at` (from the timeline head) into pieces at the
1686
+ # same record and source frames, each read back (exact length), the clip's sizing written onto every piece. The
1687
+ # timeline must be current (AppendToTimeline). Undo: the pieces out, the whole clip back.
1688
+ mpi = it.GetMediaPoolItem()
1689
+ if mpi is None:
1690
+ return {"ok": False, "undo": [], "detail": "a title or generator cannot be split here"}
1691
+ t0, start, end = int(t.GetStartFrame()), int(it.GetStart()), int(it.GetEnd())
1692
+ src0, track = int(it.GetSourceStartFrame()), int(op["item"]["track"])
1693
+ cuts = sorted(set(int(c) + t0 for c in op["at"] if start < int(c) + t0 < end))
1694
+ if not cuts:
1695
+ return {"ok": True, "undo": [], "detail": "no cut inside the clip"}
1696
+ props = {k: it.GetProperty(k) for k in PROPS if k != "AudioVolume"}
1697
+ bounds = [start] + cuts + [end]
1698
+ mp, was = p.GetMediaPool(), p.GetCurrentTimeline()
1699
+ p.SetCurrentTimeline(t)
1700
+ try:
1701
+ if not t.DeleteClips([it], False):
1702
+ return {"ok": False, "undo": [], "detail": "Resolve would not take the clip out to cut it"}
1703
+ made, exact = [], True
1704
+ for a0, a1 in zip(bounds, bounds[1:]):
1705
+ piece, ok = _append_piece(mp, t, mpi, {"src_in": src0 + a0 - start, "src_out": src0 + a1 - start, "start": a0 - t0, "end": a1 - t0}, track, t0)
1706
+ if piece is None:
1707
+ exact = False
1708
+ continue
1709
+ exact &= ok
1710
+ for k, v in props.items():
1711
+ if v is not None and not _same_value(v, piece.GetProperty(k)):
1712
+ piece.SetProperty(k, v)
1713
+ made.append(a0 - t0)
1714
+ finally:
1715
+ if was and was.GetUniqueId() != t.GetUniqueId():
1716
+ p.SetCurrentTimeline(was)
1717
+ undo = [{"op": "unsplit", "item": {"track": track, "start": made[0] if made else start - t0}, "pieces": made, "whole": {"src_in": src0, "src_out": src0 + end - start, "start": start - t0, "end": end - t0}, "props": props}]
1718
+ return {"ok": exact and len(made) == len(bounds) - 1, "pieces": made, "undo": undo,
1719
+ **({} if exact else {"detail": "a piece did not land at its exact frames"})}
1720
+ if kind == "unsplit":
1721
+ # split_clip's undo: the pieces out, the whole clip back at its frames with its sizing
1722
+ mpi = it.GetMediaPoolItem()
1723
+ track, t0 = int(op["item"]["track"]), int(t.GetStartFrame())
1724
+ pieces = [x for x in t.GetItemListInTrack("video", track) or [] if int(x.GetStart()) - t0 in set(op["pieces"])]
1725
+ mp, was = p.GetMediaPool(), p.GetCurrentTimeline()
1726
+ p.SetCurrentTimeline(t)
1727
+ try:
1728
+ t.DeleteClips(pieces, False)
1729
+ whole, ok = _append_piece(mp, t, mpi, op["whole"], track, t0)
1730
+ for k, v in (op.get("props") or {}).items():
1731
+ if whole is not None and v is not None and not _same_value(v, whole.GetProperty(k)):
1732
+ whole.SetProperty(k, v)
1733
+ finally:
1734
+ if was and was.GetUniqueId() != t.GetUniqueId():
1735
+ p.SetCurrentTimeline(was)
1736
+ return {"ok": whole is not None and ok, "undo": []}
1198
1737
  if kind == "track_delete":
1199
1738
  return {"ok": bool(t.DeleteTrack(op.get("kind", "video"), int(op["index"]))), "undo": []}
1739
+ if kind == "render_jobs_delete":
1740
+ # 0.9.5 Marker Batch Renderer's "delete jobs": the render queue's all / completed / incomplete jobs. A deleted
1741
+ # job cannot be brought back (no undo); one rendering now is never touched
1742
+ which = op.get("which", "completed")
1743
+ gone = 0
1744
+ for j in p.GetRenderJobList() or []:
1745
+ st = (p.GetRenderJobStatus(j["JobId"]) or {}).get("JobStatus", "")
1746
+ if st == "Rendering":
1747
+ continue
1748
+ done = st == "Complete"
1749
+ if which == "all" or (which == "completed" and done) or (which == "incomplete" and not done):
1750
+ gone += 1 if p.DeleteRenderJob(j["JobId"]) else 0
1751
+ return {"ok": True, "undo": [], "detail": "%d render job(s) deleted" % gone}
1200
1752
  if kind.startswith("pool_"):
1201
1753
  mp = p.GetMediaPool()
1202
1754
  clips = _pool_clips(mp, op["clips"] if "clips" in op else [op["clip"]])
1203
1755
  if kind == "pool_rename":
1204
1756
  c = clips[0]
1205
- old = c.GetClipProperty("Clip Name")
1206
- ok = c.SetClipProperty("Clip Name", op["name"])
1207
- return {"ok": bool(ok) and c.GetClipProperty("Clip Name") == op["name"],
1757
+ old = c.GetName()
1758
+ # SetClipProperty("Clip Name") answers False for renames that land (0.9.5 clip_renamer.py
1759
+ # _set_clip_name): the name read back is the truth; SetName where this Resolve has it
1760
+ if not (hasattr(c, "SetName") and c.SetName(op["name"])):
1761
+ c.SetClipProperty("Clip Name", op["name"])
1762
+ return {"ok": c.GetName() == op["name"],
1208
1763
  "undo": [{"op": "pool_rename", "clip": op["clip"], "name": old}]}
1209
1764
  if kind == "pool_move":
1210
1765
  olds = [_folder_path(mp, c) for c in clips]
@@ -1258,7 +1813,7 @@ def _op(p, t, op, find):
1258
1813
  return {"ok": False, "undo": [], "detail": "no media pool clip behind this item"}
1259
1814
  old = dict((k, mpi.GetMetadata(k) or "") for k in op["set"])
1260
1815
  return {"ok": bool(mpi.SetMetadata(op["set"])), "undo": [{"op": "metadata", "item": item, "set": old}]}
1261
- if kind in ("copy_properties", "copy_grade") and op.get("from_timeline"):
1816
+ if kind in ("copy_properties", "copy_grade", "copy_speed", "copy_fades") and op.get("from_timeline"):
1262
1817
  # the source lives in another timeline of the project (Grade Tracer, Reconform's carry)
1263
1818
  pos, ids = _item_index(find_timeline(p, op["from_timeline"]))
1264
1819
  a = op["item"]
@@ -1281,6 +1836,62 @@ def _op(p, t, op, find):
1281
1836
  refused += ["%s %s" % (json.dumps(a, sort_keys=True), k) for k, v in want.items()
1282
1837
  if v is not None and not _same_value(v, have[k]) and not x.SetProperty(k, v)]
1283
1838
  return {"ok": not refused, "refused": refused, "undo": undo}
1839
+ if kind == "copy_speed":
1840
+ # A's retime onto each target (0.9.5 _carry_speed / apply_speed, measured 21.1: SetSpeed with RippleTimeline
1841
+ # off keeps the record range, only the source consumed changes); read back; a ramp is not on the API: said
1842
+ if not hasattr(it, "GetSpeed"):
1843
+ return {"ok": False, "undo": [], "detail": "this Resolve has no clip speed in its API (21.1+)"}
1844
+ want = (it.GetSpeed() or {}).get("Percentage")
1845
+ if want is None:
1846
+ return {"ok": False, "undo": [], "detail": "the source clip's speed could not be read (a ramp is not on the API)"}
1847
+ undo, off = [], []
1848
+ for a in op["to"]:
1849
+ x = find(a)
1850
+ have = (x.GetSpeed() or {}).get("Percentage")
1851
+ if have is not None and abs(float(have) - float(want)) < 0.01:
1852
+ continue
1853
+ if not x.SetSpeed({"Percentage": float(want), "RippleTimeline": False}):
1854
+ off.append("%s refused" % json.dumps(a, sort_keys=True))
1855
+ continue
1856
+ got = (x.GetSpeed() or {}).get("Percentage")
1857
+ if got is None or abs(float(got) - float(want)) > 0.01:
1858
+ off.append("%s: asked %s%%, Resolve reports %s%%" % (json.dumps(a, sort_keys=True), want, got))
1859
+ undo.append({"op": "speed", "item": a, "percentage": have})
1860
+ return {"ok": not off, "undo": undo, **({"detail": "; ".join(off)} if off else {})}
1861
+ if kind == "speed":
1862
+ old = (it.GetSpeed() or {}).get("Percentage")
1863
+ ok = it.SetSpeed({"Percentage": float(op["percentage"]), "RippleTimeline": False})
1864
+ return {"ok": bool(ok), "undo": [{"op": "speed", "item": item, "percentage": old}] if ok and old is not None else []}
1865
+ if kind == "copy_fades":
1866
+ # A's fade in / out (frames, 21.1) onto each target, read back (0.9.5 _carry_fades)
1867
+ if not hasattr(it, "GetFades"):
1868
+ return {"ok": False, "undo": [], "detail": "this Resolve has no fades in its API (21.1+)"}
1869
+ src = it.GetFades() or {}
1870
+ want = {k: src[k] for k in ("FadeIn", "FadeOut") if k in src}
1871
+ undo, off = [], []
1872
+ for a in op["to"]:
1873
+ x = find(a)
1874
+ have = x.GetFades() or {}
1875
+ if all(have.get(k) == v for k, v in want.items()):
1876
+ continue
1877
+ x.SetFades(dict(have, **want))
1878
+ got = x.GetFades() or {}
1879
+ if any(got.get(k) != v for k, v in want.items()):
1880
+ off.append("%s: Resolve kept %s" % (json.dumps(a, sort_keys=True), {k: got.get(k) for k in want}))
1881
+ undo.append({"op": "fades", "item": a, "set": have})
1882
+ off.append("Resolve 21.1.1 does not save fades made by a script: they are gone when the project is reopened")
1883
+ return {"ok": len(off) == 1, "undo": undo, "detail": "; ".join(off)}
1884
+ if kind == "copy_grade" and op.get("drx"):
1885
+ # a grade from another project (Grade Tracer): its gallery still .drx, keyframes kept, start frames aligned
1886
+ stuck, short = [], []
1887
+ for a in op["to"]:
1888
+ x = find(a)
1889
+ if not _onto_local_version(x, "Version 1"):
1890
+ stuck.append(a)
1891
+ elif not x.GetNodeGraph().ApplyGradeFromDRX(op["drx"], 2):
1892
+ short.append(a)
1893
+ return {"ok": not stuck and not short, "undo": [], "unverified": stuck + short,
1894
+ **({"detail": "on a shared remote grade and could not move to a local version"} if stuck else {})}
1284
1895
  if kind == "copy_grade":
1285
1896
  targets = [find(a) for a in op["to"]]
1286
1897
  sv = it.GetCurrentVersion() or {}
@@ -1325,11 +1936,36 @@ def _op(p, t, op, find):
1325
1936
  it.SetFusionOutputCache(op["fusion"])
1326
1937
  return {"ok": True, "undo": [undo]}
1327
1938
  if kind == "fades":
1939
+ # Resolve refuses a partial dict: what is asked goes over what the clip has ({FadeIn, FadeOut}, frames; 21.1)
1328
1940
  old = it.GetFades() or {}
1329
- return {"ok": bool(it.SetFades(op["set"])), "undo": [{"op": "fades", "item": item, "set": old}]}
1941
+ want = dict(old, **(op.get("set") or {}))
1942
+ it.SetFades(want)
1943
+ got = it.GetFades() or {} # Resolve answers True and keeps nothing in some states: read back
1944
+ kept = all(float(got.get(k, -1)) == float(v) for k, v in want.items())
1945
+ # Resolve 21.1.1 keeps an API fade only until the project is reopened: SaveProject answers True and the next load
1946
+ # reads 0 (measured 2026-10-27, also with another edit in the same save). Said on every fade written.
1947
+ return {"ok": kept, "undo": [{"op": "fades", "item": item, "set": old}] if kept else [],
1948
+ "detail": ("Resolve kept %s, not %s" % (got, want)) if not kept else
1949
+ "set; Resolve 21.1.1 does not save fades made by a script: they are gone when the project is reopened"}
1950
+ if kind == "normalize_audio":
1951
+ # Timeline.NormalizeAudioLevel (Resolve 20+), one audio item: mode, target level (dBFS) / loudness (LKFS),
1952
+ # relative or independent; the undo puts the item's AudioVolume back
1953
+ old = it.GetProperty("AudioVolume")
1954
+ opts = {"normalizationMode": op.get("mode") or "Sample Peak Program"}
1955
+ if op.get("target_level") not in (None, ""):
1956
+ opts["targetLevel"] = float(op["target_level"])
1957
+ if op.get("target_loudness") not in (None, ""):
1958
+ opts["targetLoudness"] = float(op["target_loudness"])
1959
+ const = "NORMALIZE_AUDIO_SET_LEVEL_INDEPENDENT" if op.get("independent") else "NORMALIZE_AUDIO_SET_LEVEL_RELATIVE"
1960
+ if _RESOLVE is not None and hasattr(_RESOLVE, const):
1961
+ opts["setLevelMode"] = getattr(_RESOLVE, const)
1962
+ if not hasattr(t, "NormalizeAudioLevel"):
1963
+ return {"ok": False, "undo": [], "detail": "this Resolve has no audio normalization (Resolve 20+)"}
1964
+ ok = bool(t.NormalizeAudioLevel([it], opts))
1965
+ return {"ok": ok, "undo": [{"op": "properties", "item": item, "set": {"AudioVolume": old}}] if ok and old is not None else []}
1330
1966
  if kind == "output_blanking":
1331
- old = it.GetOutputBlanking() or {}
1332
- return {"ok": bool(it.SetOutputBlanking(op["set"])), "undo": [{"op": "output_blanking", "item": item, "set": old}]}
1967
+ old = _same_page(it.GetOutputBlanking) or {}
1968
+ return {"ok": bool(_same_page(lambda: it.SetOutputBlanking(op["set"]))), "undo": [{"op": "output_blanking", "item": item, "set": old}]}
1333
1969
  if kind == "drx":
1334
1970
  g = _graph(it, t, op.get("graph"))
1335
1971
  return {"ok": bool(g.ApplyGradeFromDRX(op["path"], int(op.get("mode", 0)))), "undo": []}
@@ -1344,7 +1980,7 @@ def _op(p, t, op, find):
1344
1980
  if op["target"] == "node":
1345
1981
  return _grade_node_kept(it, op, t)
1346
1982
  return _grade_sizing_kept(it, op, t)
1347
- if kind == "node_structure": # a .drx node tree onto the clip, on a new version (the colourist's own untouched)
1983
+ if kind == "node_structure": # a .drx node tree onto the clip, on a new version (the colorist's own untouched)
1348
1984
  return _grade_node_kept(it, dict(op, structure_only=True))
1349
1985
  if kind == "grade_version_back": # the undo of an Align: the clip back on the version it was on. Ours stays in the
1350
1986
  # version list, never deleted (whatever was graded on it since stays too): undo only switches versions
@@ -1354,19 +1990,6 @@ def _op(p, t, op, find):
1354
1990
  old = g.GetLUT(int(op["node"])) or ""
1355
1991
  return {"ok": bool(g.SetLUT(int(op["node"]), op["path"])),
1356
1992
  "undo": [{"op": "lut", "item": item, "graph": op.get("graph"), "node": op["node"], "path": old}]}
1357
- if kind == "node_copy":
1358
- # Copy (or swap) a whole node tree between grade graphs: CopyNodeTree → reset → PasteNodeTree,
1359
- # the one path that carries a full tree on every build tested (old app, node_stack_transfer.py).
1360
- dst_it = find(op["to_item"]) if op.get("to_item") else it
1361
- src, dst = _graph(it, t, op.get("from")), _graph(dst_it, t, op.get("to"))
1362
- n = int(src.GetNumNodes() or 0)
1363
- if not hasattr(src, "CopyNodeTree"):
1364
- return {"ok": False, "undo": [], "detail": "this Resolve has no node-tree copy in its API"}
1365
- # ponytail: no swap (needs a parking graph); copy A→B then B's old tree is gone. Add via a temp version if asked.
1366
- ok = bool(src.CopyNodeTree()) and bool(dst.ResetAllGrades()) and bool(dst.PasteNodeTree())
1367
- if ok and op.get("clear_source"):
1368
- src.ResetAllGrades()
1369
- return {"ok": ok and int(dst.GetNumNodes() or 0) == n, "nodes": n, "undo": []}
1370
1993
  raise ValueError("unknown op %r" % kind)
1371
1994
 
1372
1995
 
@@ -1466,19 +2089,19 @@ def _grade_state(it):
1466
2089
 
1467
2090
  def _grade_sizing(t, it, op):
1468
2091
  """The undo of a sizing written (by an older build) onto an UNGRADED clip: its grade reset. A clip that has a grade
1469
- since is left alone: nothing ever resets a colourist's grade."""
2092
+ since is left alone: nothing ever resets a colorist's grade."""
1470
2093
  n, tools, lut = _grade_state(it)
1471
2094
  if not (n <= 1 and not lut and (not tools or tools == ["Sizing"])):
1472
2095
  return {"ok": False, "undo": [], "refused": ["has a grade"], "detail": "refused: the clip has a grade now; nothing changed"}
1473
2096
  return {"ok": bool(it.GetNodeGraph(1).ResetAllGrades()), "undo": []}
1474
2097
 
1475
2098
 
1476
- # ── Input Sizing ADDED to the grade the clip has: nothing a colourist did is lost ──────────────────────────
2099
+ # ── Input Sizing ADDED to the grade the clip has: nothing a colorist did is lost ──────────────────────────
1477
2100
  #
1478
2101
  # The clip's grade as it stands comes in the op (`bodies`: every local and remote version's raw Body, read by the
1479
2102
  # engine from the timeline's .drt, grade-bodies.ts). The new Body = that Body with its clip-input record (root field 3,
1480
- # type 84) replaced by one carrying the sizing; every node, version, LUT and colour group is left exactly as it was.
1481
- # It goes onto a NEW local version (the colourist's own version is never written), checked node for node after.
2103
+ # type 84) replaced by one carrying the sizing; every node, version, LUT and color group is left exactly as it was.
2104
+ # It goes onto a NEW local version (the colorist's own version is never written), checked node for node after.
1482
2105
 
1483
2106
  ALIGNED = "conform.tools aligned"
1484
2107
 
@@ -1630,7 +2253,7 @@ def _gid(g):
1630
2253
  def splice_input_sizing(base_hex, op):
1631
2254
  """`base_hex` (a raw Body, "80…") with op's Input Sizing written into its clip-input record: ONLY the sizing group
1632
2255
  (10) is replaced — every other record and every other field and group of the clip-input record (whatever else the
1633
- colourist set there) is kept byte for byte. A grade without a clip-input record gets one carrying just the sizing.
2256
+ colorist set there) is kept byte for byte. A grade without a clip-input record gets one carrying just the sizing.
1634
2257
  Returns (new Body hex, whether the old Body already had Input Sizing of its own)."""
1635
2258
  if not base_hex.lower().startswith("80"):
1636
2259
  raise ValueError("grade body must be raw (80…)")
@@ -1659,7 +2282,7 @@ def splice_input_sizing(base_hex, op):
1659
2282
 
1660
2283
 
1661
2284
  def _signature(it):
1662
- """What a colourist made, node by node, on the clip's current version: tools, LUT, label."""
2285
+ """What a colorist made, node by node, on the clip's current version: tools, LUT, label."""
1663
2286
  g = it.GetNodeGraph(1)
1664
2287
  n = int(g.GetNumNodes() or 0) if g else 0
1665
2288
  label = getattr(g, "GetNodeLabel", None) if g else None
@@ -1668,7 +2291,7 @@ def _signature(it):
1668
2291
 
1669
2292
  def _aligned_version(it, vname, vtype):
1670
2293
  """The version our sizing goes on: (name, made). The clip already on OUR version (a re-run) is written in place;
1671
- anything else gets a new local version, so the colourist's own version is never written. (None, True) = no version."""
2294
+ anything else gets a new local version, so the colorist's own version is never written. (None, True) = no version."""
1672
2295
  if vtype == 0 and (vname or "").startswith(ALIGNED):
1673
2296
  return vname, False
1674
2297
  taken = set(it.GetVersionNameList(0) or [])
@@ -1758,20 +2381,23 @@ def _folder_path(mp, clip):
1758
2381
 
1759
2382
  def _in_scratch(resolve, args, fn):
1760
2383
  """fn(project) in the open project, or with `into: scratch` in our scratch project (`scratch_project`,
1761
- made if missing): the user's project is saved first and opened again afterwards, timeline and page as
2384
+ made if missing), or with `project` in that project of the library: the user's project is saved first and opened again afterwards, timeline and page as
1762
2385
  they were — the safe way for live tests and probes to edit (a_open does the same for imports)."""
1763
2386
  pm, p = project_or_fail(resolve)
1764
- if args.get("into") != "scratch":
2387
+ # `project`: another project of the library, visited the same way and never made (Grade Tracer across projects)
2388
+ other = args.get("project")
2389
+ if args.get("into") != "scratch" and not other:
1765
2390
  return fn(p)
1766
- scratch = args.get("scratch_project") or "conform.tools scratch"
2391
+ scratch = other or args.get("scratch_project") or "conform.tools scratch"
1767
2392
  user, page = p.GetName(), resolve.GetCurrentPage()
1768
2393
  tl = p.GetCurrentTimeline()
1769
2394
  utl = tl.GetName() if tl else None
1770
2395
  if user == scratch:
1771
2396
  return fn(p)
1772
2397
  pm.SaveProject()
1773
- if not pm.LoadProject(scratch) and not pm.CreateProject(scratch):
1774
- fail("scratch_failed", "could not open or create the project %r" % scratch)
2398
+ if not pm.LoadProject(scratch) and (other or not pm.CreateProject(scratch)):
2399
+ pm.LoadProject(user)
2400
+ fail("not_found" if other else "scratch_failed", "could not open the project %r" % scratch)
1775
2401
  try:
1776
2402
  return fn(pm.GetCurrentProject())
1777
2403
  finally:
@@ -1819,28 +2445,35 @@ def a_still(resolve, args):
1819
2445
  return _in_scratch(resolve, args, go)
1820
2446
 
1821
2447
 
2448
+ _RESOLVE = None # the running Resolve, for the constants an edit needs (normalize_audio's level mode)
2449
+
2450
+
1822
2451
  def a_apply(resolve, args):
1823
2452
  """Carry out a list of live edits on one timeline, in order; each is read back. Stops at nothing:
1824
2453
  every op reports its own result, and `undo` (newest first) puts back everything that changed.
1825
2454
  `into: scratch` edits our scratch project instead (live tests), the user's project put back after."""
2455
+ global _RESOLVE
2456
+ _RESOLVE = resolve
1826
2457
  return _in_scratch(resolve, args, lambda p: _apply(p, args))
1827
2458
 
1828
2459
 
1829
2460
  def _apply(p, args):
1830
2461
  t = find_timeline(p, args.get("timeline"))
1831
- by_pos, by_id = _item_index(t)
2462
+ tname = t.GetName() # said at the end even when an op deleted it (Discard)
2463
+ index = [_item_index(t)]
1832
2464
 
1833
2465
  def find(a):
1834
- if a.get("id"):
1835
- it = by_id.get(a["id"])
1836
- else:
1837
- it = by_pos.get((a.get("kind", "video"), int(a["track"]), int(a["start"])))
1838
- if it is None:
1839
- raise ValueError("no %s item at %s" % (a.get("kind", "video"), json.dumps(a, sort_keys=True)))
1840
- return it
2466
+ for fresh in (False, True):
2467
+ if fresh: # an op earlier in the batch made items (split_clip, history, drop-in): read the timeline again
2468
+ index[0] = _item_index(t)
2469
+ by_pos, by_id = index[0]
2470
+ it = by_id.get(a["id"]) if a.get("id") else by_pos.get((a.get("kind", "video"), int(a["track"]), int(a["start"])))
2471
+ if it is not None:
2472
+ return it
2473
+ raise ValueError("no %s item at %s" % (a.get("kind", "video"), json.dumps(a, sort_keys=True)))
1841
2474
 
1842
2475
  # the batch runs on the open timeline: Resolve drops AddFlag on an item of a timeline that is not open (21.1, while
1843
- # clip colour still lands), so the edits' timeline is opened and the artist's put back after, unless an op opened
2476
+ # clip color still lands), so the edits' timeline is opened and the artist's put back after, unless an op opened
1844
2477
  # another on purpose (timeline_duplicate, goto)
1845
2478
  prev = p.GetCurrentTimeline()
1846
2479
  away = prev is not None and prev.GetName() != t.GetName()
@@ -1854,10 +2487,13 @@ def _apply(p, args):
1854
2487
  r = {"ok": False, "undo": [], "detail": "%s: %s" % (type(e).__name__, e)}
1855
2488
  undo = list(r.pop("undo", [])) + undo
1856
2489
  results.append(dict(r, op=op["op"]))
2490
+ if op["op"] in ("split_clip", "unsplit", "history_track", "drop_in", "pool_import", "track_delete"):
2491
+ # it made or removed clips: an item read before is a dead object now (a piece starts where the clip did)
2492
+ index[0] = _item_index(t)
1857
2493
  now = p.GetCurrentTimeline()
1858
2494
  if away and now is not None and now.GetName() == t.GetName():
1859
2495
  p.SetCurrentTimeline(prev)
1860
- return {"ok": True, "project": p.GetName(), "timeline": t.GetName(), "results": results, "undo": undo,
2496
+ return {"ok": True, "project": p.GetName(), "timeline": tname, "results": results, "undo": undo,
1861
2497
  "applied": sum(1 for r in results if r["ok"]), "failed": sum(1 for r in results if not r["ok"])}
1862
2498
 
1863
2499
 
@@ -2111,7 +2747,8 @@ def main():
2111
2747
  args = json.loads(raw)
2112
2748
  except ValueError as e:
2113
2749
  fail("usage", "arguments are not JSON: %s" % e)
2114
- resolve = connect()
2750
+ global _RESOLVE
2751
+ resolve = _RESOLVE = connect()
2115
2752
  t0 = time.time()
2116
2753
  try:
2117
2754
  out = ACTIONS[sys.argv[1]](resolve, args)