mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-07-02 21:52:48 +00:00
docs(download): examples for downloading videos
This commit is contained in:
20
examples/download/basic/index.js
Normal file
20
examples/download/basic/index.js
Normal 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');
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user