forked from ojusave/qdrant_example_zoom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzoomapi.js
167 lines (145 loc) · 6.28 KB
/
zoomapi.js
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
const { makeApiCall } = require('./utils/apiutils');
const { getDateRange } = require('./utils/dateutils');
const { downloadVttFile, writeDataToFile } = require('./utils/fileutils');
const axios = require('axios');
function cleanUserData(user) {
return {
userid: user.id,
firstname: user.first_name,
lastname: user.last_name,
email: user.email
};
}
async function fetchMeetingSummary(meetingId) {
try {
const response = await makeApiCall(`/meetings/${meetingId}/meeting_summary`);
console.log(`Fetched meeting summary for meeting ${meetingId}`);
return response;
} catch (error) {
console.error(`Error fetching meeting summary for meeting ${meetingId}:`, error.message);
return null;
}
}
async function processRecording(recording) {
let vttContent = null;
for (const file of recording.recording_files) {
if (file.file_type === 'TRANSCRIPT' && file.file_extension === 'VTT') {
console.log(`Attempting to download VTT file for recording ${recording.uuid}`);
console.log(`Download URL: ${file.download_url}`);
try {
// Special handling for VTT file download
const response = await axios({
method: 'GET',
url: file.download_url,
headers: {
'Authorization': 'Bearer abc'
},
responseType: 'text'
});
vttContent = response.data;
console.log(`Download completed for recording ${recording.uuid}`);
if (vttContent === null) {
console.log(`VTT content is null for recording ${recording.uuid}`);
} else if (vttContent === '') {
console.log(`VTT content is an empty string for recording ${recording.uuid}`);
} else {
console.log(`VTT content received for recording ${recording.uuid}`);
console.log(`Content type: ${typeof vttContent}`);
console.log(`Content length: ${vttContent.length} characters`);
const lines = vttContent.split('\n');
const totalLines = lines.length;
const previewLines = lines.slice(0, 10).join('\n'); // First 10 lines
console.log(`Total lines: ${totalLines}`);
console.log(`Preview (first 10 lines or less):\n${previewLines}`);
if (totalLines <= 10) {
console.log('Entire VTT content shown above');
} else {
console.log('...');
}
}
} catch (error) {
console.error(`Error downloading VTT file for recording ${recording.uuid}:`, error.message);
if (error.response) {
console.error(`Response status: ${error.response.status}`);
console.error(`Response headers:`, error.response.headers);
console.error(`Response data:`, error.response.data);
}
}
break;
}
}
const meetingSummary = await fetchMeetingSummary(recording.uuid);
return {
uuid: recording.uuid,
topic: recording.topic,
start_time: recording.start_time,
duration: recording.duration,
vtt_content: vttContent,
summary: meetingSummary ? {
summary_title: meetingSummary.summary_title,
summary_overview: meetingSummary.summary_overview,
summary_details: meetingSummary.summary_details,
next_steps: meetingSummary.next_steps
} : null
};
}
async function fetchUserRecordings(userId) {
console.log(`Fetching recordings for user ${userId}`);
const recordings = [];
const dateRanges = getDateRange(6);
for (const dateRange of dateRanges) {
try {
const response = await makeApiCall(`/users/${userId}/recordings`, {
from: dateRange.from,
to: dateRange.to,
page_size: 300
});
console.log(`Fetched recordings for user ${userId} from ${dateRange.from} to ${dateRange.to}`);
if (response && Array.isArray(response.meetings)) {
for (const meeting of response.meetings) {
const processedRecording = await processRecording(meeting);
recordings.push(processedRecording);
}
} else {
console.log(`No recordings found for user ${userId} in date range ${dateRange.from} to ${dateRange.to}`);
}
} catch (error) {
console.error(`Error fetching recordings for user ${userId}:`, error.message);
}
}
return recordings;
}
async function fetchAllData() {
try {
const response = await makeApiCall('/users');
console.log('Users API response:', JSON.stringify(response, null, 2));
let users = [];
if (response && response.users && Array.isArray(response.users)) {
users = response.users;
} else if (response && typeof response === 'object') {
users = [response];
}
if (users.length === 0) {
console.log('No users found in the API response');
return;
}
// Limit to the first 5 users
const usersToProcess = users.slice(0, 5);
console.log(`Processing the first ${usersToProcess.length} users`);
for (const user of usersToProcess) {
const cleanedUser = cleanUserData(user);
const recordings = await fetchUserRecordings(user.id);
const userData = {
...cleanedUser,
recordings: recordings
};
// Save the data to a file (to be used by the Python script)
await writeDataToFile(userData, `user_${user.id}`);
console.log(`Processed ${recordings.length} recordings for user ${user.id}`);
}
console.log('All data fetched and saved successfully for the first 5 users');
} catch (error) {
console.error('Error in fetchAllData:', error);
}
}
module.exports = { fetchAllData };