feat: add dedicated YouTube transcript API endpoint

## CHANGES

- Add new YouTube handler for transcript requests
- Create `/youtube/transcript` POST endpoint route
- Add request/response types for YouTube API
- Support language and timestamp options
- Update frontend to use new endpoint
- Remove chat endpoint dependency for transcripts
- Validate video vs playlist URLs properly
This commit is contained in:
Kayvan Sylvan
2025-06-26 01:21:27 -07:00
parent e29ed908e6
commit 0dbe1bbb4e
3 changed files with 75 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
import { get } from 'svelte/store';
import { languageStore } from '$lib/store/language-store';
import { get } from 'svelte/store';
export interface TranscriptResponse {
transcript: string;
@@ -18,18 +18,18 @@ export async function getTranscript(url: string): Promise<TranscriptResponse> {
console.log('\n=== YouTube Transcript Service Start ===');
console.log('1. Request details:', {
url,
endpoint: '/chat',
endpoint: '/youtube/transcript',
method: 'POST',
isYouTubeURL: url.includes('youtube.com') || url.includes('youtu.be'),
originalLanguage
});
const response = await fetch('/chat', {
const response = await fetch('/youtube/transcript', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
body: JSON.stringify({
url,
language: originalLanguage // Pass original language to server
})