Skip to content

[Feature Suggestion] Ignore extra header lines #18

Closed
@abstractvector

Description

@abstractvector

I'm using this module to ingest data from Google's YouTube Captions API. Unfortunately, the content it generates has extra lines after the opening WEBVTT line, for example:

WEBVTT
Kind: captions
Language: en

00:00:00.000 --> 00:00:00.960
[Happy music]

According to MDN, this is not allowed, however nonetheless it appears there. At the moment I'm solving this with a workaround to alter the string before passing it to parse():

const adjustedCaption = caption.replace(/^WEBVTT[\s\S]*?\n\n/, "WEBVTT\n\n");

Without this workaround, I receive an error: Missing blank line after signature. It would be preferable if this module could instead accept an option to ignore trailing signature lines. Looking at the code, this wouldn't have adverse effects on the parsing. Alternatively, these lines could be parsed and added as metadata to the parsed output.

I'd be happy to issue a PR for this if you're comfortable with the approach, or if you have a better suggestion I can look at implementing that too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions