ytdlku
v1.0.1
Published
Lightweight YouTube downloader module with search, suggestions, and download capabilities
Maintainers
Readme
ytdlku
Lightweight YouTube downloader module with search, suggestions, and download capabilities. Supports both ESM and CommonJS with TypeScript.
Features
- 🔍 YouTube Search - Search videos with customizable results
- 💡 Search Suggestions - Get YouTube search suggestions
- ℹ️ Video Information - Get detailed video metadata
- 🎵 Audio Download - Download audio in MP3 format
- 🎬 Video Download - Download video in MP4 format
- 📱 Format Selection - Choose quality using itag
- 🔑 API Key Support - Optional authentication
Installation
npm install ytdlkuUsage
Import
// ES Module
import YTDownloader from 'ytdlku';
// CommonJS
const YTDownloader = require('ytdlku').default;Initialize
const yt = new YTDownloader({
baseUrl: 'https://ytdl.siputzx.my.id', // optional
apiKey: 'your-api-key', // optional
timeout: 30000 // optional, default 30s
});Search Suggestions
const suggestions = await yt.getSuggestions('kucing');
console.log(suggestions);
// ['kucing', 'kucing lucu', 'kucing berantem', ...]Search Videos
const results = await yt.search('kucing', 10); // limit 10 results
console.log(results);
/*
[
{
type: 'video',
id: 'bnVUHWCynig',
title: 'Video Title',
thumbnail: 'https://...',
channel: { name: '...', id: '...', url: '...' },
views: '1,000 views',
published: '2 days ago',
url: 'https://youtube.com/watch?v=...'
}
]
*/Get Video Information
const info = await yt.getVideoInfo('bnVUHWCynig');
console.log(info);
/*
{
id: 'bnVUHWCynig',
title: 'Video Title',
description: '...',
duration: '3:45',
thumbnail: 'https://...',
video_formats: [...],
audio_formats: [...],
// ... more info
}
*/Download Audio (Simple)
// Quick download - waits for completion
const downloadUrl = await yt.downloadAudioComplete(
'https://youtube.com/watch?v=bnVUHWCynig',
140
);
console.log('Download URL:', downloadUrl);Download Video (Simple)
// Quick download - waits for completion
const downloadUrl = await yt.downloadVideoComplete(
'https://youtube.com/watch?v=bnVUHWCynig',
136
);
console.log('Download URL:', downloadUrl);Manual Download Control
// Start download task
const task = await yt.downloadAudio('https://youtube.com/watch?v=...', 140);
console.log('Task ID:', task.taskId);
// Check status manually
const status = await yt.getDownloadStatus(task.taskId);
console.log('Status:', status.data.status);
// Or wait for completion with custom polling
const finalStatus = await yt.waitForDownload(task.taskId, 1000, 60); // 1s interval, 60 attempts
console.log('Download URL:', finalStatus.data.result.downloadUrl);API Limits
| Feature | Free | Premium | |---------|------|---------| | Video Duration | 30 minutes | Unlimited | | File Size | 100MB | Unlimited | | Resolution | 720p | Unlimited | | Rate Limit | 10/10min | 100/10min |
Error Handling
try {
const downloadUrl = await yt.downloadAudioComplete(url, 140);
console.log('Success:', downloadUrl);
} catch (error) {
console.error('Error:', error.message);
}TypeScript
Full TypeScript support with interfaces:
import YTDownloader, { VideoInfo, SearchResult } from 'ytdlku';
const yt = new YTDownloader();
const info: VideoInfo = await yt.getVideoInfo('video_id');
const results: SearchResult[] = await yt.search('query');License
MIT License
Support
For issues and feature requests, please visit the GitHub repository.
