Skip to content

Commit a1e2896

Browse files
committed
Fix YouTube link validation in yt_summarizer.py
1 parent 8914692 commit a1e2896

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

yt_summarizer.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ def check_link(link):
1212

1313

1414
def get_transcript(video_link):
15-
# Get video transcript
16-
if check_link(video_link):
15+
if not check_link(video_link):
16+
return "Invalid YouTube URL."
17+
try:
1718
loader = YoutubeLoader.from_youtube_url(video_link, language=["en", "en-US"])
1819
transcript = loader.load()
1920
return transcript
20-
return "Invalid YouTube URL."
21+
except Exception as e:
22+
return f"Failed to retrieve transcript: {e}"
2123

2224

2325
def split_chunks(transcript):

0 commit comments

Comments
 (0)