langchain_community.document_loaders.youtube.GoogleApiYoutubeLoader

class langchain_community.document_loaders.youtube.GoogleApiYoutubeLoader(google_api_client: GoogleApiClient, channel_name: Optional[str] = None, video_ids: Optional[List[str]] = None, add_video_info: bool = True, captions_language: str = 'en', continue_on_failure: bool = False)[source]

Load all Videos from a YouTube Channel.

To use, you should have the googleapiclient,youtube_transcript_api python package installed. As the service needs a google_api_client, you first have to initialize the GoogleApiClient.

Additionally you have to either provide a channel name or a list of videoids “https://developers.google.com/docs/api/quickstart/python

Example

from langchain_community.document_loaders import GoogleApiClient
from langchain_community.document_loaders import GoogleApiYoutubeLoader
google_api_client = GoogleApiClient(
    service_account_path=Path("path_to_your_sec_file.json")
)
loader = GoogleApiYoutubeLoader(
    google_api_client=google_api_client,
    channel_name = "CodeAesthetic"
)
load.load()

Attributes

add_video_info

captions_language

channel_name

continue_on_failure

video_ids

google_api_client

Methods

__init__(google_api_client[, channel_name, ...])

alazy_load()

A lazy loader for Documents.

aload()

Load data into Document objects.

lazy_load()

A lazy loader for Documents.

load()

Load documents.

load_and_split([text_splitter])

Load Documents and split into chunks.

validate_channel_or_videoIds_is_set(values)

Validate that either folder_id or document_ids is set, but not both.

Parameters
  • google_api_client (GoogleApiClient) –

  • channel_name (Optional[str]) –

  • video_ids (Optional[List[str]]) –

  • add_video_info (bool) –

  • captions_language (str) –

  • continue_on_failure (bool) –

__init__(google_api_client: GoogleApiClient, channel_name: Optional[str] = None, video_ids: Optional[List[str]] = None, add_video_info: bool = True, captions_language: str = 'en', continue_on_failure: bool = False) None
Parameters
  • google_api_client (GoogleApiClient) –

  • channel_name (Optional[str]) –

  • video_ids (Optional[List[str]]) –

  • add_video_info (bool) –

  • captions_language (str) –

  • continue_on_failure (bool) –

Return type

None

async alazy_load() AsyncIterator[Document]

A lazy loader for Documents.

Return type

AsyncIterator[Document]

async aload() List[Document]

Load data into Document objects.

Return type

List[Document]

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]

classmethod validate_channel_or_videoIds_is_set(values: Dict[str, Any]) Dict[str, Any][source]

Validate that either folder_id or document_ids is set, but not both.

Parameters

values (Dict[str, Any]) –

Return type

Dict[str, Any]

Examples using GoogleApiYoutubeLoader