A simple and powerful Node.js tool to download YouTube **videos** and **playlists** with ease. Works both as a **CLI tool** and as a **library**. 🎥🎶
npm install ytsave
yt-dlp)
bash
npm install -g ytsave
``
$3
`bash
npm install ytsave
`
📥 Install yt-dlp & ffmpeg
ytsave relies on the external tool yt-dlp to download media and (optionally) ffmpeg to merge separate video/audio streams. Install them on your system and ensure they're available on your PATH before running the CLI.
Windows
- Using winget:
`powershell
winget install yt-dlp
`
- Using pip (if Python is installed):
`powershell
pip install yt-dlp
`
- Using Scoop:
`powershell
scoop install yt-dlp
`
- Using Chocolatey:
`powershell
choco install yt-dlp
`
- Or download the yt-dlp.exe from the releases page and add it to your PATH:
https://github.com/yt-dlp/yt-dlp/releases
macOS
- Using Homebrew:
`bash
brew install yt-dlp
`
Linux
- Using pip:
`bash
pip3 install --user yt-dlp
`
- Using your distro package manager (if available) or download the binary from the releases page.
ffmpeg (optional but recommended)
- ffmpeg is required if yt-dlp needs to merge separate video and audio streams (this happens when selecting the best video and best audio). Install ffmpeg via your platform package manager:
- Windows (scoop/choco) — scoop install ffmpeg or choco install ffmpeg
- macOS (Homebrew) — brew install ffmpeg
- Linux (apt/yum/pacman) — sudo apt install ffmpeg or equivalent
After installing, verify both commands are available:
`bash
yt-dlp --version
ffmpeg -version
`
💻 CLI Usage
$3
#### No Parameters (default)
`bash
ytsave https://www.youtube.com/watch?v=dQw4w9WgXcQ
`
`bash
ytsave https://www.youtube.com/playlist?list=PL123456789
`
#### With Parameters
`bash
ytsave https://www.youtube.com/watch?v=dQw4w9WgXcQ --format mp4 --output ./videos
`
`bash
ytsave https://www.youtube.com/playlist?list=PL123456789 --format mp3 --output ./music
`
$3
* --format → Output format (default: mp4)
* --output → Output directory (default: current folder)
📖 Library Usage
$3
`js
import { downloadVideo, downloadPlaylist } from "ytsave";
`
$3
`js
await downloadVideo("https://www.youtube.com/watch?v=dQw4w9WgXcQ", {
format: "mp4",
output: "./videos",
});
`
$3
`js
await downloadPlaylist("https://www.youtube.com/playlist?list=PL123456789", {
format: "mp3",
output: "./music",
});
`
⚙️ API
$3
Downloads a single YouTube video.
url (string)*: YouTube video URL
options.format (string)*: "mp4" or "mp3"
options.output (string)*: Output directory path
$3
Downloads an entire YouTube playlist.
url (string)*: YouTube playlist URL
options.format (string)*: "mp4" or "mp3"
options.output` (string)*: Output directory path