跳至內容
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 都多。