# parse-m3u8

> Parse M3U8

Latest version **1.0.1** (published 2019-05-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install parse-m3u8
pnpm add parse-m3u8
yarn add parse-m3u8
bun add parse-m3u8
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-05-27 |
| First published | 2018-07-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Watanabe Shinnosuke |
| Maintainers | shinnn |
| Keywords | parse, m3u, m3u8, hls, live, streaming, video, movie, playlist, data |

## Links

- npm: https://www.npmjs.com/package/parse-m3u8
- Repository: https://github.com/shinnn/parse-m3u8
- Homepage: https://github.com/shinnn/parse-m3u8#readme
- Issues: https://github.com/shinnn/parse-m3u8/issues
- npm.io page: https://npm.io/package/parse-m3u8

## Dependencies (3)

- [m3u8-parser](https://npm.io/package/m3u8-parser.md) ^4.3.0
- [is-plain-obj](https://npm.io/package/is-plain-obj.md) ^2.0.0
- [inspect-with-kind](https://npm.io/package/inspect-with-kind.md) ^1.0.5

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-05-27
- 1.0.0 — 2018-07-25
- 0.1.0 — 2018-07-24
- 0.0.0 — 2018-07-23

## README

# parse-m3u8

[![npm version](https://img.shields.io/npm/v/parse-m3u8.svg)](https://www.npmjs.com/package/parse-m3u8)
[![Build Status](https://travis-ci.com/shinnn/parse-m3u8.svg?branch=master)](https://travis-ci.com/shinnn/parse-m3u8)
[![codecov](https://codecov.io/gh/shinnn/parse-m3u8/branch/master/graph/badge.svg)](https://codecov.io/gh/shinnn/parse-m3u8)

A [Node.js](https://nodejs.org/) module to parse [M3U8](https://en.wikipedia.org/wiki/M3U#M3U8)

```javascript
const parseM3u8 = require('parse-m3u8');

parseM3u8(`#EXTM3U
#EXT-X-TARGETDURATION:10
#EXTINF:10,
0.ts
#EXTINF:20,
1.ts
`).segments; /*=>  [
  {
    duration: 10,
    uri: '0.ts',
    timeline: 0
  },
  {
    duration: 20,
    uri: '1.ts',
    timeline: 0
  }
] */
```

## Installation

[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/).

```
npm install parse-m3u8
```

## API

```javascript
const parseM3u8 = require('parse-m3u8');
```

### parseM3u8(*contents* [, *option*])

*contents*: `string`  
*option*: `Object`  
Return: `Object`

It parses a given `string` with [m3u8-parser](https://github.com/videojs/m3u8-parser) and returns a [result `Object`](https://github.com/videojs/m3u8-parser#parsed-output).

#### option.baseUri

Type: `string | URL`

Rebase `uri` properties of each items in `playlists` and `segments` to this URL.

```javascript
const source = `#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=300000
low.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=600000
high.m3u8`;

parseM3u8(source).playlists; /*=> [
  {
    attributes: {BANDWIDTH: 300000},
    uri: 'low.m3u8',
    timeline: 0
  },
  {
    attributes: {BANDWIDTH: 600000},
    uri: 'high.m3u8',
    timeline: 0
  }
] */

parseM3u8(source, {baseUri: 'https://example.org/assets/playlists/'}).playlists; /*=> [
  {
    attributes: {BANDWIDTH: 300000},
    uri: 'https://example.org/assets/playlists/low.m3u8',
    timeline: 0
  },
  {
    attributes: {BANDWIDTH: 600000},
    uri: 'https://example.org/assets/playlists/high.m3u8',
    timeline: 0
  }
] */
```

## License

[ISC License](./LICENSE) © 2018 - 2019 Watanabe Shinnosuke

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