Files
YouTube.js/examples/download/basic/index.js
2022-06-16 13:46:43 -03:00

21 lines
647 B
JavaScript

// import Innertube from 'youtubei.js';
const { createWriteStream } = require('fs');
const Innertube = require('../../../lib/Innertube');
(async () => {
// instantiate the library
const yt = await new Innertube();
// download the video
// the default options are to download with 360p quality
// with both audio and video in an mp4 container
yt.download('bUHZ2k9DYHY')
.pipe(createWriteStream('./stream.mp4'))
.on('progress', progress => {
console.log(`Downloaded ${progress.percent}%`);
})
.on('finish', () => {
console.log('Download finished');
});
})();