snippets/js/convert-ytdl-mp3.js

11 lines
331 B
JavaScript
Raw Permalink Normal View History

2024-10-02 23:47:38 +00:00
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'))