fix: YouTube requires JS runtime — auto-configure Node.js in install

yt-dlp now requires an external JS runtime (deno or Node.js) for YouTube.
Since agent-reach already installs Node.js, we configure yt-dlp to use it:

1. cli.py: install writes '--js-runtimes node' to ~/.config/yt-dlp/config
2. youtube.py: doctor checks JS runtime availability and config
3. SKILL.md: updated YouTube section with accurate troubleshooting

Bilibili note: 412 errors are IP-based (needs proxy), not cookie-related.

Fixes #47
This commit is contained in:
Panniantong
2026-02-27 11:45:39 +01:00
parent e620a1db8f
commit 0d1a33236e
3 changed files with 45 additions and 7 deletions
+19
View File
@@ -419,6 +419,25 @@ def _install_system_deps():
except Exception:
print(" ⬜ undici install failed (optional — xreach may not work behind proxies)")
# ── yt-dlp JS runtime config (YouTube requires external JS runtime) ──
if shutil.which("node"):
ytdlp_config_dir = os.path.expanduser("~/.config/yt-dlp")
ytdlp_config = os.path.join(ytdlp_config_dir, "config")
needs_config = True
if os.path.exists(ytdlp_config):
with open(ytdlp_config, "r") as f:
if "--js-runtimes" in f.read():
needs_config = False
print(" ✅ yt-dlp JS runtime already configured")
if needs_config:
try:
os.makedirs(ytdlp_config_dir, exist_ok=True)
with open(ytdlp_config, "a") as f:
f.write("--js-runtimes node\n")
print(" ✅ yt-dlp configured to use Node.js as JS runtime (YouTube)")
except Exception:
print(" ⬜ Could not configure yt-dlp JS runtime (YouTube may not work)")
def _install_system_deps_safe():
"""Safe mode: check what's installed, print instructions for what's missing."""