mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-29 18:08:36 +00:00
Youtube Loader load
method Fixed (#30314)
- **Description:** Fixed the `YoutubeLoader` loading method not returning the correct object - **Issue:** #30309 --------- Co-authored-by: ccurme <chester.curme@gmail.com>
This commit is contained in:
parent
df4448dfac
commit
33f1ab1528
@ -241,6 +241,7 @@ class YoutubeLoader(BaseLoader):
|
||||
"""Load YouTube transcripts into `Document` objects."""
|
||||
try:
|
||||
from youtube_transcript_api import (
|
||||
FetchedTranscript,
|
||||
NoTranscriptFound,
|
||||
TranscriptsDisabled,
|
||||
YouTubeTranscriptApi,
|
||||
@ -269,8 +270,11 @@ class YoutubeLoader(BaseLoader):
|
||||
|
||||
if self.translation is not None:
|
||||
transcript = transcript.translate(self.translation)
|
||||
|
||||
transcript_pieces: List[Dict[str, Any]] = transcript.fetch()
|
||||
transcript_object = transcript.fetch()
|
||||
if isinstance(transcript_object, FetchedTranscript):
|
||||
transcript_pieces = [{"text": x.text} for x in transcript_object.snippets]
|
||||
else:
|
||||
transcript_pieces: List[Dict[str, Any]] = transcript_object # type: ignore[no-redef]
|
||||
|
||||
if self.transcript_format == TranscriptFormat.TEXT:
|
||||
transcript = " ".join(
|
||||
|
Loading…
Reference in New Issue
Block a user