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

MalformedCaptionError #33

Open
BeAtS85 opened this issue Sep 20, 2020 · 1 comment
Open

MalformedCaptionError #33

BeAtS85 opened this issue Sep 20, 2020 · 1 comment

Comments

@BeAtS85
Copy link

BeAtS85 commented Sep 20, 2020

Sometimes there are empty timestamps in the .vtt. The script errors out on them.

For example:
00:22:21.320 --> 00:22:26.520
00:21:13.720 --> 00:21:15.360 line:90% position:50% align:middle

Can this error somehow be captured or ignore the empty timestamps?

@chapmanjacobd
Copy link

chapmanjacobd commented Aug 28, 2022

yeah it would be nice if the file was parsed a line at a time so people could do something like this:

try:
    out = []
    for caption in webvtt.read_generator(path):
        try:
            line = caption.text   # or even .text() would be fine
        except webvtt.MalformedCaptionError:
            pass
        else:
            out.append(remove_text_inside_brackets(line.replace("\n", " ")))

    return out
except webvtt.MalformedFileError:
    return []

tmpsqszy7z2.vtt.txt

~80% of my VTT files are malformed according to this library so as-is not super useful for my use case.... :/

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

No branches or pull requests

2 participants