mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-18 12:02:11 +00:00
21 lines
647 B
JavaScript
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');
|
|
});
|
|
})();
|