diff --git a/api/get_music_directory.go b/api/get_music_directory.go index 9643d068b..3062dbc9a 100644 --- a/api/get_music_directory.go +++ b/api/get_music_directory.go @@ -6,6 +6,7 @@ import ( "github.com/deluan/gosonic/domain" "github.com/deluan/gosonic/utils" "github.com/karlkfi/inject" + "mime" ) type GetMusicDirectoryController struct { @@ -82,6 +83,7 @@ func (c *GetMusicDirectoryController) buildAlbumDir(al *domain.Album, tracks []d if mf.HasCoverArt { dir.Child[i].CoverArt = mf.Id } + dir.Child[i].ContentType = mime.TypeByExtension("." + mf.Suffix) } return dir } diff --git a/conf/mime_types.go b/conf/mime_types.go new file mode 100644 index 000000000..e0bac8e40 --- /dev/null +++ b/conf/mime_types.go @@ -0,0 +1,44 @@ +package conf + +import "mime" + +func init() { + mt := map[string]string{ + ".mp3": "audio/mpeg", + ".ogg": "audio/ogg", + ".oga": "audio/ogg", + ".opus": "audio/ogg", + ".ogx": "application/ogg", + ".aac": "audio/mp4", + ".m4a": "audio/mp4", + ".flac": "audio/flac", + ".wav": "audio/x-wav", + ".wma": "audio/x-ms-wma", + ".ape": "audio/x-monkeys-audio", + ".mpc": "audio/x-musepack", + ".shn": "audio/x-shn", + ".flv": "video/x-flv", + ".avi": "video/avi", + ".mpg": "video/mpeg", + ".mpeg": "video/mpeg", + ".mp4": "video/mp4", + ".m4v": "video/x-m4v", + ".mkv": "video/x-matroska", + ".mov": "video/quicktime", + ".wmv": "video/x-ms-wmv", + ".ogv": "video/ogg", + ".divx": "video/divx", + ".m2ts": "video/MP2T", + ".ts": "video/MP2T", + ".webm": "video/webm", + ".gif": "image/gif", + ".jpg": "image/jpeg", + ".jpeg": "image/jpeg", + ".png": "image/png", + ".bmp": "image/bmp", + } + + for ext, typ := range mt { + mime.AddExtensionType(ext, typ) + } +}