youtube-dl runner in node.js. Fork of https://github.com/skt-t1-byungi/ytdl-run which adds improvements to install.js (hopefully to be merged by upstream project)
yarn add ytdl-run
const ytdl = require('ytdl-run')
// supports async/await
(async _=>{
// download file into current working directory
await ytdl('https://www.youtube.com/watch?v=JQGRg8XBnB4')
console.log('downloaded!')
})()
const info = await ytdl.getInfo('https://www.youtube.com/watch?v=JQGRg8XBnB4')
console.log(info.title) // [MV] MOMOLAND (모모랜드) _ BBoom BBoom (뿜뿜)
console.log(info.duration) // 210
const fs = require('fs')
ytdl.stream('https://www.youtube.com/watch?v=JQGRg8XBnB4')
.stdout
.pipe(fs.createWriteStream('video.mp4'))
const opts = [
'-o', '%(title)s.%(ext)s',
'--audio-quality', '0',
'https://www.youtube.com/watch?v=JQGRg8XBnB4'
]
ytdl(opts)
MIT