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"""#