Created
May 17, 2023 01:40
-
-
Save alphasecio/5f7606b2d46d4265b6a43232b3c43e7f to your computer and use it in GitHub Desktop.
Load YouTube transcripts using LangChain YoutubeLoader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import validators, streamlit as st | |
from langchain.document_loaders import YoutubeLoader | |
url = st.text_input("YouTube URL") | |
if st.button("Load"): | |
try: | |
if not url.strip(): | |
st.error("Please enter a URL") | |
elif not validators.url(url): | |
st.error("Invalid URL. Please enter a valid URL") | |
else: | |
loader = YoutubeLoader.from_youtube_url(url, add_video_info=True) | |
data = loader.load() | |
st.success(data) | |
except Exception as e: | |
st.error(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment