- First create a file in
/react/components/{filename}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const ytdl = require('ytdl-core'); | |
const sanitize = require("sanitize-filename"); | |
async function downloadVideos(urls) { | |
try { | |
for (const url of urls) { | |
const info = await ytdl.getInfo(url); | |
const title = info.videoDetails.title; | |
const filename = sanitize(`${title}.mp3`); |