File size: 769 Bytes
9430c4d
236e101
6de6818
a6b0cbe
6de6818
a6b0cbe
9430c4d
236e101
6de6818
 
 
 
 
4185844
9430c4d
 
6de6818
 
 
 
9430c4d
6de6818
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import streamlit as st
from pytube import YouTube
import os

# Function to download YouTube video
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}")

# Streamlit UI
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)