Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,8 +31,11 @@ def get_available_formats(info_dict):
|
|
| 31 |
if filesize:
|
| 32 |
filesize_mb = round(filesize / (1024 * 1024), 2)
|
| 33 |
resolution = f"{fmt['height']}p"
|
| 34 |
-
formats[resolution] =
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
# "ํ์ธ" ๋ฒํผ์ ๋๋ฅด๋ฉด ์ฒ๋ฆฌํ ๋ก์ง
|
| 38 |
if st.button('ํ์ธ'):
|
|
@@ -60,7 +63,7 @@ if 'confirmed' in st.session_state and st.session_state.confirmed:
|
|
| 60 |
st.image(st.session_state.thumbnail_url, caption='Video Thumbnail', use_column_width=True)
|
| 61 |
|
| 62 |
# ํด์๋ ์ ํ
|
| 63 |
-
format_selection = st.selectbox('Select resolution', st.session_state.formats)
|
| 64 |
|
| 65 |
def download_video(youtube_url, format_id):
|
| 66 |
ydl_opts = {
|
|
@@ -75,7 +78,7 @@ if 'confirmed' in st.session_state and st.session_state.confirmed:
|
|
| 75 |
|
| 76 |
# "์ถ์ถ" ๋ฒํผ ์ถ๊ฐ
|
| 77 |
if st.button('์ถ์ถ'):
|
| 78 |
-
format_id =
|
| 79 |
try:
|
| 80 |
# ์ธ์
์ํ์ youtube_url ์ฌ์ฉ
|
| 81 |
download_video(st.session_state.youtube_url, format_id)
|
|
|
|
| 31 |
if filesize:
|
| 32 |
filesize_mb = round(filesize / (1024 * 1024), 2)
|
| 33 |
resolution = f"{fmt['height']}p"
|
| 34 |
+
formats[resolution] = {
|
| 35 |
+
'id': fmt['format_id'],
|
| 36 |
+
'info': f"{resolution} - {filesize_mb} MB"
|
| 37 |
+
}
|
| 38 |
+
return formats
|
| 39 |
|
| 40 |
# "ํ์ธ" ๋ฒํผ์ ๋๋ฅด๋ฉด ์ฒ๋ฆฌํ ๋ก์ง
|
| 41 |
if st.button('ํ์ธ'):
|
|
|
|
| 63 |
st.image(st.session_state.thumbnail_url, caption='Video Thumbnail', use_column_width=True)
|
| 64 |
|
| 65 |
# ํด์๋ ์ ํ
|
| 66 |
+
format_selection = st.selectbox('Select resolution', list(st.session_state.formats.values()))
|
| 67 |
|
| 68 |
def download_video(youtube_url, format_id):
|
| 69 |
ydl_opts = {
|
|
|
|
| 78 |
|
| 79 |
# "์ถ์ถ" ๋ฒํผ ์ถ๊ฐ
|
| 80 |
if st.button('์ถ์ถ'):
|
| 81 |
+
format_id = next(key for key, value in st.session_state.formats.items() if value['info'] == format_selection)
|
| 82 |
try:
|
| 83 |
# ์ธ์
์ํ์ youtube_url ์ฌ์ฉ
|
| 84 |
download_video(st.session_state.youtube_url, format_id)
|