Initial support for song browsing from UI

This commit is contained in:
Deluan
2020-01-22 10:19:13 -05:00
parent fdf1ceeade
commit 9557f7ceed
17 changed files with 158 additions and 28 deletions
+3
View File
@@ -53,6 +53,9 @@ func (app *Router) routes() http.Handler {
R(r, "/user", func(ctx context.Context) rest.Repository {
return app.ds.Resource(model.User{})
})
R(r, "/song", func(ctx context.Context) rest.Repository {
return app.ds.Resource(model.MediaFile{})
})
})
return r
}
+1 -1
View File
@@ -181,7 +181,7 @@ func ToChild(entry engine.Entry) responses.Child {
child.CoverArt = entry.CoverArt
child.Track = entry.Track
child.Duration = entry.Duration
child.Size = entry.Size
child.Size = strconv.Itoa(entry.Size)
child.Suffix = entry.Suffix
child.BitRate = entry.BitRate
child.ContentType = entry.ContentType
+2 -1
View File
@@ -2,6 +2,7 @@ package subsonic
import (
"net/http"
"strconv"
"github.com/cloudsonic/sonic-server/engine"
"github.com/cloudsonic/sonic-server/log"
@@ -54,7 +55,7 @@ func (c *StreamController) Stream(w http.ResponseWriter, r *http.Request) (*resp
// contentLength = strconv.Itoa((mf.Duration + 1) * maxBitRate * 1000 / 8)
//}
h := w.Header()
h.Set("Content-Length", mf.Size)
h.Set("Content-Length", strconv.Itoa(mf.Size))
h.Set("Content-Type", "audio/mpeg")
h.Set("Expires", "0")
h.Set("Cache-Control", "must-revalidate")