Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import streamlit as st
|
|
| 2 |
import os
|
| 3 |
import yt_dlp
|
| 4 |
import psutil
|
|
|
|
| 5 |
|
| 6 |
# Function to get system information
|
| 7 |
def get_system_info():
|
|
@@ -12,12 +13,6 @@ def get_system_info():
|
|
| 12 |
# Streamlit UI setup
|
| 13 |
st.title("YouTube Video Downloader 8K supported")
|
| 14 |
|
| 15 |
-
# Display server RAM and disk usage
|
| 16 |
-
ram_info, disk_info = get_system_info()
|
| 17 |
-
st.write("## Server Information")
|
| 18 |
-
st.write(f"**RAM Usage:** {ram_info.percent}% used ({ram_info.used // (1024 ** 2)} MB of {ram_info.total // (1024 ** 2)} MB)")
|
| 19 |
-
st.write(f"**Disk Usage:** {disk_info.percent}% used ({disk_info.used // (1024 ** 3)} GB of {disk_info.total // (1024 ** 3)} GB)")
|
| 20 |
-
|
| 21 |
# Streamlit input fields
|
| 22 |
url = st.text_input("Enter the YouTube URL:")
|
| 23 |
quality = st.selectbox("Select the desired quality:", ['4320', '2160', '1440', '1080', '720', '480'])
|
|
@@ -32,6 +27,27 @@ ydl_opts = {
|
|
| 32 |
'outtmpl': f'{save_file_name}.%(ext)s', # Save the video with the specified name
|
| 33 |
}
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
if st.button("Download"):
|
| 36 |
with st.spinner("Downloading... Please wait."):
|
| 37 |
try:
|
|
|
|
| 2 |
import os
|
| 3 |
import yt_dlp
|
| 4 |
import psutil
|
| 5 |
+
import time
|
| 6 |
|
| 7 |
# Function to get system information
|
| 8 |
def get_system_info():
|
|
|
|
| 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 |
'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.write("## Server Information")
|
| 42 |
+
system_info_placeholder.write(f"**RAM Usage:** {ram_info.percent}% used ({ram_used_gb:.2f} GB of {ram_total_gb:.2f} GB)")
|
| 43 |
+
system_info_placeholder.write(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 |
+
# Continuously update system information every 5 seconds
|
| 49 |
+
st.experimental_rerun() # Optional: Force a rerun to refresh data
|
| 50 |
+
|
| 51 |
if st.button("Download"):
|
| 52 |
with st.spinner("Downloading... Please wait."):
|
| 53 |
try:
|