Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,7 +27,7 @@ def update_disk_info():
|
|
| 27 |
update_disk_info()
|
| 28 |
|
| 29 |
# Streamlit input fields
|
| 30 |
-
|
| 31 |
quality = st.selectbox("Select the desired quality:", ['4320', '2160', '1440', '1080', '720', '480'])
|
| 32 |
save_file_name = st.text_input("Enter the save file name (without extension):")
|
| 33 |
|
|
@@ -40,33 +40,6 @@ ydl_opts = {
|
|
| 40 |
'outtmpl': f'{save_file_name}.%(ext)s', # Save the video with the specified name
|
| 41 |
}
|
| 42 |
|
| 43 |
-
# Search for videos if a query is entered
|
| 44 |
-
if query:
|
| 45 |
-
if not query.startswith("http"):
|
| 46 |
-
# If the query is not a URL, search for videos
|
| 47 |
-
st.markdown("### Search Results:")
|
| 48 |
-
|
| 49 |
-
# Search videos using yt-dlp
|
| 50 |
-
with yt_dlp.YoutubeDL({'quiet': True}) as ydl:
|
| 51 |
-
search_result = ydl.extract_info(f"ytsearch5:{query}", download=False)
|
| 52 |
-
videos = search_result['entries']
|
| 53 |
-
|
| 54 |
-
video_urls = [video['webpage_url'] for video in videos]
|
| 55 |
-
thumbnails = [video['thumbnail'] for video in videos]
|
| 56 |
-
|
| 57 |
-
for i, video in enumerate(videos):
|
| 58 |
-
st.image(thumbnails[i], width=200)
|
| 59 |
-
st.write(f"{i + 1}. **{video['title']}** ({video.get('duration', 'N/A')} seconds)")
|
| 60 |
-
st.write(f" Channel: {video['uploader']}")
|
| 61 |
-
st.write(f" URL: {video_urls[i]}")
|
| 62 |
-
st.write("\n")
|
| 63 |
-
|
| 64 |
-
selected_video_index = st.number_input("Select video number to download:", min_value=1, max_value=len(videos), step=1) - 1
|
| 65 |
-
url = video_urls[selected_video_index]
|
| 66 |
-
else:
|
| 67 |
-
# If the query is a URL, use it directly
|
| 68 |
-
url = query
|
| 69 |
-
|
| 70 |
if st.button("Download"):
|
| 71 |
with st.spinner("Downloading... Please wait."):
|
| 72 |
try:
|
|
@@ -100,4 +73,4 @@ if st.button("Download"):
|
|
| 100 |
st.error(f"An error occurred: {str(e)}")
|
| 101 |
|
| 102 |
# Update disk information whenever the user interacts with the app
|
| 103 |
-
update_disk_info()
|
|
|
|
| 27 |
update_disk_info()
|
| 28 |
|
| 29 |
# Streamlit input fields
|
| 30 |
+
url = st.text_input("Enter the YouTube URL:")
|
| 31 |
quality = st.selectbox("Select the desired quality:", ['4320', '2160', '1440', '1080', '720', '480'])
|
| 32 |
save_file_name = st.text_input("Enter the save file name (without extension):")
|
| 33 |
|
|
|
|
| 40 |
'outtmpl': f'{save_file_name}.%(ext)s', # Save the video with the specified name
|
| 41 |
}
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
if st.button("Download"):
|
| 44 |
with st.spinner("Downloading... Please wait."):
|
| 45 |
try:
|
|
|
|
| 73 |
st.error(f"An error occurred: {str(e)}")
|
| 74 |
|
| 75 |
# Update disk information whenever the user interacts with the app
|
| 76 |
+
update_disk_info()
|