loom-transcript

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Loom Transcript Fetcher

Loom字幕获取工具

Fetch the transcript from a Loom video using Loom's GraphQL API.
使用Loom的GraphQL API获取Loom视频的字幕。

Instructions

操作说明

Given the Loom URL: $ARGUMENTS
给定Loom链接:$ARGUMENTS

1. Extract the Video ID

1. 提取视频ID

Parse the Loom URL to extract the 32-character hex video ID. Supported URL formats:
  • https://www.loom.com/share/<video-id>
  • https://www.loom.com/embed/<video-id>
  • https://www.loom.com/share/<video-id>?sid=<session-id>
The video ID is the 32-character hex string after
/share/
or
/embed/
.
解析Loom链接以提取32位十六进制的视频ID。支持的链接格式:
  • https://www.loom.com/share/<video-id>
  • https://www.loom.com/embed/<video-id>
  • https://www.loom.com/share/<video-id>?sid=<session-id>
视频ID是
/share/
/embed/
之后的32位十六进制字符串。

2. Fetch Video Metadata

2. 获取视频元数据

Use the
WebFetch
tool to POST to
https://www.loom.com/graphql
to get the video title and details.
Use this curl command via Bash:
bash
curl -s 'https://www.loom.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'x-loom-request-source: loom_web_45a5bd4' \
  -H 'apollographql-client-name: web' \
  -H 'apollographql-client-version: 45a5bd4' \
  -d '{
    "operationName": "GetVideoSSR",
    "variables": {"id": "<VIDEO_ID>", "password": null},
    "query": "query GetVideoSSR($id: ID!, $password: String) { getVideo(id: $id, password: $password) { ... on RegularUserVideo { id name description createdAt owner { display_name } } } }"
  }'
使用
WebFetch
工具向
https://www.loom.com/graphql
发送POST请求,获取视频标题和详情。
通过Bash执行以下curl命令:
bash
curl -s 'https://www.loom.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'x-loom-request-source: loom_web_45a5bd4' \
  -H 'apollographql-client-name: web' \
  -H 'apollographql-client-version: 45a5bd4' \
  -d '{
    "operationName": "GetVideoSSR",
    "variables": {"id": "<VIDEO_ID>", "password": null},
    "query": "query GetVideoSSR($id: ID!, $password: String) { getVideo(id: $id, password: $password) { ... on RegularUserVideo { id name description createdAt owner { display_name } } } }"
  }'

3. Fetch the Transcript URLs

3. 获取字幕链接

Use curl via Bash to call the GraphQL API:
bash
curl -s 'https://www.loom.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'x-loom-request-source: loom_web_45a5bd4' \
  -H 'apollographql-client-name: web' \
  -H 'apollographql-client-version: 45a5bd4' \
  -d '{
    "operationName": "FetchVideoTranscript",
    "variables": {"videoId": "<VIDEO_ID>", "password": null},
    "query": "query FetchVideoTranscript($videoId: ID!, $password: String) { fetchVideoTranscript(videoId: $videoId, password: $password) { ... on VideoTranscriptDetails { id video_id source_url captions_source_url } ... on GenericError { message } } }"
  }'
Replace
<VIDEO_ID>
with the actual video ID extracted in step 1.
The response contains:
  • source_url
    — JSON transcript URL
  • captions_source_url
    — VTT (WebVTT) captions URL
通过Bash执行curl命令调用GraphQL API:
bash
curl -s 'https://www.loom.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'x-loom-request-source: loom_web_45a5bd4' \
  -H 'apollographql-client-name: web' \
  -H 'apollographql-client-version: 45a5bd4' \
  -d '{
    "operationName": "FetchVideoTranscript",
    "variables": {"videoId": "<VIDEO_ID>", "password": null},
    "query": "query FetchVideoTranscript($videoId: ID!, $password: String) { fetchVideoTranscript(videoId: $videoId, password: $password) { ... on VideoTranscriptDetails { id video_id source_url captions_source_url } ... on GenericError { message } } }"
  }'
<VIDEO_ID>
替换为步骤1中提取的实际视频ID。
响应包含:
  • source_url
    — JSON格式字幕的链接
  • captions_source_url
    — VTT(WebVTT)格式字幕的链接

4. Download and Parse the Transcript

4. 下载并解析字幕

Fetch both URLs returned from step 3 (if available):
  1. VTT captions (
    captions_source_url
    ): Download with
    curl -sL "<url>"
    . This is a WebVTT file with timestamps and text.
  2. JSON transcript (
    source_url
    ): Download with
    curl -sL "<url>"
    . This is a JSON file with transcript segments.
Prefer the VTT captions as the primary source since they include proper timestamps. Fall back to the JSON transcript if VTT is unavailable.
获取步骤3返回的两个链接(如果可用):
  1. VTT字幕 (
    captions_source_url
    ):使用
    curl -sL "<url>"
    下载。这是包含时间戳和文本的WebVTT文件。
  2. JSON字幕 (
    source_url
    ):使用
    curl -sL "<url>"
    下载。这是包含字幕分段的JSON文件。
优先使用VTT字幕作为主要来源,因为它包含标准的时间戳。如果VTT不可用,则回退到JSON字幕。

5. Present the Transcript

5. 展示字幕

Format and present the full transcript to the user:
Video: [Title from metadata] Author: [Owner name] Date: [Created date]

0:00 - First transcript segment text...
0:14 - Second transcript segment text...
(continue for all segments)

将完整字幕格式化后展示给用户:
视频: [元数据中的标题] 作者: [所有者名称] 日期: [创建日期]

0:00 - 第一段字幕文本...
0:14 - 第二段字幕文本...
(所有分段依次展示)

Error Handling

错误处理

  • If the GraphQL response contains a
    GenericError
    , report the error message to the user.
  • If both
    source_url
    and
    captions_source_url
    are null/missing, tell the user that no transcript is available for this video.
  • If the video URL is invalid or the ID cannot be extracted, ask the user for a valid Loom URL.
  • 如果GraphQL响应包含
    GenericError
    ,将错误消息告知用户。
  • 如果
    source_url
    captions_source_url
    均为null或缺失,告知用户该视频没有可用字幕。
  • 如果视频链接无效或无法提取ID,请用户提供有效的Loom链接。

Notes

注意事项

  • No authentication or cookies are required — Loom's transcript API is publicly accessible.
  • Only English transcripts are available through this API.
  • Transcripts are auto-generated and may contain minor errors.
  • 无需身份验证或Cookie — Loom的字幕API是公开可访问的。
  • 该API仅支持英语字幕。
  • 字幕为自动生成,可能存在少量错误。