File size: 1,934 Bytes
65d68f5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | // βββ Video Engine V1 β API client ββββββββββββββββββββββββββββββββββββββββββββ
// Talks to the backend curriculum-aligned script endpoints. No file paths ever
// cross this boundary; segment ids are opaque hashes.
import { apiGet, apiPost } from "@/lib/api/client";
import type { VideoScript } from "@/lib/video/types";
export type CurriculumHints = {
chapter_name?: string;
topics?: string[];
formulas?: string[];
definitions?: string[];
common_mistakes?: string[];
exam_importance?: string | null;
pyq_frequency?: string | null;
exam_weightage_marks?: number | null;
prerequisites?: string[];
};
export type VideoScriptRequest = {
chapter_slug: string;
subject?: string;
level?: string;
mode?: string;
duration_minutes?: number;
language_preference?: string | null;
curriculum_hints?: CurriculumHints;
student_progress?: Record<string, unknown> | null;
};
export type SegmentAudioResponse = {
segment_id: string;
mode: string;
audio_ready: boolean;
audio_token: string | null;
subtitle_text: string;
message: string;
};
export type VideoProgressResponse = {
video_id: string;
current_segment_index: number;
completed_segment_ids: string[];
percent_complete: number;
updated_at: string | null;
};
export function generateVideoScript(payload: VideoScriptRequest) {
return apiPost<VideoScript, VideoScriptRequest>("/video/generate-script", payload);
}
export function generateSegmentAudio(
segmentId: string,
body: { teacher_script: string; language?: string; voice?: string | null },
) {
return apiPost<SegmentAudioResponse, typeof body>(
`/video/segment/${encodeURIComponent(segmentId)}/generate`,
body,
);
}
export function getVideoProgress(videoId: string) {
return apiGet<VideoProgressResponse>(`/video/${encodeURIComponent(videoId)}/progress`);
}
|