fix: issues
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user