fix: issues

This commit is contained in:
yanghao05
2025-03-29 18:18:06 +08:00
parent a9d2c22541
commit 0d5f2e7de0

View File

@@ -193,18 +193,19 @@ func calculateMD5(filePath string) (string, error) {
// doCompress compresses the video file
func doCompress(srcPath, dstPath string) error {
// get file ext
ext := filepath.Ext(srcPath)
ext := strings.ToLower(filepath.Ext(srcPath))
if ext == "" {
return errors.New("file has no extension")
}
// check if the file is a .mp3
if ext == ".mp3" {
if strings.EqualFold(ext, ".mp3") {
return compressAudio(srcPath, dstPath)
}
// check if the file is a video
if ext != ".mp4" && ext != ".avi" && ext != ".mkv" {
videoExts := []string{".mp4", ".avi", ".mkv"}
if !lo.Contains(videoExts, ext) {
return errors.New("file is not a video")
}