mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-17 20:42:25 +03:00
35 lines
798 B
Go
35 lines
798 B
Go
package api
|
|
|
|
import (
|
|
"github.com/astaxie/beego"
|
|
"github.com/deluan/gosonic/api/responses"
|
|
"github.com/deluan/gosonic/engine"
|
|
"github.com/deluan/gosonic/utils"
|
|
"github.com/karlkfi/inject"
|
|
)
|
|
|
|
type GetCoverArtController struct {
|
|
BaseAPIController
|
|
cover engine.Cover
|
|
}
|
|
|
|
func (c *GetCoverArtController) Prepare() {
|
|
inject.ExtractAssignable(utils.Graph, &c.cover)
|
|
}
|
|
|
|
// TODO accept size parameter
|
|
func (c *GetCoverArtController) Get() {
|
|
id := c.RequiredParamString("id", "id parameter required")
|
|
|
|
err := c.cover.GetCover(id, 0, c.Ctx.ResponseWriter)
|
|
|
|
switch {
|
|
case err == engine.DataNotFound:
|
|
beego.Error(err, "Id:", id)
|
|
c.SendError(responses.ERROR_DATA_NOT_FOUND, "Directory not found")
|
|
case err != nil:
|
|
beego.Error(err)
|
|
c.SendError(responses.ERROR_GENERIC, "Internal Error")
|
|
}
|
|
}
|