parse-m3u8
v1.0.1
Published
Parse M3U8
Downloads
212
Maintainers
Readme
parse-m3u8
A Node.js module to parse M3U8
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
npm install parse-m3u8
API
const parseM3u8 = require('parse-m3u8');
parseM3u8(contents [, option])
contents: string
option: Object
Return: Object
It parses a given string
with m3u8-parser and returns a result Object
.
option.baseUri
Type: string | URL
Rebase uri
properties of each items in playlists
and segments
to this URL.
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 © 2018 - 2019 Watanabe Shinnosuke