init commit
This commit is contained in:
39
internal/srt/types.go
Normal file
39
internal/srt/types.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package srt
|
||||
|
||||
import "time"
|
||||
|
||||
// Cue represents a single subtitle entry
|
||||
type Cue struct {
|
||||
Index int
|
||||
Start time.Duration
|
||||
End time.Duration
|
||||
Text string
|
||||
LineNumber int // Line number in the SRT file (1-indexed)
|
||||
}
|
||||
|
||||
// Transcript represents a complete subtitle file
|
||||
type Transcript struct {
|
||||
Cues []Cue
|
||||
FilePath string
|
||||
IsTemp bool
|
||||
}
|
||||
|
||||
// CueAt returns the cue that contains the given time position
|
||||
func (t *Transcript) CueAt(pos time.Duration) *Cue {
|
||||
for i := range t.Cues {
|
||||
if pos >= t.Cues[i].Start && pos < t.Cues[i].End {
|
||||
return &t.Cues[i]
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// CueIndexAt returns the index of the cue at the given position, or -1
|
||||
func (t *Transcript) CueIndexAt(pos time.Duration) int {
|
||||
for i := range t.Cues {
|
||||
if pos >= t.Cues[i].Start && pos < t.Cues[i].End {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
Reference in New Issue
Block a user