- "frontend/src/api/videos.ts" - "frontend/src/components/TranscriptSidebar.tsx" - "frontend/src/pages/WatchPage.tsx" - "frontend/src/App.tsx" - "frontend/src/pages/TechniquePage.tsx" - "frontend/src/App.css" GSD-Task: S01/T03
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { request, BASE } from "./client";
|
|
|
|
// ── Types ────────────────────────────────────────────────────────────────────
|
|
|
|
export interface VideoDetail {
|
|
id: string;
|
|
filename: string;
|
|
file_path: string;
|
|
duration_seconds: number | null;
|
|
content_type: string;
|
|
creator_id: string;
|
|
creator_name: string;
|
|
creator_slug: string;
|
|
video_url: string | null;
|
|
processing_status: string;
|
|
created_at: string;
|
|
updated_at: string;
|
|
}
|
|
|
|
export interface TranscriptSegment {
|
|
id: string;
|
|
source_video_id: string;
|
|
start_time: number;
|
|
end_time: number;
|
|
text: string;
|
|
segment_index: number;
|
|
topic_label: string | null;
|
|
}
|
|
|
|
export interface TranscriptResponse {
|
|
video_id: string;
|
|
segments: TranscriptSegment[];
|
|
total: number;
|
|
}
|
|
|
|
// ── API functions ────────────────────────────────────────────────────────────
|
|
|
|
export function fetchVideo(id: string): Promise<VideoDetail> {
|
|
return request<VideoDetail>(`${BASE}/videos/${encodeURIComponent(id)}`);
|
|
}
|
|
|
|
export function fetchTranscript(videoId: string): Promise<TranscriptResponse> {
|
|
return request<TranscriptResponse>(
|
|
`${BASE}/videos/${encodeURIComponent(videoId)}/transcript`,
|
|
);
|
|
}
|