mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-05 21:47:36 +03:00
28 lines
572 B
Go
28 lines
572 B
Go
package persistence
|
|
|
|
import (
|
|
"errors"
|
|
"time"
|
|
|
|
"github.com/deluan/gosonic/engine"
|
|
)
|
|
|
|
type nowPlayingRepository struct {
|
|
ledisRepository
|
|
}
|
|
|
|
func NewNowPlayingRepository() engine.NowPlayingRepository {
|
|
r := &nowPlayingRepository{}
|
|
r.init("nnowplaying", &engine.NowPlayingInfo{})
|
|
return r
|
|
}
|
|
|
|
func (r *nowPlayingRepository) Add(id string) error {
|
|
if id == "" {
|
|
return errors.New("Id is required")
|
|
}
|
|
m := &engine.NowPlayingInfo{TrackId: id, Start: time.Now()}
|
|
return r.saveOrUpdate(m.TrackId, m)
|
|
}
|
|
|
|
var _ engine.NowPlayingRepository = (*nowPlayingRepository)(nil)
|