This commit is contained in:
Deluan 2016-03-03 13:17:52 -05:00
parent f3ba23ef41
commit cd0fa5739b
2 changed files with 9 additions and 11 deletions

View File

@ -1,13 +1,13 @@
package api package api
import ( import (
"github.com/deluan/gosonic/domain"
"github.com/karlkfi/inject"
"github.com/deluan/gosonic/utils"
"github.com/astaxie/beego" "github.com/astaxie/beego"
"github.com/deluan/gosonic/api/responses" "github.com/deluan/gosonic/api/responses"
"github.com/deluan/gosonic/domain"
"github.com/deluan/gosonic/utils"
"github.com/dhowden/tag"
"github.com/karlkfi/inject"
"io/ioutil" "io/ioutil"
"github.com/dhowden/tag"
"os" "os"
) )
@ -34,7 +34,7 @@ func (c *GetCoverArtController) Get() {
var img []byte var img []byte
if (mf.HasCoverArt) { if mf.HasCoverArt {
img, err = readFromTag(mf.Path) img, err = readFromTag(mf.Path)
beego.Debug("Serving cover art from", mf.Path) beego.Debug("Serving cover art from", mf.Path)
} else { } else {
@ -47,7 +47,6 @@ func (c *GetCoverArtController) Get() {
c.SendError(responses.ERROR_DATA_NOT_FOUND, "cover art not available") c.SendError(responses.ERROR_DATA_NOT_FOUND, "cover art not available")
} }
c.Ctx.Output.ContentType("image/jpg") c.Ctx.Output.ContentType("image/jpg")
c.Ctx.Output.Body(img) c.Ctx.Output.Body(img)
} }
@ -68,4 +67,3 @@ func readFromTag(path string) ([]byte, error) {
return m.Picture().Data, nil return m.Picture().Data, nil
} }

View File

@ -45,7 +45,7 @@ func (c *GetMusicDirectoryController) Get() {
c.SendResponse(response) c.SendResponse(response)
} }
func (c *GetMusicDirectoryController) buildArtistDir(a *domain.Artist, albums []domain.Album) (*responses.Directory) { func (c *GetMusicDirectoryController) buildArtistDir(a *domain.Artist, albums []domain.Album) *responses.Directory {
dir := &responses.Directory{Id: a.Id, Name: a.Name} dir := &responses.Directory{Id: a.Id, Name: a.Name}
dir.Child = make([]responses.Child, len(albums)) dir.Child = make([]responses.Child, len(albums))
@ -62,7 +62,7 @@ func (c *GetMusicDirectoryController) buildArtistDir(a *domain.Artist, albums []
return dir return dir
} }
func (c *GetMusicDirectoryController) buildAlbumDir(al *domain.Album, tracks []domain.MediaFile) (*responses.Directory) { func (c *GetMusicDirectoryController) buildAlbumDir(al *domain.Album, tracks []domain.MediaFile) *responses.Directory {
dir := &responses.Directory{Id: al.Id, Name: al.Name} dir := &responses.Directory{Id: al.Id, Name: al.Name}
dir.Child = make([]responses.Child, len(tracks)) dir.Child = make([]responses.Child, len(tracks))
@ -87,7 +87,7 @@ func (c *GetMusicDirectoryController) buildAlbumDir(al *domain.Album, tracks []d
} }
func (c *GetMusicDirectoryController) isArtist(id string) bool { func (c *GetMusicDirectoryController) isArtist(id string) bool {
found, err := c.artistRepo.Exists(id); found, err := c.artistRepo.Exists(id)
if err != nil { if err != nil {
beego.Error("Error searching for Artist:", err) beego.Error("Error searching for Artist:", err)
c.SendError(responses.ERROR_GENERIC, "Internal Error") c.SendError(responses.ERROR_GENERIC, "Internal Error")
@ -105,7 +105,7 @@ func (c *GetMusicDirectoryController) isAlbum(id string) bool {
} }
func (c *GetMusicDirectoryController) retrieveArtist(id string) (a *domain.Artist, as []domain.Album) { func (c *GetMusicDirectoryController) retrieveArtist(id string) (a *domain.Artist, as []domain.Album) {
a, err := c.artistRepo.Get(id); a, err := c.artistRepo.Get(id)
if err != nil { if err != nil {
beego.Error("Error reading Artist from DB", err) beego.Error("Error reading Artist from DB", err)
c.SendError(responses.ERROR_GENERIC, "Internal Error") c.SendError(responses.ERROR_GENERIC, "Internal Error")