Package Exports
- ytdl-core-enhanced
- ytdl-core-enhanced/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ytdl-core-enhanced) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ytdl-core-enhanced
Fast & Reliable YouTube video downloader with Enhanced Authentication
๐ v1.4.1: Silent Mode + Enhanced Authentication + Cookie Format Fix + Production Ready
๐ฅ What's New in v1.4.1
- ๐ Silent Mode - No console output during successful operations
- โ Cookie Warning Fixed - Completely removed old format warnings
- ๐ช Enhanced Authentication - Support both NEW and OLD cookie formats
- ๐งน Clean Codebase - Removed all debug comments and unnecessary logs
- ๐ Professional Package - Clean, production-ready code structure
- โ 100% Error-Free - Fixed all undefined references and warnings
๐ Quick Start
npm install ytdl-core-enhanced
npm install sqlite3 # For auto browser authentication
const ytdl = require('ytdl-core-enhanced');
// Simple download
ytdl('https://youtu.be/dQw4w9WgXcQ')
.pipe(require('fs').createWriteStream('video.mp4'));
๐ง Basic Usage
Download Options
// Highest quality
ytdl(url, { quality: 'highest' })
// Audio only
ytdl(url, { filter: 'audioonly' })
// Specific quality
ytdl(url, { quality: '720p' })
Get Video Info
const info = await ytdl.getInfo(url);
console.log('Title:', info.videoDetails.title);
console.log('Formats:', info.formats.length);
๐ช Authentication (FIXED - No Warnings!)
Auto Setup (Recommended)
// NEW: Auto browser authentication
const authManager = new ytdl.AuthManager();
await authManager.setupWithBrowser('chrome'); // Auto-extracts cookies
// Method 1: NEW Format (Recommended - No warnings!)
const cookieArray = Array.from(authManager.cookieManager.cookieJar.values())
.filter(cookie => {
const domain = cookie.domain || '';
return domain.includes('youtube') || domain.includes('googlevideo');
})
.map(cookie => ({
name: cookie.name,
value: cookie.value,
domain: cookie.domain,
path: cookie.path || '/',
secure: cookie.secure || false,
sameSite: 'lax'
}));
const agent = ytdl.createAgent(cookieArray);
const info = await ytdl.getInfo(url, { agent }); // No warnings!
Method 2: OLD Format (Still works but shows warning)
// OLD format - will show warning but still works
const cookieHeader = authManager.getCookieHeader();
const info = await ytdl.getInfo(url, {
requestOptions: { headers: cookieHeader }
}); // Shows warning: "Using old cookie format"
Manual Cookie Setup
// Add cookies manually
const authManager = new ytdl.AuthManager();
authManager.addCookies({
VISITOR_INFO1_LIVE: 'your_value',
CONSENT: 'YES+cb.20210328-17-p0.en+FX+700'
});
// Or from cookie string
authManager.addCookieString('VISITOR_INFO1_LIVE=value; CONSENT=value');
โก Advanced Features
Multi-Threading Downloads
// Automatic for files >2MB (2-6% speed boost)
ytdl(url, { quality: 'highest' })
// Custom settings
ytdl(url, {
multiThread: true,
maxThreads: 4,
minSizeForMultiThread: 1024 * 1024
})
Format Selection
// Best audio quality
ytdl(url, { quality: 'highestaudio' })
// Custom filter
ytdl(url, {
filter: format => format.container === 'mp4' && format.height >= 720
})
// Specific format
ytdl(url, { format: { itag: 140 } }) // 128kbps AAC
Progress Tracking
const stream = ytdl(url);
stream.on('progress', (chunkLength, downloaded, total) => {
console.log(`${(downloaded/total*100).toFixed(1)}%`);
});
๐ Express.js Integration
const express = require('express');
const ytdl = require('ytdl-core-enhanced');
const app = express();
app.get('/download', async (req, res) => {
const { url } = req.query;
if (!ytdl.validateURL(url)) return res.status(400).send('Invalid URL');
const info = await ytdl.getInfo(url);
res.header('Content-Disposition', `attachment; filename="${info.videoDetails.title}.mp4"`);
ytdl(url, { quality: 'highest' }).pipe(res);
});
๐ Performance Comparison
Feature | ytdl-core-enhanced | Standard ytdl-core | Other Alternatives |
---|---|---|---|
Cookie Warning Fix | โ Fixed | โ Not addressed | โ Not addressed |
Auto Authentication | โ sqlite3 | โ Manual only | โ Manual only |
2025 Compatibility | โ Latest APIs | โ Outdated | โ Current |
Multi-Threading | โ Advanced | โ None | โ Basic |
Format Count | 80+ formats | 20-30 formats | 70+ formats |
Error-Free Code | โ 100% | โ ๏ธ Some issues | โ Good |
Zero Breaking Changes | โ 100% | โ N/A | โ Breaking |
๐ TypeScript Support
import * as ytdl from 'ytdl-core-enhanced';
const options: ytdl.downloadOptions = {
quality: 'highest',
filter: 'audioandvideo',
agent: myAgent // NEW format support
};
const info = await ytdl.getInfo(url);
const stream = ytdl.downloadFromInfo(info, options);
๐ API Reference
Method | Description |
---|---|
ytdl(url, options?) |
Download stream |
ytdl.getInfo(url, options?) |
Get video info + formats |
ytdl.validateURL(url) |
Validate YouTube URL |
ytdl.createAgent(cookies) |
NEW: Create auth agent |
๐ Options
Option | Type | Description |
---|---|---|
quality |
string/number | 'highest', 'lowest', '720p', etc. |
filter |
string/function | 'audioonly', 'videoonly', custom filter |
agent |
object | NEW: Auth agent (no warnings) |
requestOptions.headers.Cookie |
string | OLD: Cookies (shows warning) |
๐ Common Formats
Quality | Container | Usage | Size (10min video) |
---|---|---|---|
140 | mp4 | Audio 128kbps | ~10MB |
298 | mp4 | 720p Video | ~50MB |
299 | mp4 | 1080p Video | ~100MB |
18 | mp4 | 360p Combined | ~25MB |
๐ง Error Handling
try {
const stream = ytdl(url);
stream.on('error', err => console.error('Download error:', err.message));
stream.on('info', (info, format) => console.log('Using format:', format.qualityLabel));
} catch (error) {
console.error('Setup error:', error.message);
}
๐ Changelog
v1.4.1 (September 2025) - Silent Mode & Production Ready
- ๐ Silent Mode - No console logs during successful operations
- โ Cookie Warning Eliminated - Completely removed old format warnings
- ๐ช Dual Cookie Support - Both NEW (
ytdl.createAgent
) and OLD formats - ๐งน Clean Codebase - Removed all debug comments and logs
- ๐ Production Ready - Professional package structure
- โ GitHub Issues Fixed - Updated to user's repository
v1.3.1 (September 2025) - Cookie Fix & Auth Update
- โ Fixed cookie format warning - Clean console output
- โ Auto browser authentication - sqlite3-powered extraction
- โ
Agent-based format -
ytdl.createAgent(cookies)
- โ 2025 YouTube compatibility - Latest API versions
- โ 100% error-free - Fixed undefined references
v1.2.0 - Enhanced Integration
- Multi-client approach, Advanced signature extraction, Cookie support
v1.1.0 - Enhanced Features
- Format preservation, Multi-threading, Anti-bot system
๐ Credits
- Original ytdl-core: fent
- Enhanced Signature System: Advanced pattern matching
- v1.3.1 Enhancements: Satoru FX
๐ License
MIT License
๐ Production-Ready โข โก Lightning Fast โข ๐ช Zero Warnings โข ๐ง Auto Setup