Youtube-mp3-download [2021]er Npm Jun 2026
// Configure the downloader const YD = new YoutubeMp3Downloader( outputPath: "./downloads", // Where to save the MP3s youtubeVideoQuality: "highest", // Audio quality from YouTube queueParallelism: 2, // Download 2 videos at once progressTimeout: 2000, // How often to emit 'progress' (ms) allowWebm: false // Prefer opus audio (requires ffmpeg) );
When instantiating the constructor, you can pass several options to fine-tune its performance and output: Description ffmpegPath System default Absolute path to your system's FFmpeg binary. outputPath Current directory Relative or absolute path where MP3 files are written. youtubeVideoQuality highestaudio
downloader.on("error", (e) => console.error("\n❌", e); process.exit(1); ); );
Verify the provided path exists and that the Node.js process has permission to write to it. youtube-mp3-downloader npm
const filePath = path.join(DOWNLOAD_DIR, data.file); res.download(filePath, data.file, (err) => if (err) console.error("File send error:", err); // Optionally delete the file after download to save space // fs.unlinkSync(filePath); ); );
Instead of manually spawning child processes or handling streams, this package provides a clean, event-driven API.
async function downloadWithTitle(videoUrl) const videoId = new URL(videoUrl).searchParams.get("v"); const info = await ytdl.getInfo(videoId); const title = info.videoDetails.title.replace(/[^\w\s]/gi, ""); // Sanitize YD.download(videoId, $title.mp3 ); // Configure the downloader const YD = new
Provides real-time progress events for downloads. Customizable Quality: Allows selection of audio quality. Automatic Cleanup: Handles temporary files efficiently. Prerequisites
The package emits events at various stages of the download process. Listening to these events allows monitoring progress, handling errors, and performing actions upon completion.
const getDownloadDetails = require('youtube-downloader-cc-api'); const filePath = path
// Start download (using a well-known Creative Commons video) const videoId = "Vhd6Kc4TZls"; // "Cold Funk - Funkorama" downloader.download(videoId);
If you would like, pleasejs API server , into the finished MP3s, or handling network proxy options to avoid rate limits. Share public link
// Download the video using its ID (from the URL) YD.download("Vhd6Kc4TZls");
The package uses FFmpeg’s -ab (audio bitrate) flag. Insert it via the ffmpegParams option: