Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: custom tag mapping #73

Merged
merged 5 commits into from Jan 10, 2019
Merged

feat: custom tag mapping #73

merged 5 commits into from Jan 10, 2019

Conversation

forbesjo
Copy link
Contributor

@forbesjo forbesjo commented Jan 2, 2019

No description provided.

test/m3u8.test.js Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/parse-stream.js Outdated Show resolved Hide resolved
src/parse-stream.js Outdated Show resolved Hide resolved
src/parse-stream.js Show resolved Hide resolved

this.lineStream.push(manifest);
assert.ok(element, 'element');
assert.strictEqual(calls, 2);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be 1 since the regex test in mapFn should fail for the intermediate tag mapper?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mapping goes #VOD-STARTTIMESTAMP -> #INTERMEDIATE -> #EXT-X-PROGRAM-DATE-TIME on the same line. Each line being parsed will be processed by all registered mappers.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 not sure we should allow this sort of chained tag mapping since tag mappers could be added by different users. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can have it explicitly break on the first matching mapper however I think it's a valid use case if say the BC player adds some mappers and a BC user would like to transform that data further

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, that's a good point. Maybe a warning would work?

test/m3u8.test.js Outdated Show resolved Hide resolved
if (this.customParsers[i].call(this, line)) {
return;
// map tags
const newLines = this.tagMappers.reduce((acc, mapper) =>
Copy link

@ldayananda ldayananda Jan 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only issue I see with this PR is that for lines that neither match the customParsers nor tagMappers, lines are unnecessarily duplicated. This results in as many data events(+1) as there are tagMappers for the same line.

We might only want to concat the result of mapper(line) if it is different from the original line

});

this.lineStream.push(manifest);
assert.strictEqual(element.type, 'comment', 'the type is comment');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you assert the number of data events here there are 2 instead of 1 (which I would expect if the line didn't need to be duplicated)

@forbesjo forbesjo merged commit 0ef040a into master Jan 10, 2019
@forbesjo forbesjo deleted the custom-fn branch January 10, 2019 17:02
miadabdi pushed a commit to miadabdi/m3u8-parser that referenced this pull request Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants