yt-rip
v1.0.1
Published
Cross-platform YouTube video and playlist downloader CLI and Node.js / Bun library powered by yt-dlp and ffmpeg.
Maintainers
Readme
yt-rip
Cross-platform, reliable media and playlist downloader CLI and Node.js / Bun library with automatic retry handling, stream multiplexing, and live progress reporting.
Key Highlights
- Cross-Platform Compatibility: Tested and supported across Windows, macOS, and Linux.
- Configurable Retry Engine: Built-in exponential retry policy handles transient drops, rate limits, and network hiccups automatically.
- Live Terminal Progress Bar: Interactive CLI progress visualization with download speed, downloaded percentage, ETA, and size metrics.
- Progress Callback Hook: Programmatic
onProgresshook gives your custom apps granular real-time transfer stats. - Dual Module Exports: Comprehensive native support for ES Modules (
import) and CommonJS (require) with complete TypeScript declarations. - Stream Merging: Uses bundled
ffmpeg-staticor detects system FFmpeg to merge high-resolution video and audio streams into single containers (mp4,mkv,mp3, etc.).
Installation
Instant Execution (No install required)
npx yt-rip "https://www.youtube.com/watch?v=dQw4w9WgXcQ"Global CLI Installation
npm install -g yt-ripAdd to Project Dependencies
npm install yt-ripCommand-Line Usage
yt-rip <url> [options]
# or: ytd <url> [options]Command Options
| Option | Shorthand | Description | Default |
|---|---|---|---|
| --output <dir> | -o | Destination directory for saved files | ./downloads |
| --template <str> | -t | yt-dlp filename output template | %(title)s.%(ext)s |
| --format <selector> | -f | Stream format selector | bestvideo[ext=mp4][height<=1080]+bestaudio[ext=m4a]/best[ext=mp4]/best |
| --merge <ext> | -m | Container extension to merge streams | mp4 |
| --retries <number> | -r | Number of retries on transient errors | 3 |
| --retry-delay <ms> | | Delay between retry attempts in milliseconds | 2000 |
| --no-playlist | | Download only the target video if URL is part of a playlist | false |
| --ffmpeg <path> | | Specify explicit path to an FFmpeg binary | Auto-detected |
| --quiet | | Suppress progress output and notifications | false |
| --version | -v | Display package version | |
| --help | -h | Display help screen | |
Common CLI Recipes
1. Basic Single Video Download
ytd "https://www.youtube.com/watch?v=dQw4w9WgXcQ"2. Download Entire Playlist to Specific Folder
ytd "https://www.youtube.com/playlist?list=PL12345" -o ./courses3. Extract High-Quality Audio as MP3
ytd "https://www.youtube.com/watch?v=dQw4w9WgXcQ" -f "bestaudio/best" -m mp3 -o ./music4. Robust Download with 5 Retries on Unstable Connections
ytd "https://www.youtube.com/watch?v=dQw4w9WgXcQ" -r 5 --retry-delay 30005. Download Single Video from a Playlist URL
ytd "https://www.youtube.com/watch?v=dQw4w9WgXcQ&list=PL12345" --no-playlistProgrammatic API
TypeScript & ES Modules
import { download, parseProgressLine, getFfmpegPath } from 'yt-rip';
async function run() {
const result = await download('https://www.youtube.com/watch?v=dQw4w9WgXcQ', {
outputDir: './downloads',
retries: 3,
retryDelayMs: 2000,
onProgress: (progress) => {
console.log(`[${progress.percent}%] Speed: ${progress.speed} - ETA: ${progress.eta}`);
}
});
console.log(`Completed in ${result.attempts} attempt(s):`, result.outputDir);
}
run().catch(console.error);CommonJS
const { download } = require('yt-rip');
download('https://www.youtube.com/watch?v=dQw4w9WgXcQ', {
outputDir: './media',
retries: 2
})
.then(res => console.log('Downloaded successfully:', res))
.catch(err => console.error('Download error:', err.message));Verification & Testing
The package includes a comprehensive test suite executed with Node's native test runner:
# Run unit and integration tests
npm test
# Verify TypeScript types
npm run typecheck
# Build distributions
npm run build