mirror of
https://github.com/navidrome/navidrome.git
synced 2024-09-11 20:12:54 +02:00
29 lines
653 B
Go
29 lines
653 B
Go
package utils
|
|
|
|
import (
|
|
"mime"
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
var excludeAudioType = []string{
|
|
"audio/x-mpegurl",
|
|
"audio/x-scpls",
|
|
}
|
|
|
|
func IsAudioFile(filePath string) bool {
|
|
extension := filepath.Ext(filePath)
|
|
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/")
|
|
}
|
|
|
|
func IsPlaylist(filePath string) bool {
|
|
extension := strings.ToLower(filepath.Ext(filePath))
|
|
return extension == ".m3u" || extension == ".m3u8"
|
|
}
|