File size: 904 Bytes
9430c4d 4185844 9430c4d 4185844 9430c4d 4185844 9430c4d 4185844 f7e4d90 9430c4d |
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 28 29 30 |
import streamlit as st
from pytube import YouTube
def download_video(url, save_path):
try:
yt = YouTube(url)
streams = yt.streams.filter(progressive=True, file_extension="mp4")
highest_res_stream = streams.get_highest_resolution()
highest_res_stream.download(output_path=save_path)
st.success("Video downloaded successfully!")
except Exception as e:
st.error(f"An error occurred: {e}")
def main():
st.title("YouTube Video Downloader")
# Input field for entering YouTube URL
video_url = st.text_input("Enter YouTube URL:")
# Button to trigger the download
if st.button("Download"):
if video_url.strip() == "":
st.warning("Please enter a valid YouTube URL.")
else:
# Download the video
download_video(video_url, "./Downloads")
if __name__ == "__main__":
main()
|