Rajan18 commited on
Commit
8a01fcc
·
verified ·
1 Parent(s): 90d824b
Files changed (1) hide show
  1. downloader.py +7 -3
downloader.py CHANGED
@@ -26,8 +26,8 @@ def _write_cookies_file_if_present(output_dir: Path) -> Optional[Path]:
26
  If YTDLP_COOKIES_TXT is configured, write it to a temp file and return path.
27
  Supports both real newlines and escaped '\\n' forms commonly used in secrets.
28
  """
29
- cookies_txt = os.environ.get("YTDLP_COOKIES_TXT", "").strip()
30
- if not cookies_txt:
31
  return None
32
 
33
  normalized = cookies_txt.replace("\\r\\n", "\n").replace("\\n", "\n")
@@ -68,7 +68,11 @@ def download_youtube_video(
68
 
69
  def _hook(d: dict):
70
  if d["status"] == "downloading" and progress_cb:
71
- raw = d.get("_percent_str", "0%").strip().replace("%", "")
 
 
 
 
72
  try:
73
  pct = int(float(raw))
74
  except ValueError:
 
26
  If YTDLP_COOKIES_TXT is configured, write it to a temp file and return path.
27
  Supports both real newlines and escaped '\\n' forms commonly used in secrets.
28
  """
29
+ cookies_txt = os.environ.get("YTDLP_COOKIES_TXT", "")
30
+ if not cookies_txt or not isinstance(cookies_txt, str) or cookies_txt == "":
31
  return None
32
 
33
  normalized = cookies_txt.replace("\\r\\n", "\n").replace("\\n", "\n")
 
68
 
69
  def _hook(d: dict):
70
  if d["status"] == "downloading" and progress_cb:
71
+ raw = d.get("_percent_str", "0%")
72
+ if raw is not None:
73
+ raw = raw.replace(" ", "").replace("%", "")
74
+ else:
75
+ raw = "0"
76
  try:
77
  pct = int(float(raw))
78
  except ValueError: