feat: add now playing endpoint and ui (#93)

* wip

* feat: add now playing
This commit is contained in:
Gabe Farrell 2025-11-19 00:58:24 -05:00 committed by GitHub
parent 0b7ecb0b96
commit a4689bed27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 265 additions and 9 deletions

View file

@ -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
}