Spaces:
Runtime error
Runtime error
Add clearer fallback messaging for YouTube anti-bot failures
Browse files
app.py
CHANGED
|
@@ -84,7 +84,19 @@ def download_url(url):
|
|
| 84 |
capture_output=True, text=True, timeout=600,
|
| 85 |
)
|
| 86 |
if result.returncode != 0:
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
import glob
|
| 89 |
files = glob.glob(tmp_path.replace(".%(ext)s", "*"))
|
| 90 |
if files:
|
|
|
|
| 84 |
capture_output=True, text=True, timeout=600,
|
| 85 |
)
|
| 86 |
if result.returncode != 0:
|
| 87 |
+
err = (result.stderr or '').strip()
|
| 88 |
+
lowered = err.lower()
|
| 89 |
+
if 'sign in to confirm you\'re not a bot' in lowered or 'cookies-from-browser' in lowered or 'cookies' in lowered:
|
| 90 |
+
return None, (
|
| 91 |
+
'YouTube blocked anonymous extraction for this video. '
|
| 92 |
+
'Please fall back to direct upload, or use a Google Drive / Dropbox / direct file link instead.'
|
| 93 |
+
)
|
| 94 |
+
if 'no supported javascript runtime could be found' in lowered:
|
| 95 |
+
return None, (
|
| 96 |
+
'This source needs a JavaScript runtime for extraction. '
|
| 97 |
+
'Please try again shortly, or fall back to direct upload / non-YouTube hosted links.'
|
| 98 |
+
)
|
| 99 |
+
return None, f"Download failed: {err}"
|
| 100 |
import glob
|
| 101 |
files = glob.glob(tmp_path.replace(".%(ext)s", "*"))
|
| 102 |
if files:
|