Commti prior to change to video tag below / above layering

This commit is contained in:
2026-03-16 16:57:54 +01:00
parent 757d966803
commit e734dbfcac
12 changed files with 416 additions and 154 deletions
+23 -9
View File
@@ -4,6 +4,7 @@ from pathlib import Path
from .cache import resolve_with_cache
from .errors import ValidationError, ValidationIssue
from .parser import _read_json
from .models import (
ProjectConfig,
SlideDefinition,
@@ -21,9 +22,10 @@ def validate_project(
videos: dict[str, VideoSource],
videos_dir: Path,
malformed_markers: list[tuple[int, str]] = None,
) -> None:
) -> list[ValidationIssue]:
"""
Validate all parsed project data. Raises ValidationError if any issues found.
Returns a list of warnings (non-fatal issues).
Checks:
- All slide markers in manuscript exist in slides.json
@@ -34,6 +36,7 @@ def validate_project(
- No malformed markers in manuscript
"""
issues: list[ValidationIssue] = []
warnings: list[ValidationIssue] = []
# Check for malformed markers first (these are likely typos)
if malformed_markers:
@@ -64,9 +67,9 @@ def validate_project(
base_name = video_id.rsplit(".", 1)[0]
if base_name in videos:
hint = f" (Did you mean [video:{base_name}]? Don't include file extensions in markers)"
issues.append(
warnings.append(
ValidationIssue(
f"Video marker [{marker}] referenced in manuscript but '{video_id}' not defined in videos.json{hint}",
f"Video marker [{marker}] referenced in manuscript but '{video_id}' not defined in videos.json{hint} — using PlaceholderVideo instead",
project_path / "manuscript.txt",
)
)
@@ -76,9 +79,9 @@ def validate_project(
if marker.startswith("narration:"):
video_id = marker[10:] # Remove 'narration:' prefix
if video_id not in videos:
issues.append(
warnings.append(
ValidationIssue(
f"Narration marker [{marker}] referenced in manuscript but '{video_id}' not defined in videos.json",
f"Narration marker [{marker}] referenced in manuscript but '{video_id}' not defined in videos.json — using PlaceholderVideo instead",
project_path / "manuscript.txt",
)
)
@@ -88,6 +91,16 @@ def validate_project(
if marker.startswith("segment:"):
continue
# Unknown namespaced markers (e.g. [background:xxx]) — not supported, ignore with warning
if ":" in marker:
warnings.append(
ValidationIssue(
f"Unknown marker type [{marker}] — ignoring (no support for '{marker.split(':', 1)[0]}:' markers)",
project_path / "manuscript.txt",
)
)
continue
if marker not in slides:
issues.append(
ValidationIssue(
@@ -150,9 +163,9 @@ def validate_project(
video_path = base_dir / video_source.source_file
video_path, _ = resolve_with_cache(video_path, project_path)
if not video_path.exists():
issues.append(
warnings.append(
ValidationIssue(
f"Video file not found: {video_source.source_file}",
f"Video file not found: {video_source.source_file} — falling back to PlaceholderVideo",
videos_json_path,
)
)
@@ -183,8 +196,7 @@ def validate_project(
)
)
else:
import json as _json
bg_videos = _json.loads(videos_json_path_bg.read_text())
bg_videos = _read_json(videos_json_path_bg)
if bg_handle not in bg_videos:
issues.append(
ValidationIssue(
@@ -239,3 +251,5 @@ def validate_project(
# If any issues, raise ValidationError
if issues:
raise ValidationError(issues)
return warnings