-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsimple-test.js
More file actions
72 lines (59 loc) · 2.66 KB
/
Copy pathsimple-test.js
File metadata and controls
72 lines (59 loc) · 2.66 KB
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
66
67
68
69
70
71
72
// Simple test to check if the server is running and APIs are accessible
import fetch from 'node-fetch';
const SERVER_PORT = 3001; // Updated to match the actual server port
async function testServer() {
console.log('Testing server connectivity...');
try {
// Test basic connectivity
const response = await fetch(`http://localhost:${SERVER_PORT}`);
console.log('Server is running, status:', response.status);
// Test transcript API with a different video
console.log('\nTesting transcript API with different video...');
const testVideos = [
'kJQP7kiw5Fk', // Despacito
'dQw4w9WgXcQ', // Rick Roll
'9bZkp7q19f0' // Gangnam Style
];
for (const videoId of testVideos) {
console.log(`\nTrying video: ${videoId}`);
const transcriptResponse = await fetch(`http://localhost:${SERVER_PORT}/api/youtube-transcript`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ videoId })
});
console.log(`Status: ${transcriptResponse.status}`);
const transcriptData = await transcriptResponse.text();
if (transcriptResponse.ok) {
console.log('✅ Success! Transcript extracted.');
const data = JSON.parse(transcriptData);
console.log('Method used:', data.method);
console.log('Transcript length:', data.length);
console.log('Preview:', data.transcript.substring(0, 100) + '...');
// Test analysis API with the extracted transcript
console.log('\nTesting analysis API with extracted transcript...');
const analysisResponse = await fetch(`http://localhost:${SERVER_PORT}/api/video-learn-analyze`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
transcript: data.transcript,
videoTitle: 'Test Video'
})
});
console.log('Analysis API status:', analysisResponse.status);
const analysisData = await analysisResponse.text();
console.log('Analysis response (first 200 chars):', analysisData.substring(0, 200));
return; // Success, exit early
} else {
console.log('❌ Failed:', transcriptData.substring(0, 200));
}
}
console.log('\nAll test videos failed. This might be due to:');
console.log('- No captions available on these videos');
console.log('- Network connectivity issues');
console.log('- YouTube API changes');
console.log('- Missing Gemini API key (for analysis)');
} catch (error) {
console.error('Error testing server:', error.message);
}
}
testServer();