arnabbumba077
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -3,10 +3,10 @@ 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:",
|
10 |
st.write("Downloading...")
|
11 |
stream = yt.streams.filter(progressive=True, file_extension='mp4').first()
|
12 |
stream.download(output_path=os.path.expanduser("~\Downloads"))
|
@@ -23,4 +23,12 @@ if st.button("Download"):
|
|
23 |
if url.strip() == "":
|
24 |
st.warning("Please enter a YouTube video URL.")
|
25 |
else:
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
import os
|
4 |
|
5 |
# Function to download YouTube video
|
6 |
+
def download_video(url, title):
|
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').first()
|
12 |
stream.download(output_path=os.path.expanduser("~\Downloads"))
|
|
|
23 |
if url.strip() == "":
|
24 |
st.warning("Please enter a YouTube video URL.")
|
25 |
else:
|
26 |
+
yt = YouTube(url)
|
27 |
+
title = yt.title
|
28 |
+
download_video(url, title)
|
29 |
+
|
30 |
+
if 'url' in st.session_state and st.session_state.url.strip() != "":
|
31 |
+
yt = YouTube(st.session_state.url)
|
32 |
+
title = yt.title
|
33 |
+
if st.button("Download Video"):
|
34 |
+
download_video(st.session_state.url, title)
|