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"
|
|
|
|
)
|
|
|
|
|
2020-12-12 17:20:31 +01:00
|
|
|
var MediaTypes = map[FileFormat]MediaType{
|
|
|
|
FormatRaw: MediaRaw,
|
|
|
|
FormatJpeg: MediaImage,
|
|
|
|
FormatPng: MediaImage,
|
|
|
|
FormatGif: MediaImage,
|
|
|
|
FormatTiff: MediaImage,
|
|
|
|
FormatBitmap: MediaImage,
|
|
|
|
FormatHEIF: MediaImage,
|
2021-02-14 19:25:52 +01:00
|
|
|
FormatMpo: MediaImage,
|
2020-12-12 17:20:31 +01:00
|
|
|
FormatAvi: MediaVideo,
|
|
|
|
FormatHEVC: MediaVideo,
|
|
|
|
FormatAvc: MediaVideo,
|
|
|
|
FormatMp4: MediaVideo,
|
|
|
|
FormatMov: MediaVideo,
|
|
|
|
Format3gp: MediaVideo,
|
|
|
|
Format3g2: MediaVideo,
|
|
|
|
FormatFlv: MediaVideo,
|
|
|
|
FormatMkv: MediaVideo,
|
|
|
|
FormatMpg: MediaVideo,
|
2021-02-14 19:25:52 +01:00
|
|
|
FormatMts: MediaVideo,
|
2020-12-12 17:20:31 +01:00
|
|
|
FormatOgv: MediaVideo,
|
|
|
|
FormatWebm: MediaVideo,
|
|
|
|
FormatWMV: MediaVideo,
|
|
|
|
FormatXMP: MediaSidecar,
|
|
|
|
FormatXML: MediaSidecar,
|
|
|
|
FormatAAE: MediaSidecar,
|
|
|
|
FormatYaml: MediaSidecar,
|
|
|
|
FormatText: MediaSidecar,
|
|
|
|
FormatJson: MediaSidecar,
|
|
|
|
FormatToml: MediaSidecar,
|
|
|
|
FormatMarkdown: MediaSidecar,
|
|
|
|
FormatOther: 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-12-12 17:20:31 +01:00
|
|
|
result, ok := MediaTypes[GetFileFormat(fileName)]
|
2020-04-07 10:42:42 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|