From 548c4fef6372b43ee28272da7d1b82a49712d5d9 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sun, 21 Jun 2026 15:39:22 -0400 Subject: [PATCH] feat(video_analysis): synthesize_report.py orchestrator with TDD (5 tests) --- scripts/video_analysis/synthesize_report.py | 113 ++++++++++++++++++ .../test_video_analysis_synthesize_report.py | 53 ++++++++ 2 files changed, 166 insertions(+) create mode 100644 scripts/video_analysis/synthesize_report.py create mode 100644 tests/test_video_analysis_synthesize_report.py diff --git a/scripts/video_analysis/synthesize_report.py b/scripts/video_analysis/synthesize_report.py new file mode 100644 index 00000000..eee18b54 --- /dev/null +++ b/scripts/video_analysis/synthesize_report.py @@ -0,0 +1,113 @@ +from __future__ import annotations + +from dataclasses import dataclass +from pathlib import Path +from typing import Any + +from scripts.video_analysis import download_video, extract_keyframes, extract_transcript, ocr_frames +from scripts.video_analysis.error_types import ErrorInfo, make_error + + +PIPELINE_STAGES: list[str] = ["transcript", "download", "keyframes", "ocr", "report"] + + +@dataclass +class ReportContext: + url: str + slug: str + output_dir: Path + + +@dataclass +class _Ok: + value: Any + + def is_ok(self) -> bool: + return True + + def is_err(self) -> bool: + return False + + +@dataclass +class _Err: + err: ErrorInfo + + def is_ok(self) -> bool: + return False + + def is_err(self) -> bool: + return True + + +def ok(value: Any) -> _Ok: + return _Ok(value) + + +def err(error: ErrorInfo) -> _Err: + return _Err(error) + + +def build_report_stub(slug: str, url: str, video_id: str) -> str: + return f"""#