Adding fixes to the stitcher

This commit is contained in:
2026-07-05 12:16:35 +02:00
parent b9b5a8e77d
commit f9ff847f6b
11 changed files with 1019 additions and 167 deletions
+30 -4
View File
@@ -22,6 +22,7 @@ def validate_project(
videos: dict[str, VideoSource],
videos_dir: Path,
malformed_markers: list[tuple[int, str]] = None,
audio: dict = None,
) -> list[ValidationIssue]:
"""
Validate all parsed project data. Raises ValidationError if any issues found.
@@ -34,6 +35,7 @@ def validate_project(
- Background video exists (if specified)
- Slide types are valid
- No malformed markers in manuscript
- All audio: markers in manuscript exist in audio.json
"""
issues: list[ValidationIssue] = []
warnings: list[ValidationIssue] = []
@@ -52,9 +54,9 @@ def validate_project(
for marker in manuscript_markers:
prefix = next((p for p in _VIDEO_PREFIXES if marker.startswith(p)), None)
if prefix is not None:
referenced_video_ids.add(marker[_VIDEO_PREFIXES[prefix]:])
referenced_video_ids.add(marker[_VIDEO_PREFIXES[prefix]:].lower())
elif marker.startswith("narration:"):
referenced_video_ids.add(marker[10:])
referenced_video_ids.add(marker[10:].lower())
# Check for malformed markers first (these are likely typos)
if malformed_markers:
@@ -84,7 +86,7 @@ def validate_project(
(p for p in _VIDEO_PREFIXES if marker.startswith(p)), None
)
if matched_prefix is not None:
video_id = marker[_VIDEO_PREFIXES[matched_prefix] :]
video_id = marker[_VIDEO_PREFIXES[matched_prefix] :].lower()
if video_id not in videos:
hint = ""
if "." in video_id:
@@ -111,7 +113,7 @@ def validate_project(
# Validate narration trigger markers (narration:xxx) - continuous videos
if marker.startswith("narration:"):
video_id = marker[10:] # Remove 'narration:' prefix
video_id = marker[10:].lower() # Remove 'narration:' prefix
if video_id not in videos:
warnings.append(
ValidationIssue(
@@ -135,6 +137,10 @@ def validate_project(
if marker.startswith("segment:"):
continue
# Bare narrator cues (teleprompter hints, not pipeline markers)
if marker in ("pause", "stop"):
continue
# Unknown namespaced markers (e.g. [background:xxx]) — not supported, ignore with warning
if ":" in marker:
warnings.append(
@@ -320,6 +326,26 @@ def validate_project(
)
)
# Check all audio: markers in manuscript exist in audio.json
if audio is not None:
seen_audio: set[str] = set()
manuscript_path = project_path / "manuscript.txt"
for marker in manuscript_markers:
audio_id = None
if marker.startswith("audio:"):
audio_id = marker[6:]
elif marker.startswith("A") and len(marker) > 1 and marker[1:].isalnum():
audio_id = marker[1:]
if audio_id and audio_id not in seen_audio:
seen_audio.add(audio_id)
if audio_id not in audio:
warnings.append(
ValidationIssue(
f"Audio marker [{marker}] referenced in manuscript but '{audio_id}' not defined in audio.json — will be silent at render",
manuscript_path,
)
)
# If any issues, raise ValidationError
if issues:
raise ValidationError(issues)