• Import from "@langchain/community/document_loaders/web/youtube" instead. This entrypoint will be removed in 0.3.0.

A document loader for loading data from YouTube videos. It uses the youtube-transcript and youtubei.js libraries to fetch the transcript and video metadata.

const loader = new YoutubeLoader(
"https:
"en",
true,
);
const docs = await loader.load();

Hierarchy (view full)

Constructors

Methods

  • Loads the transcript and video metadata from the specified YouTube video. It uses the youtube-transcript library to fetch the transcript and the youtubei.js library to fetch the video metadata.

    Returns Promise<Document<Record<string, any>>[]>

    An array of Documents representing the retrieved data.

  • Parameters

    • Optionalsplitter: BaseDocumentTransformer<DocumentInterface<Record<string, any>>[], DocumentInterface<Record<string, any>>[]>

    Returns Promise<Document<Record<string, any>>[]>

    A Promise that resolves with an array of Document instances, each split according to the provided TextSplitter.

    Use this.load() and splitter.splitDocuments() individually. Loads the documents and splits them using a specified text splitter.

  • Creates a new instance of the YoutubeLoader class from a YouTube video URL.

    Parameters

    • url: string

      The URL of the YouTube video.

    • Optionalconfig: Omit<YoutubeConfig, "videoId">

      Optional configuration options for the YoutubeLoader instance, excluding the videoId.

    Returns YoutubeLoader

    A new instance of the YoutubeLoader class.