feat: vtt converting
This commit is contained in:
parent
ba2e477dc0
commit
ba66894e42
7 changed files with 693 additions and 107 deletions
|
@ -22,3 +22,63 @@ type SRTEntry struct {
|
|||
EndTime Timestamp
|
||||
Content string
|
||||
}
|
||||
|
||||
// SubtitleEntry represents a generic subtitle entry in our intermediate representation
|
||||
type SubtitleEntry struct {
|
||||
Index int // Sequential index/number
|
||||
StartTime Timestamp // Start time
|
||||
EndTime Timestamp // End time
|
||||
Text string // The subtitle text content
|
||||
Styles map[string]string // Styling information (e.g., VTT's align, position)
|
||||
Classes []string // CSS classes (for VTT)
|
||||
Metadata map[string]string // Additional metadata
|
||||
FormatData map[string]interface{} // Format-specific data that doesn't fit elsewhere
|
||||
}
|
||||
|
||||
// Subtitle represents our intermediate subtitle representation used for conversions
|
||||
type Subtitle struct {
|
||||
Title string // Optional title
|
||||
Metadata map[string]string // Global metadata (e.g., LRC's ti, ar, al)
|
||||
Entries []SubtitleEntry // Subtitle entries
|
||||
Format string // Source format
|
||||
Styles map[string]string // Global styles (e.g., VTT STYLE blocks)
|
||||
Comments []string // Comments/notes (for VTT)
|
||||
Regions []SubtitleRegion // Region definitions (for VTT)
|
||||
FormatData map[string]interface{} // Format-specific data that doesn't fit elsewhere
|
||||
}
|
||||
|
||||
// SubtitleRegion represents a region definition (mainly for VTT)
|
||||
type SubtitleRegion struct {
|
||||
ID string
|
||||
Settings map[string]string
|
||||
}
|
||||
|
||||
// Creates a new empty Subtitle
|
||||
func NewSubtitle() Subtitle {
|
||||
return Subtitle{
|
||||
Metadata: make(map[string]string),
|
||||
Entries: []SubtitleEntry{},
|
||||
Styles: make(map[string]string),
|
||||
Comments: []string{},
|
||||
Regions: []SubtitleRegion{},
|
||||
FormatData: make(map[string]interface{}),
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a new empty SubtitleEntry
|
||||
func NewSubtitleEntry() SubtitleEntry {
|
||||
return SubtitleEntry{
|
||||
Styles: make(map[string]string),
|
||||
Classes: []string{},
|
||||
Metadata: make(map[string]string),
|
||||
FormatData: make(map[string]interface{}),
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a new SubtitleRegion
|
||||
func NewSubtitleRegion(id string) SubtitleRegion {
|
||||
return SubtitleRegion{
|
||||
ID: id,
|
||||
Settings: make(map[string]string),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue