// Event: when download starts YD.on("progress", (data) => console.log( $data.progress.percentage% downloaded ); );
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 ); youtube-mp3-downloader npm
Here's a basic example of how to use the package: // Event: when download starts YD