# ytpl

> Simple package to resolve YouTube playlists - no strings attached.

Latest version **2.3.0** (published 2022-03-04) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install ytpl
pnpm add ytpl
yarn add ytpl
bun add ytpl
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.3.0 |
| Published | 2022-03-04 |
| First published | 2017-02-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 1 |
| Unpacked size | 26.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 199 |
| Author | Tobias Kutscha |
| Maintainers | timeforaninja |
| Keywords | youtube, playlist, yt, video, videos, api, pl, scrape, pagination, promise |

## Links

- npm: https://www.npmjs.com/package/ytpl
- Repository: https://github.com/TimeForANinja/node-ytpl
- Homepage: https://github.com/TimeForANinja/node-ytpl#readme
- Issues: https://github.com/TimeForANinja/node-ytpl/issues
- npm.io page: https://npm.io/package/ytpl

## Dependencies (1)

- [miniget](https://npm.io/package/miniget.md) ^4.2.2

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 2.3.0 (latest) — 2022-03-04
- 2.2.3 — 2021-08-04
- 2.2.2 — 2021-08-04
- 2.2.1 — 2021-05-05
- 2.2.0 — 2021-04-25
- 2.1.1 — 2021-04-10
- 2.1.0 — 2021-03-31
- 2.0.5 — 2021-02-01
- 2.0.4 — 2020-12-23
- 2.0.3 — 2020-12-15
- 2.0.2 — 2020-12-15
- 2.0.1 — 2020-12-14
- 2.0.0 — 2020-12-13
- 2.0.0-alpha.3 — 2020-12-01
- 2.0.0-alpha.2 — 2020-11-29
- … 33 more at https://npm.io/package/ytpl/versions

## README

# node-ytpl
[![NPM version](https://img.shields.io/npm/v/ytpl.svg?maxAge=3600)](https://www.npmjs.com/package/ytpl)
[![NPM downloads](https://img.shields.io/npm/dt/ytpl.svg?maxAge=3600)](https://www.npmjs.com/package/ytpl)
[![codecov](https://codecov.io/gh/timeforaninja/node-ytpl/branch/master/graph/badge.svg)](https://codecov.io/gh/timeforaninja/node-ytpl)
[![Known Vulnerabilities](https://snyk.io/test/github/timeforaninja/node-ytpl/badge.svg)](https://snyk.io/test/github/timeforaninja/node-ytpl)
[![Discord](https://img.shields.io/discord/484464227067887645.svg)](https://discord.gg/V3vSCs7)

Simple js only package to resolve YouTube Playlists.
Does not require any login or Google-API-Key.

# Support
You can contact us for support on our [chat server](https://discord.gg/V3vSCs7)

# Usage

```js
const ytpl = require('ytpl');

const playlist = await ytpl('UU_aEa8K-EOJ3D6gOs7HcyNg');
```


# API
### ytpl(id, [options])

Attempts to resolve the given playlist id

* `id`
    * id of the yt-playlist
    * or a playlist url
    * or a user url (resolves to uploaded playlist)
    * or a channel url (resolves to uploaded playlist)
* `options`
    * object with options
    * possible settings:
    * gl[String] -> 2-Digit Code of a Country, defaults to `US` - Allows for localisation of the request
    * hl[String] -> 2-Digit Code for a Language, defaults to `en` - Allows for localisation of the request
    * limit[Number] -> limits the pulled items, defaults to 100, set to Infinity to get the whole playlist - numbers <1 result in the default being used
    * pages[Number] -> limits the pulled pages, pages contain 100 items, set to Infinity to get the whole playlist - numbers <1 result in the default limit being used - overwrites limit
    * requestOptions[Object] -> Additional parameters to passed to [miniget](https://github.com/fent/node-miniget), which is used to do the https requests

* returns a Promise
* [Example response](https://github.com/timeforaninja/node-ytpl/blob/master/example/example_output.txt)

### ytpl.continueReq(continuationData)
Continues a previous request by pulling yet another page.  
The previous request had to be done using `pages` limitation.

#### Usage
```js
const ytpl = require('ytpl');

const firstResultBatch = await ytpl('UU_aEa8K-EOJ3D6gOs7HcyNg', { pages: 1 });
const secondResultBatch = ytpl.continueReq(firstResultBatch.continuation);
const thirdResultBatch = ytpl.continueReq(secondResultBatch.continuation);

// You can now use the .items property of all result batches e.g.:
console.log(firstResultBatch.items);
console.log(secondResultBatch.items);
console.log(thirdResultBatch.items);
```

* returns a Promise resolving into `{ continuation, items }`

### ytpl.validateID(string)

Returns true if able to parse out a (formally) valid playlist ID.

### ytpl.getPlaylistID(string)

Returns a playlist ID from a YouTube URL. Can be called with the playlist ID directly, in which case it just resolves.

* returns a promise resolving into a string containing the id


# Related / Works well with

* [node-ytdl-core](https://github.com/fent/node-ytdl-core)
* [node-ytsr](https://github.com/TimeForANinja/node-ytsr)


# Install

    npm install --save ytpl


# License
MIT

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