# youtube-information-parser

> node module to parse the source video url of a youtube video

Latest version **1.0.7** (published 2020-07-29) · MIT license · 0 weekly downloads

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

## Install

```sh
npm install youtube-information-parser
pnpm add youtube-information-parser
yarn add youtube-information-parser
bun add youtube-information-parser
```

## Health

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

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2020-07-29 |
| First published | 2020-07-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 30.4 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Marius Butz |
| Maintainers | mbpictures |
| Keywords | youtube, link, video, url, parser, source, download |

## Links

- npm: https://www.npmjs.com/package/youtube-information-parser
- Repository: https://github.com/mbpictures/youtube-information-parser
- Homepage: https://github.com/mbpictures/youtube-information-parser#readme
- Issues: https://github.com/mbpictures/youtube-information-parser/issues
- npm.io page: https://npm.io/package/youtube-information-parser

## Dependencies (2)

- [request](https://npm.io/package/request.md) ^2.88.2
- [@types/request](https://npm.io/package/@types/request.md) ^2.48.5

## Recent versions

- 1.0.7 (latest) — 2020-07-29
- 1.0.6 — 2020-07-29
- 1.0.5 — 2020-07-28
- 1.0.4 — 2020-07-27
- 1.0.2 — 2020-07-26
- 1.0.1 — 2020-07-26
- 1.0.0 — 2020-07-26

## README

# Youtube Information Parser
[![DeepScan grade](https://deepscan.io/api/teams/10967/projects/13904/branches/246156/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=10967&pid=13904&bid=246156)
[![npm](https://img.shields.io/npm/v/youtube-information-parser)](https://www.npmjs.com/package/youtube-information-parser)

This module allows you to retrieve information about title, creator, clicks, thumbnails and raw video urls of any youtube video you want!

## Installation
To install this module, simply run the following command:
```
npm install --save youtube-url-parser
```

## Usage
The first thing you have to do is to import it:
```TypeScript
import * from "youtube-url-parser";
```

After that, you can create a new ```YoutubeLoader``` object like this:
```TypeScript
let loader: YoutubeLoader = new YoutubeLoader("https://youtube.com/watch?v=VIDEO_ID");
```
Execute the ```getVideoLinks()``` function to retrieve all information about the video. This function returns a promise, which means you can either use the ```.then(...)``` and ```.catch(...)``` functions or prefix the function call with a ```await``` statement to handle asynchronous behavior.

When you only need the ```StreamingInfo``` which contains the video of the highest quality, execute the ```getBestQualityStreamingInfo(filters?: Filter): Promise<StreamingInfo>``` function. This will return the ```StreamingInfo``` with the highest video dimensions. To retrieve only videos which match specific attributes, like ```audio: true```, specify them in the optional filters parameter. The parameter is of type ```[FilterType, keyof StreamingInfo, any][]``` which means, that you can provide an array of 3-tuples. The first element of the tuple represents the comparison type (e.g. ==, <=, >=, ...), the second the key you want to check (e.g. ```"audio"```) and the last element represents the value of the key (e.g. ```true```). To retrieve the video with the highest quality which contains audio, you would call:
 ```TypeScript
 getBestQualityStreamingInfo([[FilterType.EQUAL, "audio", true]])
 ```
To filter for a set of ```StreamingInfo```, that match your filter conditions, use the ```getFilteredStreamingInfo(filters: Filter): Promise<StreamingInfo[]>``` function.
### Download videos
To download a youtube video, the easiest way to do so is to create a new instance of the ```YoutubeDownloader``` class. Provide the URL of the youtube video and the download location (relative Path with filename) as parameters in the constructor. After that execute the ```downloadBestQuality(): Promise<string>``` to download the video with the highest video quality. You can otherwise search for a ```StreamingInfo``` and download the video with the specific ```StreamingInfo```.
## Contribution
This project is work in progress. Feel free to create pull requests or report bugs using the github issue tracker!

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