mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-30 02:13:23 +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."""
|
"""Load YouTube transcripts into `Document` objects."""
|
||||||
try:
|
try:
|
||||||
from youtube_transcript_api import (
|
from youtube_transcript_api import (
|
||||||
|
FetchedTranscript,
|
||||||
NoTranscriptFound,
|
NoTranscriptFound,
|
||||||
TranscriptsDisabled,
|
TranscriptsDisabled,
|
||||||
YouTubeTranscriptApi,
|
YouTubeTranscriptApi,
|
||||||
@ -269,8 +270,11 @@ class YoutubeLoader(BaseLoader):
|
|||||||
|
|
||||||
if self.translation is not None:
|
if self.translation is not None:
|
||||||
transcript = transcript.translate(self.translation)
|
transcript = transcript.translate(self.translation)
|
||||||
|
transcript_object = transcript.fetch()
|
||||||
transcript_pieces: List[Dict[str, Any]] = 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:
|
if self.transcript_format == TranscriptFormat.TEXT:
|
||||||
transcript = " ".join(
|
transcript = " ".join(
|
||||||
|
Loading…
Reference in New Issue
Block a user