Use yt-dlp to download videos from YouTube or Bilibili. Downloads go to the user's Videos folder ( ~/Videos).
yt-dlp must be installed:
text
yt-dlp --version
# Install if missing
pip install yt-dlp # cross-platform
winget install yt-dlp # Windows
brew install yt-dlp # macOS
sudo apt install yt-dlp # Debian/Ubuntu
ffmpeg is recommended for merging video+audio streams.
text
yt-dlp -o "<videos-dir>/%(title)s.%(ext)s" "<url>"
Replace <videos-dir> with the user's Videos folder path, and <url> with the video URL.
Supported URLs:
https://www.youtube.com/watch?v=... or https://youtu.be/...https://www.bilibili.com/video/BV...text
# YouTube
yt-dlp -o "<videos-dir>/%(title)s.%(ext)s" "ytsearch1:<title>"
# Bilibili
yt-dlp -o "<videos-dir>/%(title)s.%(ext)s" "bilisearch1:<title>"
GoalFlagBest quality (default)-f bestvideo+bestaudio/bestAudio only (mp3)-x --audio-format mp3Specific resolution-f "bestvideo[height<=720]+bestaudio"Subtitles--write-subs --sub-langs zh-Hans,enPlaylist (all videos)just pass the playlist URLLimit speed--rate-limit 2M
-f best (single stream).--cookies-from-browser chrome.ytsearch1: or bilisearch1: prefix