feat: add transcodedSuffix to Subsonic API responses

This commit is contained in:
Deluan
2020-03-16 12:56:15 -04:00
committed by Deluan Quintão
parent 45180115a6
commit 39993810b3
12 changed files with 136 additions and 61 deletions
+10 -3
View File
@@ -12,7 +12,7 @@ import (
type Players interface {
Get(ctx context.Context, playerId string) (*model.Player, error)
Register(ctx context.Context, id, client, typ, ip string) (*model.Player, error)
Register(ctx context.Context, id, client, typ, ip string) (*model.Player, *model.Transcoding, error)
}
func NewPlayers(ds model.DataStore) Players {
@@ -23,8 +23,9 @@ type players struct {
ds model.DataStore
}
func (p *players) Register(ctx context.Context, id, client, typ, ip string) (*model.Player, error) {
func (p *players) Register(ctx context.Context, id, client, typ, ip string) (*model.Player, *model.Transcoding, error) {
var plr *model.Player
var trc *model.Transcoding
var err error
userName := ctx.Value("username").(string)
if id != "" {
@@ -49,7 +50,13 @@ func (p *players) Register(ctx context.Context, id, client, typ, ip string) (*mo
plr.Type = typ
plr.IPAddress = ip
err = p.ds.Player(ctx).Put(plr)
return plr, err
if err != nil {
return nil, nil, err
}
if plr.TranscodingId != "" {
trc, err = p.ds.Transcoding(ctx).Get(plr.TranscodingId)
}
return plr, trc, err
}
func (p *players) Get(ctx context.Context, playerId string) (*model.Player, error) {