youtube-dlsr
TypeScript icon, indicating that this package has built-in type declarations

2.8.3 • Public • Published

youtube-dlsr

NPM Version NPM Downloads

Installing

npm install youtube-dlsr

GitHub

Example

Automatic format selection

const { download, search } = require('youtube-dlsr');
const { createWriteStream } = require('fs');

(async () => {
    // Search video.
    const result = await search('no copyright music', { type: 'video', limit: 1 });
    // Get suitable stream for live video or music bots.
    const stream = await download(result[0].url);
    // Write to file.
    stream.pipe(createWriteStream('./auto_no_copyright_music.ogg'));
})();

Manually format selection

const { getVideoInfo, search } = require('youtube-dlsr');
const { createWriteStream } = require('fs');

(async () => {
    // Search video.
    const result = await search('no copyright music', { type: 'video', limit: 1 });
    // Get info of video.
    const video = await getVideoInfo(result[0].url);
    // Get stream of selected format.
    const stream = video.download((f) => f.hasAudio);
    // Write to file.
    stream.pipe(createWriteStream('./manual_no_copyright_music.mp3'));
})();

Get playlist information

const { getPlaylistInfo, search } = require('youtube-dlsr');

(async () => {
    // Search playlist.
    const result = await search('no copyright music', { type: 'playlist', limit: 2 });
    // Get first page info of playlist.
    const list1 = await getPlaylistInfo(result[0].url);
    // Get full page info of playlist.
    const list2 = await getPlaylistInfo(result[1].url, true);
})();

Package Sidebar

Install

npm i youtube-dlsr

Weekly Downloads

10

Version

2.8.3

License

MIT

Unpacked Size

281 kB

Total Files

9

Last publish

Collaborators

  • cjh980402