Open nakkamarra opened 1 month ago
From what I understand, there are 2 problems you're trying to fix:
1) handle \r
2) handle optional data after WEBVTT
keyword
Regarding 1), implementing a custom bufio.SplitFunc
capable of parsing \n\r
seems like a good idea
Regarding 2), I would update this logic, trimming BOMBytes prefix, checking the header is there, scanning until 2 empty lines have been found and storing its value in a Subtitles.Comments
attribute
From an excerpt of the WebVTT spec regarding the WebVTT parsing algorithm:
I don't believe the current astisub WebVTT parsing logic is covering this part of the WebVTT parsing algorithm correctly. The
bufio.Scanner
is using the default which is ScanLines and I'm not sure this is handling the WebVTT parsing correctly (i.e a file with exclusively\r
terminations will not be replaced and thus not parsed properly). So I'm thinking maybe implementing a newbufio.SplitFunc
and feeding it to thescanner.Split(...)
This somewhat ties into another issue I am currently trying to make a PR to solve #110, where I'd like to:
WEBVTT
Thoughts? Maybe there's a better way for me to achieve what I'm trying to do.