You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Google API获取Google Meet录制文件的文件ID?

如何通过会议ID/日历ID搜索Google Drive中的Meet录制文件

核心思路

Google Meet录制文件的命名默认包含会议ID(即Meet链接中meet.google.com/后的唯一字符串,如abc-defg-hij),结合文件类型过滤、文件夹限定,可以精准定位目标录制文件。如果只有日历ID(或日历事件ID),需先通过Calendar API关联到对应会议ID再搜索。

方案1:直接通过会议ID搜索

利用会议ID的唯一性,结合视频MIME类型、排除已删除文件,缩小搜索范围:

const drive = google.drive({ version: "v3", auth: oauth2Client });
const targetMeetingId = "abc-defg-hij"; // 替换为实际会议ID

const res = await drive.files.list({
    // 精准匹配:文件名含会议ID + 视频格式 + 未删除
    q: `name contains '${targetMeetingId}' and mimeType='video/mp4' and trashed=false`,
    pageSize: 10,
    // 返回必要字段:文件ID、名称、创建时间
    fields: "nextPageToken, files(id, name, createdTime)",
});

console.log("匹配的录制文件:", res.data.files);

方案2:通过日历事件ID关联搜索

如果只有日历事件ID,先通过Calendar API提取对应会议ID,再执行搜索:

const calendar = google.calendar({ version: "v3", auth: oauth2Client });
const drive = google.drive({ version: "v3", auth: oauth2Client });
const targetEventId = "<目标日历事件ID>";

// 第一步:获取日历事件关联的Meet会议ID
const eventRes = await calendar.events.get({
    calendarId: "primary", // 替换为对应日历ID(如共享日历ID)
    eventId: targetEventId,
    fields: "conferenceData(conferenceId)" // 只获取会议ID字段,减少数据量
});

const meetingId = eventRes.data.conferenceData?.conferenceId;
if (!meetingId) {
    console.log("该日历事件未关联Meet会议");
    return;
}

// 第二步:用会议ID搜索Drive录制文件
const driveRes = await drive.files.list({
    q: `name contains '${meetingId}' and mimeType='video/mp4' and trashed=false`,
    pageSize: 10,
    fields: "nextPageToken, files(id, name, createdTime)",
});

console.log("匹配的录制文件:", driveRes.data.files);

进阶优化:限定搜索文件夹

Meet录制默认保存到Drive的Meet recordings文件夹,限定搜索范围可提升效率:

const drive = google.drive({ version: "v3", auth: oauth2Client });
const targetMeetingId = "abc-defg-hij";

// 先获取Meet recordings文件夹ID
const folderRes = await drive.files.list({
    q: "name='Meet recordings' and mimeType='application/vnd.google-apps.folder' and trashed=false",
    fields: "files(id)"
});
const meetFolderId = folderRes.data.files[0]?.id;

if (!meetFolderId) {
    console.log("未找到Meet recordings文件夹");
    return;
}

// 在指定文件夹内搜索
const res = await drive.files.list({
    q: `name contains '${targetMeetingId}' and mimeType='video/mp4' and trashed=false and '${meetFolderId}' in parents`,
    pageSize: 10,
    fields: "nextPageToken, files(id, name)",
});

注意事项

  • 确保已授权https://www.googleapis.com/auth/drive.metadata.readonly权限,满足元数据读取需求;
  • 若需获取文件下载链接或内容,需额外申请对应权限,但当前场景仅需元数据,无需扩展;
  • 会议ID是最可靠的搜索标识,日历ID需先关联到会议ID再搜索,避免匹配无关文件。

内容的提问来源于stack exchange,提问作者Algorithm Unlock

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 22:13:09