Installations
npm install m3u8-parser
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
14.21.3
NPM Version
6.14.18
Score
98.7
Supply Chain
98.5
Quality
83.8
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (99.77%)
HTML (0.23%)
Developer
videojs
Download Statistics
Total Downloads
87,998,584
Last Day
43,004
Last Week
383,591
Last Month
2,001,854
Last Year
23,076,367
GitHub Statistics
483 Stars
130 Commits
101 Forks
25 Watching
10 Branches
28 Contributors
Package Meta Information
Latest Version
7.2.0
Package Id
m3u8-parser@7.2.0
Unpacked Size
517.77 kB
Size
90.80 kB
File Count
139
NPM Version
6.14.18
Node Version
14.21.3
Publised On
21 Aug 2024
Total Downloads
Cumulative downloads
Total Downloads
87,998,584
Last day
-53.9%
43,004
Compared to previous day
Last week
-20.6%
383,591
Compared to previous week
Last month
0.5%
2,001,854
Compared to previous month
Last year
-8.6%
23,076,367
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
m3u8-parser
m3u8 parser
Installation
1npm install --save m3u8-parser
The npm installation is preferred, but Bower works, too.
1bower install --save m3u8-parser
Usage
1var manifest = [ 2 '#EXTM3U', 3 '#EXT-X-VERSION:3', 4 '#EXT-X-TARGETDURATION:6', 5 '#EXT-X-MEDIA-SEQUENCE:0', 6 '#EXT-X-DISCONTINUITY-SEQUENCE:0', 7 '#EXTINF:6,', 8 '0.ts', 9 '#EXTINF:6,', 10 '1.ts', 11 '#EXT-X-PROGRAM-DATE-TIME:2019-02-14T02:14:00.106Z' 12 '#EXTINF:6,', 13 '2.ts', 14 '#EXT-X-ENDLIST' 15].join('\n'); 16 17var parser = new m3u8Parser.Parser(); 18 19parser.push(manifest); 20parser.end(); 21 22var parsedManifest = parser.manifest;
Constructor Options
The constructor optinally takes an options object with two properties. These are needed when using #EXT-X-DEFINE
for variable replacement.
1var parser = new m3u8Parser.Parser({
2 url: 'https://exmaple.com/video.m3u8?param_a=34¶m_b=abc',
3 mainDefinitions: {
4 param_c: 'def'
5 }
6});
options.url
string The URL from which the playlist was fetched. If the request was redirected this should be the final URL. This is required if usingQUERYSTRING
rules with#EXT-X-DEFINE
.options.mainDefinitions
object An object of definitions from the main playlist. This is required if usingIMPORT
rules with#EXT-X-DEFINE
.
Parsed Output
The parser ouputs a plain javascript object with the following structure:
1Manifest { 2 allowCache: boolean, 3 endList: boolean, 4 mediaSequence: number, 5 dateRanges: [], 6 discontinuitySequence: number, 7 playlistType: string, 8 custom: {}, 9 playlists: [ 10 { 11 attributes: {}, 12 Manifest 13 } 14 ], 15 mediaGroups: { 16 AUDIO: { 17 'GROUP-ID': { 18 NAME: { 19 default: boolean, 20 autoselect: boolean, 21 language: string, 22 uri: string, 23 instreamId: string, 24 characteristics: string, 25 forced: boolean 26 } 27 } 28 }, 29 VIDEO: {}, 30 'CLOSED-CAPTIONS': {}, 31 SUBTITLES: {} 32 }, 33 dateTimeString: string, 34 dateTimeObject: Date, 35 targetDuration: number, 36 totalDuration: number, 37 discontinuityStarts: [number], 38 segments: [ 39 { 40 title: string, 41 byterange: { 42 length: number, 43 offset: number 44 }, 45 duration: number, 46 programDateTime: number, 47 attributes: {}, 48 discontinuity: number, 49 uri: string, 50 timeline: number, 51 key: { 52 method: string, 53 uri: string, 54 iv: string 55 }, 56 map: { 57 uri: string, 58 byterange: { 59 length: number, 60 offset: number 61 } 62 }, 63 'cue-out': string, 64 'cue-out-cont': string, 65 'cue-in': string, 66 custom: {} 67 } 68 ] 69}
Supported Tags
Basic Playlist Tags
Media Segment Tags
- EXTINF
- EXT-X-BYTERANGE
- EXT-X-DISCONTINUITY
- EXT-X-KEY
- EXT-X-MAP
- EXT-X-PROGRAM-DATE-TIME
- EXT-X-DATERANGE
- EXT-X-I-FRAMES-ONLY
Media Playlist Tags
- EXT-X-TARGETDURATION
- EXT-X-MEDIA-SEQUENCE
- EXT-X-DISCONTINUITY-SEQUENCE
- EXT-X-ENDLIST
- EXT-X-PLAYLIST-TYPE
- EXT-X-START
- EXT-X-INDEPENDENT-SEGMENTS
- EXT-X-DEFINE
Main Playlist Tags
Experimental Tags
m3u8-parser supports 3 additional Media Segment Tags not present in the HLS specification.
EXT-X-CUE-OUT
The EXT-X-CUE-OUT
indicates that the following media segment is a break in main content and the start of interstitial content. Its format is:
#EXT-X-CUE-OUT:<duration>
where duration
is a decimal-floating-point or decimal-integer number that specifies the total duration of the interstitial in seconds.
EXT-X-CUE-OUT-CONT
The EXT-X-CUE-OUT-CONT
indicates that the following media segment is a part of interstitial content and not the main content. Every media segment following a media segment with an EXT-X-CUE-OUT
tag SHOULD have an EXT-X-CUE-OUT-CONT
applied to it until there is an EXT-X-CUE-IN
tag. A media segment between a EXT-X-CUE-OUT
and EXT-X-CUE-IN
segment without a EXT-X-CUE-OUT-CONT
is assumed to be part of the interstitial. Its format is:
#EXT-X-CUE-OUT-CONT:<n>/<duration>
where n
is a decimal-floating-point or decimal-integer number that specifies the time in seconds the first sample of the media segment lies within the interstitial content and duration
is a decimal-floating-point or decimal-integer number that specifies the total duration of the interstitial in seconds. n
SHOULD be the sum of EXTINF
durations for all preceding media segments up to the EXT-X-CUE-OUT
tag for the current interstitial. duration
SHOULD match the duration
specified in the EXT-X-CUE-OUT
tag for the current interstitial.'
EXT-X-CUE-IN
The EXT-X-CUE-IN
indicates the end of the interstitial and the return of the main content. Its format is:
#EXT-X-CUE-IN
There SHOULD be a closing EXT-X-CUE-IN
tag for every EXT-X-CUE-OUT
tag. If a second EXT-X-CUE-OUT
tag is encountered before an EXT-X-CUE-IN
tag, the client MAY choose to ignore the EXT-X-CUE-OUT
and treat it as part of the interstitial, or reject the playlist.
Example media playlist using EXT-X-CUE-
tags.
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:10
#EXTINF:10,
0.ts
#EXTINF:10,
1.ts
#EXT-X-CUE-OUT:30
#EXTINF:10,
2.ts
#EXT-X-CUE-OUT-CONT:10/30
#EXTINF:10,
3.ts
#EXT-X-CUE-OUT-CONT:20/30
#EXTINF:10,
4.ts
#EXT-X-CUE-IN
#EXTINF:10,
5.ts
#EXTINF:10,
6.ts
#EXT-X-ENDLIST
Not Yet Supported
Custom Parsers
To add a parser for a non-standard tag the parser object allows for the specification of custom tags using regular expressions. If a custom parser is specified, a custom
object is appended to the manifest object.
1const manifest = [ 2 '#EXTM3U', 3 '#EXT-X-VERSION:3', 4 '#VOD-FRAMERATE:29.97', 5 '' 6].join('\n'); 7 8const parser = new m3u8Parser.Parser(); 9parser.addParser({ 10 expression: /^#VOD-FRAMERATE/, 11 customType: 'framerate' 12}); 13 14parser.push(manifest); 15parser.end(); 16parser.manifest.custom.framerate // "#VOD-FRAMERATE:29.97"
Custom parsers may additionally be provided a data parsing function that take a line and return a value.
1const manifest = [ 2 '#EXTM3U', 3 '#EXT-X-VERSION:3', 4 '#VOD-FRAMERATE:29.97', 5 '' 6].join('\n'); 7 8const parser = new m3u8Parser.Parser(); 9parser.addParser({ 10 expression: /^#VOD-FRAMERATE/, 11 customType: 'framerate', 12 dataParser: function(line) { 13 return parseFloat(line.split(':')[1]); 14 } 15}); 16 17parser.push(manifest); 18parser.end(); 19parser.manifest.custom.framerate // 29.97
Custom parsers may also extract data at a segment level by passing segment: true
to the options object. Having a segment level custom parser will add a custom
object to the segment data.
1const manifest = [ 2 '#EXTM3U', 3 '#VOD-TIMING:1511816599485', 4 '#EXTINF:8.0,', 5 'ex1.ts', 6 '' 7 ].join('\n'); 8 9const parser = new m3u8Parser.Parser(); 10parser.addParser({ 11 expression: /#VOD-TIMING/, 12 customType: 'vodTiming', 13 segment: true 14}); 15 16parser.push(manifest); 17parser.end(); 18parser.manifest.segments[0].custom.vodTiming // #VOD-TIMING:1511816599485
Custom parsers may also map a tag to another tag. The old tag will not be replaced and all matching registered mappers and parsers will be executed.
1const manifest = [ 2 '#EXTM3U', 3 '#EXAMPLE', 4 '#EXTINF:8.0,', 5 'ex1.ts', 6 '' 7 ].join('\n'); 8 9const parser = new m3u8Parser.Parser(); 10parser.addTagMapper({ 11 expression: /#EXAMPLE/, 12 map(line) { 13 return `#NEW-TAG:123`; 14 } 15}); 16parser.addParser({ 17 expression: /#NEW-TAG/, 18 customType: 'mappingExample', 19 segment: true 20}); 21 22parser.push(manifest); 23parser.end(); 24parser.manifest.segments[0].custom.mappingExample // #NEW-TAG:123
Including the Parser
To include m3u8-parser on your website or web application, use any of the following methods.
<script>
Tag
This is the simplest case. Get the script in whatever way you prefer and include it on your page.
1<script src="//path/to/m3u8-parser.min.js"></script> 2<script> 3 var parser = new m3u8Parser.Parser(); 4</script>
Browserify
When using with Browserify, install m3u8-parser via npm and require
the parser as you would any other module.
1var m3u8Parser = require('m3u8-parser'); 2 3var parser = new m3u8Parser.Parser();
With ES6:
1import { Parser } from 'm3u8-parser'; 2 3const parser = new Parser();
RequireJS/AMD
When using with RequireJS (or another AMD library), get the script in whatever way you prefer and require
the parser as you normally would:
1require(['m3u8-parser'], function(m3u8Parser) { 2 var parser = new m3u8Parser.Parser(); 3});
License
Apache-2.0. Copyright (c) Brightcove, Inc
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Warn: project license file does not contain an FSF or OSI license.
Reason
Found 17/23 approved changesets -- score normalized to 7
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/videojs/m3u8-parser/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/videojs/m3u8-parser/ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:62: update your workflow using https://app.stepsecurity.io/secureworkflow/videojs/m3u8-parser/ci.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:75: update your workflow using https://app.stepsecurity.io/secureworkflow/videojs/m3u8-parser/ci.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/videojs/m3u8-parser/ci.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:73
- Info: 0 out of 3 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
Project has not signed or included provenance with any releases.
Details
- Warn: release artifact v4.3.0 not signed: https://api.github.com/repos/videojs/m3u8-parser/releases/14909974
- Warn: release artifact v4.0.0 not signed: https://api.github.com/repos/videojs/m3u8-parser/releases/8609069
- Warn: release artifact v2.1.0 not signed: https://api.github.com/repos/videojs/m3u8-parser/releases/5553311
- Warn: release artifact v2.0.1 not signed: https://api.github.com/repos/videojs/m3u8-parser/releases/5219806
- Warn: release artifact v4.3.0 does not have provenance: https://api.github.com/repos/videojs/m3u8-parser/releases/14909974
- Warn: release artifact v4.0.0 does not have provenance: https://api.github.com/repos/videojs/m3u8-parser/releases/8609069
- Warn: release artifact v2.1.0 does not have provenance: https://api.github.com/repos/videojs/m3u8-parser/releases/5553311
- Warn: release artifact v2.0.1 does not have provenance: https://api.github.com/repos/videojs/m3u8-parser/releases/5219806
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 24 are checked with a SAST tool
Reason
56 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-6chw-6frg-f759
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-ff7x-qrg7-qggm
- Warn: Project is vulnerable to: GHSA-j4f2-536g-r55m
- Warn: Project is vulnerable to: GHSA-r7qp-cfhv-p84w
- Warn: Project is vulnerable to: GHSA-74fj-2j2h-c42q
- Warn: Project is vulnerable to: GHSA-pw2r-vq6v-hr8c
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44
- Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-7x7c-qm48-pq9c
- Warn: Project is vulnerable to: GHSA-rc3x-jf5g-xvc5
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-82v2-mx6x-wq7q
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-44c6-4v22-4mhx
- Warn: Project is vulnerable to: GHSA-4x5v-gmq8-25ch
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6
- Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj
- Warn: Project is vulnerable to: GHSA-25hc-qcg6-38wj
- Warn: Project is vulnerable to: GHSA-qm95-pgcg-qqfq
- Warn: Project is vulnerable to: GHSA-cqmj-92xf-r6r9
- Warn: Project is vulnerable to: GHSA-w5p7-h5w8-2hfq
- Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v
- Warn: Project is vulnerable to: GHSA-38fc-wpqx-33j7
- Warn: Project is vulnerable to: GHSA-394c-5j6w-4xmx
- Warn: Project is vulnerable to: GHSA-78cj-fxph-m83p
- Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3
- Warn: Project is vulnerable to: GHSA-cf4h-3jhx-xvhq
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-72mh-269x-7mh5
- Warn: Project is vulnerable to: GHSA-h4j5-c7cj-74xg
Score
2.9
/10
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More