mirror of
https://github.com/zoriya/go-astisub.git
synced 2026-08-16 02:33:21 +00:00
Not returning error on .srt positions
This commit is contained in:
@@ -75,14 +75,22 @@ func ReadFromSRT(i io.Reader) (o *Subtitles, err error) {
|
||||
// Fetch Index
|
||||
s.Index, _ = strconv.Atoi(index.String())
|
||||
|
||||
// Fetch time boundaries
|
||||
boundaries := strings.Split(line, srtTimeBoundariesSeparator)
|
||||
if s.StartAt, err = parseDurationSRT(boundaries[0]); err != nil {
|
||||
err = fmt.Errorf("astisub: line %d: parsing srt duration %s failed: %w", lineNum, boundaries[0], err)
|
||||
// Extract time boundaries
|
||||
s1 := strings.Split(line, srtTimeBoundariesSeparator)
|
||||
if l := len(s1); l < 2 {
|
||||
err = fmt.Errorf("astisub: line %d: time boundaries has only %d element(s)", lineNum, l)
|
||||
return
|
||||
}
|
||||
if s.EndAt, err = parseDurationSRT(boundaries[1]); err != nil {
|
||||
err = fmt.Errorf("astisub: line %d: parsing srt duration %s failed: %w", lineNum, boundaries[1], err)
|
||||
// We do this to eliminate extra stuff like positions which are not documented anywhere
|
||||
s2 := strings.Split(s1[1], " ")
|
||||
|
||||
// Parse time boundaries
|
||||
if s.StartAt, err = parseDurationSRT(s1[0]); err != nil {
|
||||
err = fmt.Errorf("astisub: line %d: parsing srt duration %s failed: %w", lineNum, s1[0], err)
|
||||
return
|
||||
}
|
||||
if s.EndAt, err = parseDurationSRT(s2[0]); err != nil {
|
||||
err = fmt.Errorf("astisub: line %d: parsing srt duration %s failed: %w", lineNum, s2[0], err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
(deep rumbling)
|
||||
|
||||
2
|
||||
00:02:04,08 --> 00:02:07,12
|
||||
00:02:04,08 --> 00:02:07,12 X1:40 X2:600 Y1:20 Y2:50
|
||||
MAN:
|
||||
How did we end up here?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user