Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -296,6 +296,10 @@ import os
|
|
296 |
from pathlib import Path
|
297 |
import random
|
298 |
import time
|
|
|
|
|
|
|
|
|
299 |
|
300 |
# ํ์ด์ง ์ค์
|
301 |
st.set_page_config(page_title="Simple YouTube Downloader", page_icon="๐บ")
|
@@ -332,7 +336,7 @@ def download_video(url, progress_bar, status_text):
|
|
332 |
'user_agent': random.choice(user_agents),
|
333 |
'referer': 'https://www.youtube.com/',
|
334 |
'http_chunk_size': random.randint(10000000, 15000000),
|
335 |
-
'retries': 5,
|
336 |
'sleep_interval': 3,
|
337 |
'max_sleep_interval': 8,
|
338 |
'headers': {
|
@@ -347,7 +351,8 @@ def download_video(url, progress_bar, status_text):
|
|
347 |
progress = d['downloaded_bytes'] / d['total_bytes']
|
348 |
progress_bar.progress(progress)
|
349 |
status_text.text(f"๋ค์ด๋ก๋ ์ค: {progress:.1%}")
|
350 |
-
except:
|
|
|
351 |
status_text.text("๋ค์ด๋ก๋ ์ค...")
|
352 |
elif d['status'] == 'finished':
|
353 |
progress_bar.progress(1.0)
|
@@ -355,7 +360,7 @@ def download_video(url, progress_bar, status_text):
|
|
355 |
|
356 |
ydl_opts['progress_hooks'] = [progress_hook]
|
357 |
|
358 |
-
for attempt in range(5):
|
359 |
try:
|
360 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
361 |
info = ydl.extract_info(url, download=True)
|
@@ -366,22 +371,21 @@ def download_video(url, progress_bar, status_text):
|
|
366 |
status_text.text(f"์ฌ์๋ ์ค... ({attempt + 1}/5)")
|
367 |
time.sleep(random.uniform(3, 5))
|
368 |
continue
|
369 |
-
|
370 |
-
st.error(f"๋ค์ด๋ก๋ ์คํจ: {str(e)}")
|
371 |
st.info("๋ฌธ์ ๊ฐ ์ง์๋ ๊ฒฝ์ฐ URL์ด ์ฌ๋ฐ๋ฅธ์ง ํ์ธํ๊ณ ๋ค์ ์๋ํ์ธ์.")
|
372 |
return None
|
373 |
except Exception as e:
|
|
|
374 |
if attempt < 4:
|
375 |
status_text.text(f"์ฌ์๋ ์ค... ({attempt + 1}/5)")
|
376 |
time.sleep(2)
|
377 |
continue
|
378 |
-
|
379 |
-
st.error(f"๋ค์ด๋ก๋ ์คํจ: {str(e)}")
|
380 |
-
st.info("๋ฌธ์ ๊ฐ ์ง์๋ ๊ฒฝ์ฐ URL์ด ์ฌ๋ฐ๋ฅธ์ง ํ์ธํ๊ณ ๋ค์ ์๋ํ์ธ์.")
|
381 |
return None
|
382 |
|
383 |
except Exception as e:
|
384 |
-
|
|
|
385 |
return None
|
386 |
|
387 |
# ์ฟ ํค ํ์ผ ์ฒดํฌ
|
@@ -434,5 +438,5 @@ if download_button:
|
|
434 |
# ์ด๊ธฐํ ๋ก์ง
|
435 |
if reset_button:
|
436 |
st.session_state.video_url = ""
|
437 |
-
|
438 |
-
|
|
|
296 |
from pathlib import Path
|
297 |
import random
|
298 |
import time
|
299 |
+
import logging
|
300 |
+
|
301 |
+
# ๋ก๊น
์ค์
|
302 |
+
logging.basicConfig(level=logging.ERROR, filename='error.log')
|
303 |
|
304 |
# ํ์ด์ง ์ค์
|
305 |
st.set_page_config(page_title="Simple YouTube Downloader", page_icon="๐บ")
|
|
|
336 |
'user_agent': random.choice(user_agents),
|
337 |
'referer': 'https://www.youtube.com/',
|
338 |
'http_chunk_size': random.randint(10000000, 15000000),
|
339 |
+
'retries': 5, # ์ฌ์๋ ํ์๋ฅผ 5๋ก ๋๋ฆผ
|
340 |
'sleep_interval': 3,
|
341 |
'max_sleep_interval': 8,
|
342 |
'headers': {
|
|
|
351 |
progress = d['downloaded_bytes'] / d['total_bytes']
|
352 |
progress_bar.progress(progress)
|
353 |
status_text.text(f"๋ค์ด๋ก๋ ์ค: {progress:.1%}")
|
354 |
+
except Exception as e:
|
355 |
+
logging.error(f"Progress Hook Error: {e}")
|
356 |
status_text.text("๋ค์ด๋ก๋ ์ค...")
|
357 |
elif d['status'] == 'finished':
|
358 |
progress_bar.progress(1.0)
|
|
|
360 |
|
361 |
ydl_opts['progress_hooks'] = [progress_hook]
|
362 |
|
363 |
+
for attempt in range(5): # ์ฌ์๋ ํ์๋ฅผ 5๋ก ์ค์
|
364 |
try:
|
365 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
366 |
info = ydl.extract_info(url, download=True)
|
|
|
371 |
status_text.text(f"์ฌ์๋ ์ค... ({attempt + 1}/5)")
|
372 |
time.sleep(random.uniform(3, 5))
|
373 |
continue
|
374 |
+
logging.error(f"Extractor Error: {str(e)}")
|
|
|
375 |
st.info("๋ฌธ์ ๊ฐ ์ง์๋ ๊ฒฝ์ฐ URL์ด ์ฌ๋ฐ๋ฅธ์ง ํ์ธํ๊ณ ๋ค์ ์๋ํ์ธ์.")
|
376 |
return None
|
377 |
except Exception as e:
|
378 |
+
logging.error(f"Download Error: {str(e)}")
|
379 |
if attempt < 4:
|
380 |
status_text.text(f"์ฌ์๋ ์ค... ({attempt + 1}/5)")
|
381 |
time.sleep(2)
|
382 |
continue
|
383 |
+
st.info("๋ฌธ์ ๊ฐ ์ง์๋ ๊ฒฝ์ฐ ๋ค๋ฅธ URL์ ์๋ํด์ฃผ์ธ์.")
|
|
|
|
|
384 |
return None
|
385 |
|
386 |
except Exception as e:
|
387 |
+
logging.error(f"General Error: {str(e)}")
|
388 |
+
st.info("๋ฌธ์ ๊ฐ ์ง์๋ ๊ฒฝ์ฐ ๋ค๋ฅธ URL์ ์๋ํด์ฃผ์ธ์.")
|
389 |
return None
|
390 |
|
391 |
# ์ฟ ํค ํ์ผ ์ฒดํฌ
|
|
|
438 |
# ์ด๊ธฐํ ๋ก์ง
|
439 |
if reset_button:
|
440 |
st.session_state.video_url = ""
|
441 |
+
st.rerun() # st.experimental_rerun()์ st.rerun()์ผ๋ก ๋ณ๊ฒฝํ์ต๋๋ค.
|
442 |
+
|