neuralworm commited on
Commit
8278e48
·
verified ·
1 Parent(s): 6c588c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -25,7 +25,7 @@ def run_capture(cmd):
25
  raise RuntimeError(f"Command failed: {' '.join(cmd)}\n{err_tail}")
26
  return result.stdout
27
 
28
- def download_video_with_ytdlp(url, out_dir, cookies_path=None, format_selector=None):
29
  out_template = str(Path(out_dir) / "%(title)s.%(ext)s")
30
  cmd = ["yt-dlp", "-o", out_template]
31
  if format_selector:
@@ -33,7 +33,13 @@ def download_video_with_ytdlp(url, out_dir, cookies_path=None, format_selector=N
33
  if cookies_path:
34
  cmd += ["--cookies", cookies_path]
35
  cmd.append(url)
36
- run_capture(cmd)
 
 
 
 
 
 
37
  files = sorted(Path(out_dir).glob("*"), key=lambda p: p.stat().st_mtime, reverse=True)
38
  if not files:
39
  raise FileNotFoundError("Download fehlgeschlagen — keine Datei gefunden.")
 
25
  raise RuntimeError(f"Command failed: {' '.join(cmd)}\n{err_tail}")
26
  return result.stdout
27
 
28
+ def download_video_with_ytdlp(url: str, out_dir: str, cookies_path=None, format_selector=None) -> str:
29
  out_template = str(Path(out_dir) / "%(title)s.%(ext)s")
30
  cmd = ["yt-dlp", "-o", out_template]
31
  if format_selector:
 
33
  if cookies_path:
34
  cmd += ["--cookies", cookies_path]
35
  cmd.append(url)
36
+ try:
37
+ run_capture(cmd)
38
+ except RuntimeError as e:
39
+ msg = str(e)
40
+ if "Failed to resolve" in msg or "Name or service not known" in msg:
41
+ raise RuntimeError("Kein DNS/Internet im Space: URL-Download nicht möglich. Bitte Videodatei hochladen oder in einer Umgebung mit Internet ausführen.")
42
+ raise
43
  files = sorted(Path(out_dir).glob("*"), key=lambda p: p.stat().st_mtime, reverse=True)
44
  if not files:
45
  raise FileNotFoundError("Download fehlgeschlagen — keine Datei gefunden.")