Skip to content

Commit

Permalink
feat: custom tag mapping (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
forbesjo authored Jan 10, 2019
1 parent afc7bb9 commit 0ef040a
Show file tree
Hide file tree
Showing 4 changed files with 506 additions and 291 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,35 @@ parser.push(manifest);
parser.end();
parser.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.
```js
const manifest = [
'#EXTM3U',
'#EXAMPLE',
'#EXTINF:8.0,',
'ex1.ts',
''
].join('\n');

const parser = new m3u8Parser.Parser();
parser.addTagMapper({
expression: /#EXAMPLE/,
map(line) {
return `#NEW-TAG:123`;
}
});
parser.addParser({
expression: /#NEW-TAG/,
customType: 'mappingExample',
segment: true
});

parser.push(manifest);
parser.end();
parser.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.
Expand Down
Loading

0 comments on commit 0ef040a

Please sign in to comment.