asticode / go-astisub

Manipulate subtitles in GO (.srt, .ssa/.ass, .stl, .ttml, .vtt (webvtt), teletext, etc.)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any methods to suppress these annoying log.Printf

caryyu opened this issue · comments

As there are some invalid formats that will be parsed and can't be read properly, I'd like to know if it is possible to avoid this annoying output from the code below:

go-astisub/ssa.go

Lines 178 to 199 in aa9412f

log.Printf("astisub: unknown section: %s", line)
sectionName = ssaSectionNameUnknown
continue
}
}
// Unknown section
if sectionName == ssaSectionNameUnknown {
continue
}
// Comment
if len(line) > 0 && line[0] == ';' {
si.comments = append(si.comments, strings.TrimSpace(line[1:]))
continue
}
// Split on ":"
var split = strings.Split(line, ":")
if len(split) < 2 || split[0] == "" {
log.Printf("astisub: not understood: '%s', ignoring", line)
continue

Plus: If there's a method that I can verify whether or not the format is correct before that, will make it even better

Right now this is not possible to do so.

But I'm welcoming PRs to make the proper changes:

  • add an SSAOptions struct with OnUnknownSectionName func(name string) and OnInvalidLine func(line string) fields
  • add this struct to the ReadFromSSA func
  • by default make the callback log information