|
import streamlit as st |
|
from pytube import YouTube |
|
import os |
|
|
|
|
|
def download_video(url): |
|
try: |
|
yt = YouTube(url) |
|
st.write("Video Title:", yt.title) |
|
st.write("Downloading...") |
|
stream = yt.streams.filter(progressive=True, file_extension='mp4').first() |
|
stream.download(output_path=os.path.expanduser("~\Downloads")) |
|
st.success("Download completed successfully!") |
|
except Exception as e: |
|
st.error(f"An error occurred: {e}") |
|
|
|
|
|
st.title("YouTube Video Downloader") |
|
|
|
url = st.text_input("Enter YouTube Video URL:", "") |
|
|
|
if st.button("Download"): |
|
if url.strip() == "": |
|
st.warning("Please enter a YouTube video URL.") |
|
else: |
|
download_video(url) |
|
|