feat: srt sync and formatting

This commit is contained in:
CDN 2025-04-23 10:27:59 +08:00
parent 6bb9f06c52
commit ba2e477dc0
Signed by: CDN
GPG key ID: 0C656827F9F80080
4 changed files with 181 additions and 12 deletions

View file

@ -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{