feat: srt sync and formatting
This commit is contained in:
parent
6bb9f06c52
commit
ba2e477dc0
4 changed files with 181 additions and 12 deletions
|
@ -122,6 +122,23 @@ func formatSRTTimestamp(ts model.Timestamp) string {
|
|||
ts.Milliseconds)
|
||||
}
|
||||
|
||||
// Format standardizes and formats an SRT file
|
||||
func Format(filePath string) error {
|
||||
// Parse the file
|
||||
entries, err := Parse(filePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error parsing SRT file: %w", err)
|
||||
}
|
||||
|
||||
// Standardize entry numbering and ensure consistent formatting
|
||||
for i := range entries {
|
||||
entries[i].Number = i + 1 // Ensure sequential numbering
|
||||
}
|
||||
|
||||
// Write back the formatted content
|
||||
return Generate(entries, filePath)
|
||||
}
|
||||
|
||||
// ConvertToLyrics converts SRT entries to a Lyrics structure
|
||||
func ConvertToLyrics(entries []model.SRTEntry) model.Lyrics {
|
||||
lyrics := model.Lyrics{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue