jpjp9292 commited on
Commit
84f9e8f
·
verified ·
1 Parent(s): 5b39ff7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -404,7 +404,7 @@ def get_download_options(session_headers=None):
404
  return options
405
 
406
  def download_with_retry(url, progress_callback):
407
- """Enhanced download function with multiple retry strategies and better bot protection."""
408
  for attempt in range(Config.MAX_RETRIES):
409
  try:
410
  session = SessionManager.get_session()
@@ -422,7 +422,7 @@ def download_with_retry(url, progress_callback):
422
 
423
  ydl_opts['progress_hooks'] = [progress_hook]
424
 
425
- # Attempt download with session headers and cookies
426
  with yt_dlp.YoutubeDL(ydl_opts) as ydl:
427
  info = ydl.extract_info(url, download=True)
428
  filename = ydl.prepare_filename(info)
@@ -435,6 +435,10 @@ def download_with_retry(url, progress_callback):
435
  progress_callback(-1, f"Bot detection encountered. Waiting {delay}s before retry...")
436
  time.sleep(delay)
437
  continue
 
 
 
 
438
  return None, f"Video extraction failed: {error_msg}"
439
 
440
  except Exception as e:
@@ -449,6 +453,7 @@ def download_with_retry(url, progress_callback):
449
  return None, "Maximum retries reached. Please try again later."
450
 
451
 
 
452
  # UI Components
453
  def render_main_ui():
454
  col1, col2 = st.columns([2, 1])
 
404
  return options
405
 
406
  def download_with_retry(url, progress_callback):
407
+ """Enhanced download function with multiple retry strategies"""
408
  for attempt in range(Config.MAX_RETRIES):
409
  try:
410
  session = SessionManager.get_session()
 
422
 
423
  ydl_opts['progress_hooks'] = [progress_hook]
424
 
425
+ # Actual download
426
  with yt_dlp.YoutubeDL(ydl_opts) as ydl:
427
  info = ydl.extract_info(url, download=True)
428
  filename = ydl.prepare_filename(info)
 
435
  progress_callback(-1, f"Bot detection encountered. Waiting {delay}s before retry...")
436
  time.sleep(delay)
437
  continue
438
+
439
+ if "Video unavailable" in error_msg:
440
+ return None, "The video is unavailable or may be region-locked."
441
+
442
  return None, f"Video extraction failed: {error_msg}"
443
 
444
  except Exception as e:
 
453
  return None, "Maximum retries reached. Please try again later."
454
 
455
 
456
+
457
  # UI Components
458
  def render_main_ui():
459
  col1, col2 = st.columns([2, 1])