mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-13 01:20:26 -07:00
feat: add now playing endpoint and ui (#93)
* wip * feat: add now playing
This commit is contained in:
parent
0b7ecb0b96
commit
a4689bed27
8 changed files with 265 additions and 9 deletions
|
|
@ -8,12 +8,14 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gabehf/koito/internal/db"
|
||||
"github.com/gabehf/koito/internal/logger"
|
||||
"github.com/gabehf/koito/internal/mbz"
|
||||
"github.com/gabehf/koito/internal/memkv"
|
||||
"github.com/gabehf/koito/internal/models"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
|
@ -56,8 +58,9 @@ type SubmitListenOpts struct {
|
|||
ReleaseGroupMbzID uuid.UUID
|
||||
Time time.Time
|
||||
|
||||
UserID int32
|
||||
Client string
|
||||
UserID int32
|
||||
Client string
|
||||
IsNowPlaying bool
|
||||
}
|
||||
|
||||
const (
|
||||
|
|
@ -165,6 +168,14 @@ func SubmitListen(ctx context.Context, store db.DB, opts SubmitListenOpts) error
|
|||
}
|
||||
}
|
||||
|
||||
if opts.IsNowPlaying {
|
||||
if track.Duration == 0 {
|
||||
memkv.Store.Set(strconv.Itoa(int(opts.UserID)), track.ID)
|
||||
} else {
|
||||
memkv.Store.Set(strconv.Itoa(int(opts.UserID)), track.ID, time.Duration(track.Duration)*time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
if opts.SkipSaveListen {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue