arnabbumba077
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -3,13 +3,13 @@ from pytube import YouTube
|
|
3 |
import os
|
4 |
|
5 |
# Function to download YouTube video
|
6 |
-
def download_video(url,
|
7 |
try:
|
8 |
yt = YouTube(url)
|
9 |
-
st.write("Video Title:", title)
|
10 |
st.write("Downloading...")
|
11 |
-
stream = yt.streams.filter(progressive=True, file_extension='mp4').
|
12 |
-
download_path = os.path.join(os.path.expanduser("~\Downloads")
|
13 |
stream.download(output_path=download_path)
|
14 |
st.success("Download completed successfully!")
|
15 |
except Exception as e:
|
@@ -19,17 +19,12 @@ def download_video(url, title):
|
|
19 |
st.title("YouTube Video Downloader")
|
20 |
|
21 |
url = st.text_input("Enter YouTube Video URL:", "")
|
|
|
|
|
|
|
22 |
|
23 |
if st.button("Download"):
|
24 |
if url.strip() == "":
|
25 |
st.warning("Please enter a YouTube video URL.")
|
26 |
else:
|
27 |
-
|
28 |
-
title = yt.title
|
29 |
-
download_video(url, title)
|
30 |
-
|
31 |
-
if 'url' in st.session_state and st.session_state.url.strip() != "":
|
32 |
-
yt = YouTube(st.session_state.url)
|
33 |
-
title = yt.title
|
34 |
-
if st.button("Download Video"):
|
35 |
-
download_video(st.session_state.url, title)
|
|
|
3 |
import os
|
4 |
|
5 |
# Function to download YouTube video
|
6 |
+
def download_video(url, selected_quality):
|
7 |
try:
|
8 |
yt = YouTube(url)
|
9 |
+
st.write("Video Title:", yt.title)
|
10 |
st.write("Downloading...")
|
11 |
+
stream = yt.streams.filter(progressive=True, file_extension='mp4').get_by_resolution(selected_quality)
|
12 |
+
download_path = os.path.join(os.path.expanduser("~\Downloads"))
|
13 |
stream.download(output_path=download_path)
|
14 |
st.success("Download completed successfully!")
|
15 |
except Exception as e:
|
|
|
19 |
st.title("YouTube Video Downloader")
|
20 |
|
21 |
url = st.text_input("Enter YouTube Video URL:", "")
|
22 |
+
quality_options = ["1080p", "720p", "480p", "360p"]
|
23 |
+
|
24 |
+
selected_quality = st.selectbox("Select Video Quality:", quality_options)
|
25 |
|
26 |
if st.button("Download"):
|
27 |
if url.strip() == "":
|
28 |
st.warning("Please enter a YouTube video URL.")
|
29 |
else:
|
30 |
+
download_video(url, selected_quality)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|