MCPcopy Create free account
hub / github.com/Lightricks/ComfyUI-LTXVideo / _parse_tracks

Function _parse_tracks

sparse_tracks.py:142–161  ·  view source on GitHub ↗

Parse tracks from a JSON string, handling nested/wrapped formats.

(raw: str)

Source from the content-addressed store, hash-verified

140
141
142def _parse_tracks(raw: str) -> list[list[dict]]:
143 """Parse tracks from a JSON string, handling nested/wrapped formats."""
144 parsed = json.loads(raw) if isinstance(raw, str) else raw
145
146 if isinstance(parsed, list):
147 unwrapped = []
148 for item in parsed:
149 unwrapped.append(json.loads(item) if isinstance(item, str) else item)
150 parsed = unwrapped
151
152 tracks: list[list[dict]] = []
153 stack = [parsed]
154 while stack:
155 obj = stack.pop()
156 if isinstance(obj, list) and len(obj) > 0:
157 if isinstance(obj[0], dict) and "x" in obj[0] and "y" in obj[0]:
158 tracks.append(obj)
159 else:
160 stack.extend(obj)
161 return tracks
162
163
164def _age_color_batch(ratios: torch.Tensor, device: torch.device) -> torch.Tensor:

Callers 1

executeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected