Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,16 +4,23 @@ import os
|
|
| 4 |
|
| 5 |
# Streamlit μ λͺ©
|
| 6 |
st.title('YouTube Video Downloader')
|
| 7 |
-
st.write("<br>", unsafe_allow_html=True)
|
| 8 |
st.write("μ¬μ©λ°©λ²")
|
| 9 |
-
st.write("<br>", unsafe_allow_html=True)
|
| 10 |
st.write("1. λ€μ΄λ°κ³ μνλ μ νλΈ μμμ λ§ν¬λ₯Ό μ
λ ₯ν΄μ£ΌμΈμ")
|
| 11 |
st.write("2. λ§ν¬λ₯Ό μ
λ ₯νκ³ νμΈλ²νΌμ λλ₯΄λ©΄ ν΄λΉ μμμ μΈλ€μΌμ΄ λ±μ₯ν©λλ€")
|
| 12 |
st.write("3. μΈλ€μΌ λ°μ μ νλμ ν΅ν΄ ν΄μλμ μμ μ©λμ νμΈν ν μνλ ν΄μλλ₯Ό μ ννκ³ μΆμΆ λ²νΌμ λλ¬μ£ΌμΈμ")
|
| 13 |
st.write("4. μ μ ν λ€μ΄λ°κ³ μνλ μμμ΄ λ°μ λ±μ₯νκ³ μ¬μνκ±°λ λ€μ΄λ‘λ λ°μ μ μμ΅λλ€")
|
| 14 |
|
| 15 |
# μ μ λ‘λΆν° μ νλΈ λ§ν¬ μ
λ ₯λ°κΈ°
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
if 'confirmed' not in st.session_state:
|
| 19 |
st.session_state.confirmed = False
|
|
@@ -25,14 +32,15 @@ def fetch_video_info(youtube_url):
|
|
| 25 |
return info_dict
|
| 26 |
|
| 27 |
def get_available_formats(info_dict):
|
| 28 |
-
formats =
|
| 29 |
for fmt in info_dict['formats']:
|
| 30 |
if fmt.get('height') and fmt.get('ext') == 'mp4':
|
| 31 |
filesize = fmt.get('filesize', 0)
|
| 32 |
if filesize:
|
| 33 |
filesize_mb = round(filesize / (1024 * 1024), 2)
|
| 34 |
-
|
| 35 |
-
|
|
|
|
| 36 |
|
| 37 |
if st.button('νμΈ'):
|
| 38 |
if youtube_url:
|
|
|
|
| 4 |
|
| 5 |
# Streamlit μ λͺ©
|
| 6 |
st.title('YouTube Video Downloader')
|
| 7 |
+
st.write("<br>", unsafe_allow_html=True) # 1μ€ λμ΄μ°κΈ°
|
| 8 |
st.write("μ¬μ©λ°©λ²")
|
| 9 |
+
st.write("<br>", unsafe_allow_html=True) # 1μ€ λμ΄μ°κΈ°
|
| 10 |
st.write("1. λ€μ΄λ°κ³ μνλ μ νλΈ μμμ λ§ν¬λ₯Ό μ
λ ₯ν΄μ£ΌμΈμ")
|
| 11 |
st.write("2. λ§ν¬λ₯Ό μ
λ ₯νκ³ νμΈλ²νΌμ λλ₯΄λ©΄ ν΄λΉ μμμ μΈλ€μΌμ΄ λ±μ₯ν©λλ€")
|
| 12 |
st.write("3. μΈλ€μΌ λ°μ μ νλμ ν΅ν΄ ν΄μλμ μμ μ©λμ νμΈν ν μνλ ν΄μλλ₯Ό μ ννκ³ μΆμΆ λ²νΌμ λλ¬μ£ΌμΈμ")
|
| 13 |
st.write("4. μ μ ν λ€μ΄λ°κ³ μνλ μμμ΄ λ°μ λ±μ₯νκ³ μ¬μνκ±°λ λ€μ΄λ‘λ λ°μ μ μμ΅λλ€")
|
| 14 |
|
| 15 |
# μ μ λ‘λΆν° μ νλΈ λ§ν¬ μ
λ ₯λ°κΈ°
|
| 16 |
+
col1, col2 = st.columns([4, 1])
|
| 17 |
+
with col1:
|
| 18 |
+
youtube_url = st.text_input('Enter YouTube video URL')
|
| 19 |
+
|
| 20 |
+
with col2:
|
| 21 |
+
if st.button('μλ‘κ³ μΉ¨'):
|
| 22 |
+
st.session_state.clear() # μΈμ
μ΄κΈ°ν
|
| 23 |
+
st.experimental_rerun() # νμ΄μ§λ₯Ό μλ‘κ³ μΉ¨νμ¬ μ ν리μΌμ΄μ
μ¬μ€ν
|
| 24 |
|
| 25 |
if 'confirmed' not in st.session_state:
|
| 26 |
st.session_state.confirmed = False
|
|
|
|
| 32 |
return info_dict
|
| 33 |
|
| 34 |
def get_available_formats(info_dict):
|
| 35 |
+
formats = {}
|
| 36 |
for fmt in info_dict['formats']:
|
| 37 |
if fmt.get('height') and fmt.get('ext') == 'mp4':
|
| 38 |
filesize = fmt.get('filesize', 0)
|
| 39 |
if filesize:
|
| 40 |
filesize_mb = round(filesize / (1024 * 1024), 2)
|
| 41 |
+
resolution = f"{fmt['height']}p"
|
| 42 |
+
formats[resolution] = f"{resolution} - {filesize_mb} MB"
|
| 43 |
+
return list(formats.values())
|
| 44 |
|
| 45 |
if st.button('νμΈ'):
|
| 46 |
if youtube_url:
|