# ytdl-core-discord

> A ytdl-core wrapper focused on efficiency for use in Discord music bots

Latest version **1.3.1** (published 2021-06-12) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install ytdl-core-discord
pnpm add ytdl-core-discord
yarn add ytdl-core-discord
bun add ytdl-core-discord
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2021-06-12 |
| First published | 2019-02-18 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 16.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 72 |
| Author | Amish Shah |
| Maintainers | hydrabolt |
| Keywords | discord, ytdl, youtube, audio, music, bot |

## Links

- npm: https://www.npmjs.com/package/ytdl-core-discord
- Repository: https://github.com/amishshah/ytdl-core-discord
- Homepage: https://github.com/amishshah/ytdl-core-discord#readme
- Issues: https://github.com/amishshah/ytdl-core-discord/issues
- npm.io page: https://npm.io/package/ytdl-core-discord

## Dependencies (3)

- [ytdl-core](https://npm.io/package/ytdl-core.md) ^4.8.2
- [@types/node](https://npm.io/package/@types/node.md) ^15.12.2
- [prism-media](https://npm.io/package/prism-media.md) ^1.3.1

## Recent versions

- 1.3.1 (latest) — 2021-06-12
- 1.3.0 — 2021-03-20
- 1.2.5 — 2020-12-22
- 1.2.4 — 2020-10-23
- 1.2.3 — 2020-09-23
- 1.2.2 — 2020-09-18
- 1.2.1 — 2020-06-22
- 1.2.0 — 2020-04-12
- 1.1.0 — 2020-01-31
- 1.0.3 — 2019-02-22
- 1.0.2 — 2019-02-18
- 1.0.1 — 2019-02-18
- 1.0.0 — 2019-02-18

## README

# ytdl-core-discord

[![Build Status](https://travis-ci.org/amishshah/ytdl-core-discord.svg?branch=master)](https://travis-ci.org/amishshah/ytdl-core-discord)
[![dependencies](https://david-dm.org/amishshah/ytdl-core-discord/status.svg)](https://david-dm.org/amishshah/ytdl-core-discord)
[![npm](https://img.shields.io/npm/dt/ytdl-core-discord.svg)](https://www.npmjs.com/package/ytdl-core-discord)
[![Patreon](https://img.shields.io/badge/donate-patreon-F96854.svg)](https://www.patreon.com/discordjs)

A [ytdl-core](https://github.com/fent/node-ytdl-core/) wrapper focused on efficiency for use in Discord music bots.

You can pass the exact same arguments as you would with the ytdl-core module, with the exception that
you must `await` the function call.  

## What does it do?

For compatible videos, this module uses [prism-media](https://github.com/amishshah/prism-media)
to extract Opus audio from a stream without having to pipe it through FFmpeg first. This greatly
reduces the processing power required, making playback smoother and allowing you to play over
more connections simultaneously.

For videos where the required codec (webm + opus) isn't available, the module will fallback to
using FFmpeg to encode the stream in Opus. Many new videos on YouTube are available in this codec
so hopefully this isn't frequent.

Put simply, this module finds the most efficient way to extract a stream of Opus audio from a
YouTube video. Even in the worst case, it should still give better performance than `ytdl-core`.

## Usage in Discord.js 12.x

```js
const ytdl = require('ytdl-core-discord');

async function play(connection, url) {
  connection.play(await ytdl(url), { type: 'opus' });
}
```

## Usage in Discord.js 11.4.x

```js
const ytdl = require('ytdl-core-discord');

async function play(connection, url) {
  connection.playOpusStream(await ytdl(url));
}
```

[![Patreon](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/discordjs)

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