26 lines
904 B
Go
26 lines
904 B
Go
package sync
|
|
|
|
import (
|
|
"fmt"
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
// SyncLyrics synchronizes the timeline of a source lyrics file with a target lyrics file
|
|
func SyncLyrics(sourceFile, targetFile string) error {
|
|
sourceFmt := strings.TrimPrefix(filepath.Ext(sourceFile), ".")
|
|
targetFmt := strings.TrimPrefix(filepath.Ext(targetFile), ".")
|
|
|
|
// Check for supported format combinations
|
|
if sourceFmt == "lrc" && targetFmt == "lrc" {
|
|
return syncLRCFiles(sourceFile, targetFile)
|
|
} else if sourceFmt == "srt" && targetFmt == "srt" {
|
|
return syncSRTFiles(sourceFile, targetFile)
|
|
} else if sourceFmt == "vtt" && targetFmt == "vtt" {
|
|
return syncVTTFiles(sourceFile, targetFile)
|
|
} else if sourceFmt == "ass" && targetFmt == "ass" {
|
|
return syncASSFiles(sourceFile, targetFile)
|
|
} else {
|
|
return fmt.Errorf("sync only supports files of the same format (lrc-to-lrc, srt-to-srt, vtt-to-vtt, or ass-to-ass)")
|
|
}
|
|
}
|