yt-streamer
v6.7.23
Published
YouTube downloader
Downloads
185
Maintainers
Readme
yt-streamer
A Node.js YouTube downloader with support for YouTube, Instagram, and TikTok
Installation
npm install yt-streamerUsage
YouTube Download (yt-dlp based)
const { DownloadMusic, DownloadVideo } = require('yt-streamer');
const fs = require('fs');
(async () => {
// Download audio (M4A format)
const audioPath = await DownloadMusic('VIDEO_ID');
const audioBuffer = fs.readFileSync(audioPath);
// Download video (default: 480p, MP4 format)
const videoPath = await DownloadVideo('VIDEO_ID');
const videoBuffer = fs.readFileSync(videoPath);
// Download video with custom quality (720p, 1080p, etc.)
const hdVideoPath = await DownloadVideo('VIDEO_ID', '720');
const hdVideoBuffer = fs.readFileSync(hdVideoPath);
})();YouTube API (Fast, URL-based)
const { YouTubeDL } = require('yt-streamer');
(async () => {
const result = await YouTubeDL('https://www.youtube.com/watch?v=VIDEO_ID');
console.log(result);
// Returns: { title, vid, url, quality: "360p", type: "mp4" }
// Use the URL to stream or download
const response = await fetch(result.url);
const videoBuffer = await response.arrayBuffer();
})();Usage Tubidy
const { searchTubidy, getDetail } = require('yt-streamer');
(async () => {
const results = await searchTubidy('eminem');
const detail = await getDetail(results[0].link);
console.log(detail);
})();Instagram Download
const { InstagramDL } = require('yt-streamer');
(async () => {
const result = await InstagramDL('https://www.instagram.com/p/POST_ID/');
console.log(result);
// Returns: { type: "video|image", url, quality, size, title, vid }
// Download the media
const response = await fetch(result.url);
const mediaBuffer = await response.arrayBuffer();
})();TikTok Download
const { TikTokDL } = require('yt-streamer');
(async () => {
const result = await TikTokDL('https://www.tiktok.com/@user/video/VIDEO_ID');
console.log(result);
// Returns: { title, author, thumbnail, url }
// Download the video
const response = await fetch(result.url);
const videoBuffer = await response.arrayBuffer();
})();Function Details
DownloadMusic(videoId)
- Downloads audio in M4A format using yt-dlp
- Returns: File path to downloaded audio
- Quality: Best available audio
DownloadVideo(videoId, quality = "480")
- Downloads video in MP4 format using yt-dlp
- Returns: File path to downloaded video
- Quality: Default 480p, customizable (720, 1080, etc.)
YouTubeDL(url)
- Fast API-based YouTube URL extraction
- Returns: Object with title, video ID, direct URL, and quality info
- Quality: 360p MP4
InstagramDL(url)
- Instagram media URL extraction
- Returns: Object with media type, URL, quality, and metadata
- Supports: Videos and images
TikTokDL(url)
- TikTok video URL extraction
- Returns: Object with title, author, thumbnail, and video URL
- Supports: TikTok videos
Notes
- The
DownloadMusicandDownloadVideofunctions download files to disk - The API-based functions (
YouTubeDL,InstagramDL,TikTokDL) return direct URLs for streaming - API functions are faster but may have quality limitations
- yt-dlp functions are slower but offer better quality and reliability
Owner: Diegoson
