Skip --impersonate flag when using bundled yt-dlp

The bundled PyInstaller binary doesn't include curl_cffi, so passing
--impersonate Chrome-146:Macos-26 makes it error out with
"Impersonate target ... is not available". System yt-dlp installed via
pip can have curl_cffi alongside it and works fine.

Centralize the decision in `Downloader::apply_impersonation` and apply
the same gate to the `/api/preview` handler.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Luna 2026-05-24 23:12:07 -07:00
parent 12c32f642b
commit 26bf619a23
2 changed files with 27 additions and 17 deletions

View file

@ -1255,8 +1255,14 @@ async fn get_preview(
} else if !browser.is_empty() && browser != "none" {
cmd.arg("--cookies-from-browser").arg(&browser);
}
// Only attach --impersonate if the active yt-dlp supports it. Our
// bundled (PyInstaller) binary doesn't ship curl_cffi, so the flag
// would error out. System yt-dlp installed via pip with curl_cffi
// does support it.
if !use_bundled {
cmd.arg("--impersonate").arg("Chrome-146:Macos-26");
}
let output = cmd
.arg("--impersonate").arg("Chrome-146:Macos-26")
.arg(&url)
.stdin(Stdio::null())
.stdout(std::process::Stdio::piped())