# node-ytdlp-wrap

> A basic yt-dlp wrapper for node projects. Installs the correct binary of yt-dlp for the current platform. Supports Linux, Windows, and MacOS/X.

Latest version **1.2.0** (published 2022-12-17) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install node-ytdlp-wrap
pnpm add node-ytdlp-wrap
yarn add node-ytdlp-wrap
bun add node-ytdlp-wrap
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2022-12-17 |
| First published | 2022-04-16 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 44.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 1 |
| Author | Bwu1324 |
| Maintainers | bwu1324 |
| Keywords | yt-dlp, youtube, nodejs, installer, binary |

## Links

- npm: https://www.npmjs.com/package/node-ytdlp-wrap
- Repository: https://github.com/bwu1324/node-yt-dlp
- Homepage: https://github.com/bwu1324/node-yt-dlp#readme
- Issues: https://github.com/bwu1324/node-yt-dlp/issues
- npm.io page: https://npm.io/package/node-ytdlp-wrap

## Dependencies (1)

- [follow-redirects](https://npm.io/package/follow-redirects.md) ^1.14.9

## Recent versions

- 1.2.0 (latest) — 2022-12-17
- 1.1.0 — 2022-04-16
- 1.0.4 — 2022-04-16
- 1.0.3 — 2022-04-16
- 1.0.2 — 2022-04-16
- 1.0.1 — 2022-04-16
- 1.0.0 — 2022-04-16

## README

# node-yt-dlp
A basic yt-dlp wrapper written in Typescript for Node projects. 

Installs the correct binary of yt-dlp for the current platform. Supports Linux, Windows, and MacOS/X.

# Installation
Install with [npm](https://www.npmjs.com/):
```
$ npm --save i node-ytdlp-wrap
```

# Usage Example

## Stream

### Typescript
Downloads a video from youtube and saves it as 'example.mp4'
```
import ytdlp from 'node-ytdlp-wrap';
import fs from 'fs';

const link = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';

const stream = ytdlp.stream(link, ['-f', 'bestvideo']);
stream.pipe(fs.createWriteStream('example.mp4'));
```
### ES6
Downloads a video from youtube and saves it as 'example.mp4'
```
const ytdlp = require('node-ytdlp-wrap');
const fs = require('fs');

const link = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';

const stream = ytdlp.stream(link, ['-f', 'bestvideo']);
stream.pipe(fs.createWriteStream('example.mp4'));
```

## Downloader
### Typescript

Downloads a video from youtube and saves it as 'example.mp4' but aborts partway
```
import ytdlp from 'node-ytdlp-wrap';
import fs from 'fs';


const link = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';

const downloader = ytdlp.downloader(link, ['-f', 'bestvideo']);
downloader.stream.pipe(fs.createWriteStream('example.mp4'));

// Abort the download after 2 seconds
setTimeout(() => {
  downloader.Abort();
}, 2000);
```
### ES6

Downloads a video from youtube and saves it as 'example.mp4' but aborts partway
```
const ytdlp = require('node-ytdlp-wrap');
const fs = require('fs');

const link = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';

const downloader = ytdlp.downloader(link, ['-f', 'bestvideo']);
downloader.stream.pipe(fs.createWriteStream('example.mp4'));

// Abort the download after 2 seconds
setTimeout(() => {
  downloader.Abort();
}, 2000);
```
# Documentation

## ytdlp Methods
### ytdlp.downloader(link, [optional args]) 
Spawns YT-DLP to download the given link using the args given and returns [YtdlpDownloader](#YtdlpDownloader).
For a list of avaliable arguments, see [YT-DLP Options](https://github.com/yt-dlp/yt-dlp/blob/master/README.md#usage-and-options)


### ytdlp.stream(link, [optional args])
Spawns YT-DLP to download the given link using the args given and returns passthrough stream.
For a list of avaliable arguments, see [YT-DLP Options](https://github.com/yt-dlp/yt-dlp/blob/master/README.md#usage-and-options)

## ytdlp Properties

### ytdlp.path
Path of YT-DLP binary

### ytdlp.version
Version of YT-DLP used

## YtdlpDownloader Methods

### YtdlpDownloader.Abort()
Aborts download and ends output stream (only aborts once, repeat calls do nothing)

## YtdlpDownloader Properties
### YtdlpDownloader.stream
Passthrough stream of video download

---
_Source: https://npm.io/package/node-ytdlp-wrap · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
