Adding big list of mime types, and adding support for contenty-type in

getMusicDirectory.view
This commit is contained in:
Deluan 2016-03-03 13:43:57 -05:00
parent cd0fa5739b
commit 053f4b72ba
2 changed files with 46 additions and 0 deletions

View File

@ -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
}

44
conf/mime_types.go Normal file
View File

@ -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)
}
}