docs(download): examples for downloading videos

This commit is contained in:
Daniel Wykerd
2022-06-16 13:34:07 +02:00
committed by LuanRT
parent 60075f8726
commit 418dcac80a
6 changed files with 176 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
// 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');
});
})();