from __future__ import annotations

from dataclasses import dataclass, field
from datetime import datetime
from pathlib import Path


@dataclass(frozen=True, slots=True)
class VideoCandidate:
    rank: int
    video_id: str
    title: str
    channel: str
    url: str
    duration_seconds: int | None = None
    publish_date: str | None = None
    description: str | None = None


@dataclass(frozen=True, slots=True)
class VideoMetadata:
    video_id: str
    title: str
    channel: str
    url: str
    publish_date: str
    duration_seconds: int
    description: str


@dataclass(frozen=True, slots=True)
class TranscriptResult:
    source: str
    language: str
    text: str
    generated_at: datetime


@dataclass(frozen=True, slots=True)
class CaptionProbeSummary:
    checked_modes: tuple[str, ...]
    captions_found: bool
    region_restricted: bool
    notes: str


@dataclass(frozen=True, slots=True)
class CaptionFetchResult:
    transcript: TranscriptResult | None
    captions_available: bool
    verified_unavailable: bool
    probe_summary: CaptionProbeSummary


@dataclass(frozen=True, slots=True)
class FileCheckResult:
    path: Path
    exists: bool
    is_valid: bool
    has_transcript: bool
    is_corrupt: bool
    reason: str


@dataclass(frozen=True, slots=True)
class PersistResult:
    path: Path
    skipped: bool
    reason: str


@dataclass(frozen=True, slots=True)
class VideoProcessingResult:
    metadata: VideoMetadata
    output_path: Path
    status: str
    reason: str


@dataclass(slots=True)
class ExecutionSummary:
    query: str
    attempted: int = 0
    processed: int = 0
    skipped: int = 0
    failed: int = 0
    output_files: list[Path] = field(default_factory=list)
