Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,17 +2,30 @@ import streamlit as st
|
|
| 2 |
import os
|
| 3 |
import yt_dlp
|
| 4 |
import psutil
|
| 5 |
-
import time
|
| 6 |
|
| 7 |
-
# Function to get
|
| 8 |
-
def
|
| 9 |
-
ram_info = psutil.virtual_memory()
|
| 10 |
disk_info = psutil.disk_usage('/')
|
| 11 |
-
return
|
| 12 |
|
| 13 |
# Streamlit UI setup
|
| 14 |
st.title("YouTube Video Downloader 8K supported")
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
# Streamlit input fields
|
| 17 |
url = st.text_input("Enter the YouTube URL:")
|
| 18 |
quality = st.selectbox("Select the desired quality:", ['4320', '2160', '1440', '1080', '720', '480'])
|
|
@@ -27,28 +40,6 @@ ydl_opts = {
|
|
| 27 |
'outtmpl': f'{save_file_name}.%(ext)s', # Save the video with the specified name
|
| 28 |
}
|
| 29 |
|
| 30 |
-
# Placeholder for system info
|
| 31 |
-
system_info_placeholder = st.empty()
|
| 32 |
-
|
| 33 |
-
# Function to update system information
|
| 34 |
-
def update_system_info():
|
| 35 |
-
ram_info, disk_info = get_system_info()
|
| 36 |
-
ram_used_gb = ram_info.used / (1024 ** 3)
|
| 37 |
-
ram_total_gb = ram_info.total / (1024 ** 3)
|
| 38 |
-
disk_used_gb = disk_info.used / (1024 ** 3)
|
| 39 |
-
disk_total_gb = disk_info.total / (1024 ** 3)
|
| 40 |
-
|
| 41 |
-
system_info_placeholder.markdown("## Server Information")
|
| 42 |
-
system_info_placeholder.markdown(f"**RAM Usage:** {ram_info.percent}% used ({ram_used_gb:.2f} GB of {ram_total_gb:.2f} GB)")
|
| 43 |
-
system_info_placeholder.markdown(f"**Disk Usage:** {disk_info.percent}% used ({disk_used_gb:.2f} GB of {disk_total_gb:.2f} GB)")
|
| 44 |
-
|
| 45 |
-
# Initial system information update
|
| 46 |
-
update_system_info()
|
| 47 |
-
|
| 48 |
-
# Button to update system information
|
| 49 |
-
if st.button("Update System Information"):
|
| 50 |
-
update_system_info()
|
| 51 |
-
|
| 52 |
if st.button("Download"):
|
| 53 |
with st.spinner("Downloading... Please wait."):
|
| 54 |
try:
|
|
@@ -81,8 +72,5 @@ if st.button("Download"):
|
|
| 81 |
except Exception as e:
|
| 82 |
st.error(f"An error occurred: {str(e)}")
|
| 83 |
|
| 84 |
-
#
|
| 85 |
-
|
| 86 |
-
update_system_info()
|
| 87 |
-
time.sleep(5)
|
| 88 |
-
st.experimental_rerun()
|
|
|
|
| 2 |
import os
|
| 3 |
import yt_dlp
|
| 4 |
import psutil
|
|
|
|
| 5 |
|
| 6 |
+
# Function to get disk usage information
|
| 7 |
+
def get_disk_info():
|
|
|
|
| 8 |
disk_info = psutil.disk_usage('/')
|
| 9 |
+
return disk_info
|
| 10 |
|
| 11 |
# Streamlit UI setup
|
| 12 |
st.title("YouTube Video Downloader 8K supported")
|
| 13 |
|
| 14 |
+
# Placeholder for disk usage info
|
| 15 |
+
disk_info_placeholder = st.empty()
|
| 16 |
+
|
| 17 |
+
# Function to update disk usage information
|
| 18 |
+
def update_disk_info():
|
| 19 |
+
disk_info = get_disk_info()
|
| 20 |
+
disk_used_gb = disk_info.used / (1024 ** 3)
|
| 21 |
+
disk_total_gb = disk_info.total / (1024 ** 3)
|
| 22 |
+
|
| 23 |
+
disk_info_placeholder.markdown("## Server Information")
|
| 24 |
+
disk_info_placeholder.markdown(f"**Disk Usage:** {disk_info.percent}% used ({disk_used_gb:.2f} GB of {disk_total_gb:.2f} GB)")
|
| 25 |
+
|
| 26 |
+
# Initial disk information update
|
| 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'])
|
|
|
|
| 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:
|
|
|
|
| 72 |
except Exception as e:
|
| 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()
|
|
|
|
|
|
|
|
|