跳到正文
yt-dlp

在 macOS 上安装 yt-dlp

用 Homebrew 或 pipx 在 macOS 上安装 yt-dlp 和 ffmpeg,并保持更新。

这篇文章还没有翻译,所以以英文显示。界面部分仍是你的语言。

1. Install yt-dlp

Homebrew is the path of least resistance and installs both tools in one line.

brew install yt-dlp ffmpeg

Without Homebrew, pipx keeps yt-dlp in its own environment so it cannot collide with anything else you have installed through Python.

pipx install yt-dlp

Avoid a bare pip install into the system Python: recent macOS releases push back on it, and when it does work it tends to break later for unrelated reasons.

2. Install ffmpeg

Included above if you used Homebrew. Otherwise install it separately — merging, MP3 extraction and embedding all depend on it.

brew install ffmpeg

3. Check it worked

yt-dlp --version
ffmpeg -version

If the shell cannot find yt-dlp after a pipx install, run pipx ensurepath and open a new terminal.

Cookies from Safari

--cookies-from-browser safari needs Full Disk Access for your terminal, granted in System Settings → Privacy & Security. Without it the read fails with a permissions error that does not mention the setting. Chrome and Firefox work without it.

Updating

brew upgrade yt-dlp     # Homebrew
pipx upgrade yt-dlp     # pipx

常见问题

用 pipx 装完后 macOS 找不到 yt-dlp。
运行 pipx ensurepath,然后打开一个新终端,让更新后的 PATH 生效。
macOS 上用 cookies 还需要别的设置吗?
只有 Safari 需要:--cookies-from-browser safari 要求你的终端有完全磁盘访问权限,在系统设置 → 隐私与安全性里。Chrome 和 Firefox 不需要。
怎么更新 yt-dlp?
独立的二进制文件用 yt-dlp -U 自我更新。如果是通过包管理器安装的,就用那个管理器更新;自我更新会拒绝改动不属于它的文件。更新能解决的问题比任何 flag 都多。