langchain_community.document_loaders.youtube.YoutubeLoader¶

class langchain_community.document_loaders.youtube.YoutubeLoader(video_id: str, add_video_info: bool = False, language: Union[str, Sequence[str]] = 'en', translation: Optional[str] = None, transcript_format: TranscriptFormat = TranscriptFormat.TEXT, continue_on_failure: bool = False)[source]¶

Load YouTube transcripts.

Initialize with YouTube video ID.

Methods

__init__(video_id[, add_video_info, ...])

Initialize with YouTube video ID.

alazy_load()

A lazy loader for Documents.

extract_video_id(youtube_url)

Extract video id from common YT urls.

from_youtube_url(youtube_url, **kwargs)

Given youtube URL, load video.

lazy_load()

A lazy loader for Documents.

load()

Load documents.

load_and_split([text_splitter])

Load Documents and split into chunks.

Parameters
  • video_id (str) –

  • add_video_info (bool) –

  • language (Union[str, Sequence[str]]) –

  • translation (Optional[str]) –

  • transcript_format (TranscriptFormat) –

  • continue_on_failure (bool) –

__init__(video_id: str, add_video_info: bool = False, language: Union[str, Sequence[str]] = 'en', translation: Optional[str] = None, transcript_format: TranscriptFormat = TranscriptFormat.TEXT, continue_on_failure: bool = False)[source]¶

Initialize with YouTube video ID.

Parameters
  • video_id (str) –

  • add_video_info (bool) –

  • language (Union[str, Sequence[str]]) –

  • translation (Optional[str]) –

  • transcript_format (TranscriptFormat) –

  • continue_on_failure (bool) –

async alazy_load() AsyncIterator[Document]¶

A lazy loader for Documents.

Return type

AsyncIterator[Document]

static extract_video_id(youtube_url: str) str[source]¶

Extract video id from common YT urls.

Parameters

youtube_url (str) –

Return type

str

classmethod from_youtube_url(youtube_url: str, **kwargs: Any) YoutubeLoader[source]¶

Given youtube URL, load video.

Parameters
  • youtube_url (str) –

  • kwargs (Any) –

Return type

YoutubeLoader

lazy_load() Iterator[Document]¶

A lazy loader for Documents.

Return type

Iterator[Document]

load() List[Document][source]¶

Load documents.

Return type

List[Document]

load_and_split(text_splitter: Optional[TextSplitter] = None) List[Document]¶

Load Documents and split into chunks. Chunks are returned as Documents.

Do not override this method. It should be considered to be deprecated!

Parameters

text_splitter (Optional[TextSplitter]) – TextSplitter instance to use for splitting documents. Defaults to RecursiveCharacterTextSplitter.

Returns

List of Documents.

Return type

List[Document]

Examples using YoutubeLoader¶