navidrome/utils/files.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
504 B
Go
Raw Normal View History

package utils
import (
"mime"
"path/filepath"
"strings"
)
2020-07-04 03:06:33 +02:00
var excludeAudioType = []string{
"audio/x-mpegurl",
2020-07-04 03:15:01 +02:00
"audio/x-scpls",
2020-07-04 03:06:33 +02:00
}
func IsAudioFile(filePath string) bool {
extension := filepath.Ext(filePath)
2020-07-04 03:06:33 +02:00
mimeType := mime.TypeByExtension(extension)
return !StringInSlice(mimeType, excludeAudioType) && strings.HasPrefix(mimeType, "audio/")
}
func IsImageFile(filePath string) bool {
extension := filepath.Ext(filePath)
return strings.HasPrefix(mime.TypeByExtension(extension), "image/")
}