2020-04-07 10:42:42 +02:00
|
|
|
package fs
|
|
|
|
|
|
|
|
type MediaType string
|
|
|
|
|
|
|
|
const (
|
|
|
|
MediaImage MediaType = "image"
|
|
|
|
MediaSidecar MediaType = "sidecar"
|
2020-12-05 02:18:45 +01:00
|
|
|
MediaRaw MediaType = "raw"
|
|
|
|
MediaVideo MediaType = "video"
|
2020-04-07 10:42:42 +02:00
|
|
|
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,
|
2020-12-05 04:24:10 +01:00
|
|
|
TypeHEVC: MediaVideo,
|
|
|
|
TypeMp4: MediaVideo,
|
2020-04-07 22:03:31 +02:00
|
|
|
TypeMov: MediaVideo,
|
2020-12-05 04:24:10 +01:00
|
|
|
Type3gp: MediaVideo,
|
|
|
|
Type3g2: MediaVideo,
|
|
|
|
TypeFlv: MediaVideo,
|
|
|
|
TypeMkv: MediaVideo,
|
|
|
|
TypeMpg: MediaVideo,
|
|
|
|
TypeOgv: MediaVideo,
|
|
|
|
TypeWebm: MediaVideo,
|
|
|
|
TypeWMV: MediaVideo,
|
2020-04-07 22:03:31 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|