2020-04-07 10:42:42 +02:00
|
|
|
package fs
|
|
|
|
|
|
|
|
type MediaType string
|
|
|
|
|
|
|
|
const (
|
|
|
|
MediaRaw MediaType = "raw"
|
|
|
|
MediaImage MediaType = "image"
|
|
|
|
MediaVideo MediaType = "video"
|
|
|
|
MediaSidecar MediaType = "sidecar"
|
|
|
|
MediaOther MediaType = "other"
|
|
|
|
)
|
|
|
|
|
|
|
|
var MediaTypes = map[FileType]MediaType{
|
2020-04-07 22:03:31 +02:00
|
|
|
TypeRaw: MediaRaw,
|
|
|
|
TypeJpeg: MediaImage,
|
|
|
|
TypePng: MediaImage,
|
|
|
|
TypeGif: MediaImage,
|
|
|
|
TypeTiff: MediaImage,
|
|
|
|
TypeBitmap: MediaImage,
|
|
|
|
TypeHEIF: MediaImage,
|
|
|
|
TypeAvi: MediaVideo,
|
|
|
|
TypeMP4: MediaVideo,
|
|
|
|
TypeMov: MediaVideo,
|
|
|
|
TypeXMP: MediaSidecar,
|
|
|
|
TypeXML: MediaSidecar,
|
|
|
|
TypeAAE: MediaSidecar,
|
|
|
|
TypeYaml: MediaSidecar,
|
|
|
|
TypeText: MediaSidecar,
|
|
|
|
TypeJson: MediaSidecar,
|
|
|
|
TypeToml: MediaSidecar,
|
2020-04-07 10:42:42 +02:00
|
|
|
TypeMarkdown: MediaSidecar,
|
2020-04-07 22:03:31 +02:00
|
|
|
TypeOther: MediaOther,
|
2020-04-07 10:42:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func GetMediaType(fileName string) MediaType {
|
2020-07-19 14:45:49 +02:00
|
|
|
if fileName == "" {
|
|
|
|
return MediaOther
|
|
|
|
}
|
|
|
|
|
2020-04-07 10:42:42 +02:00
|
|
|
result, ok := MediaTypes[GetFileType(fileName)]
|
|
|
|
|
|
|
|
if !ok {
|
|
|
|
result = MediaOther
|
|
|
|
}
|
|
|
|
|
|
|
|
return result
|
|
|
|
}
|
2020-07-19 14:45:49 +02:00
|
|
|
|
|
|
|
func IsMedia(fileName string) bool {
|
|
|
|
switch GetMediaType(fileName) {
|
|
|
|
case MediaRaw, MediaImage, MediaVideo:
|
|
|
|
return true
|
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|