shadowx-ytdl
v1.0.0
Published
A powerful YouTube downloader and metadata API module for Node.js Author Mueid Mursalin Rifat
Maintainers
Readme
shadowx-ytdl
YouTube downloader for Node.js - download videos, get metadata, search, and more!
📦 Installation
npm install shadowx-ytdl🚀 Quick Start
Use as a Library
const ytdl = require('shadowx-ytdl');
// Get video info
const info = await ytdl.getVideoMetadata('https://youtube.com/watch?v=VIDEO_ID');
console.log(info.title);
// Download audio (MP3)
const audio = await ytdl.downloadAudio('https://youtube.com/watch?v=VIDEO_ID', 128);
console.log(audio.download.downloadUrl);
// Download video (MP4)
const video = await ytdl.downloadVideo('https://youtube.com/watch?v=VIDEO_ID', 720);
console.log(video.download.downloadUrl);
// Search videos
const results = await ytdl.searchYouTube('rick astley');
console.log(results.results);
// Get channel info
const channel = await ytdl.getChannelInfo('@MrBeast');
console.log(channel.title);Use as an API Server
const { createApp } = require('shadowx-ytdl');
const app = createApp();
app.listen(3000, () => {
console.log('Server running on port 3000');
});📚 Functions
getVideoMetadata(url)
Get video details like title, description, views, etc.
const info = await ytdl.getVideoMetadata('https://youtube.com/watch?v=VIDEO_ID');
// Returns: { title, channelTitle, views, likes, thumbnails, ... }downloadAudio(url, quality = 128)
Download video as MP3 audio.
Quality options: 92, 128, 256, 320
const audio = await ytdl.downloadAudio('https://youtube.com/watch?v=VIDEO_ID', 320);
// Returns: { downloadUrl, filename, quality }downloadVideo(url, quality = 360)
Download video as MP4.
Quality options: 144, 360, 480, 720, 1080
const video = await ytdl.downloadVideo('https://youtube.com/watch?v=VIDEO_ID', 1080);
// Returns: { downloadUrl, filename, quality }searchYouTube(query)
Search for videos on YouTube.
const results = await ytdl.searchYouTube('funny cats');
// Returns: { results: [ { title, url, videoId, author, ... } ] }getChannelInfo(input)
Get channel details.
const channel = await ytdl.getChannelInfo('@MrBeast');
// or
const channel = await ytdl.getChannelInfo('https://youtube.com/@MrBeast');
// Returns: { title, subscribers, videos, views, description, ... }🌐 API Endpoints (Server Mode)
When running as a server, these endpoints are available:
GET /yt
Get video info or download.
# Get info
/yt?url=https://youtube.com/watch?v=VIDEO_ID
# Download MP3
/yt?url=https://youtube.com/watch?v=VIDEO_ID&type=mp3
# Download MP4 (720p)
/yt?url=https://youtube.com/watch?v=VIDEO_ID&type=mp4&quality=720GET /search
Search videos.
/search?q=rick+astleyGET /channel
Get channel info.
/channel?id=@MrBeast📝 Example Responses
Video Info
{
"status": true,
"title": "Never Gonna Give You Up",
"channelTitle": "Rick Astley",
"statistics": {
"views": "1000000000",
"likes": "1000000"
}
}Download
{
"status": true,
"download": {
"downloadUrl": "https://cdn.example.com/video.mp3",
"filename": "Rick Astley - Never Gonna Give You Up (128kbps).mp3",
"quality": "128kbps"
}
}Search
{
"status": true,
"results": [
{
"title": "Rick Astley - Never Gonna Give You Up",
"url": "https://youtube.com/watch?v=dQw4w9WgXcQ",
"author": "Rick Astley",
"duration": "3:33",
"views": 1000000000
}
]
}Channel Info
{
"status": true,
"title": "MrBeast",
"statistics": {
"subscribers": "200000000",
"videos": "800",
"views": "10000000000"
}
}⚠️ Error Handling
All functions return error objects:
const result = await ytdl.getVideoMetadata('invalid-url');
if (!result.status) {
console.log('Error:', result.message);
}📄 License
MIT
👤 Author
Mueid Mursalin Rifat
⚠️ Disclaimer
For educational purposes only. Respect YouTube's Terms of Service.
