snippets/js/convert-ytdl-mp3.js
2024-10-03 01:47:38 +02:00

11 lines
331 B
JavaScript

const fs = require('fs'),
url = process.argv[2],
ytdl = require('ytdl-core'),
ffmpeg = require('fluent-ffmpeg'),
stream = new ffmpeg(ytdl(url, { filter: 'audioonly' }))
stream.on('error', function (err) {
console.log(err)
})
.format('mp3').pipe(fs.createWriteStream(__dirname + '/' + url.replace(/^.*v=/, '') + '.mp3'))