> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-zh.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# YouTube 字幕集成

> 使用 LangChain JavaScript 集成 YouTube 字幕文档加载器。

本文介绍如何将 YouTube 字幕加载到 LangChain 文档中。

## 安装设置

你需要安装 [youtubei.js](https://www.npmjs.com/package/youtubei.js) 来提取元数据：

```bash npm theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
npm install @langchain/community @langchain/core youtubei.js
```

## 使用方法

你需要在 `url` 参数中指定视频链接。你还可以指定 [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) 标准的 `language` 参数以及 `addVideoInfo` 标志。

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import { YoutubeLoader } from "@langchain/community/document_loaders/web/youtube";

const loader = YoutubeLoader.createFromUrl("https://youtu.be/bZQun8Y4L2A", {
  language: "en",
  addVideoInfo: true,
});

const docs = await loader.load();

console.log(docs);
```

***

<div className="source-links">
  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/i18n\zh-CN\oss\javascript\integrations\document_loaders\web_loaders\youtube.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>

  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>
</div>
