Documentation
¶
Overview ¶
Package scrobbling coordinates playback events with configured scrobble services.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Coordinator ¶
type Coordinator struct {
// contains filtered or unexported fields
}
Coordinator tracks playback progress and submits scrobbles.
func NewCoordinator ¶
func NewCoordinator(store Store, opts ...Option) *Coordinator
NewCoordinator creates a scrobbling coordinator backed by store.
func (*Coordinator) FlushQueue ¶
func (c *Coordinator) FlushQueue()
FlushQueue retries pending scrobbles for all configured services.
func (*Coordinator) Tick ¶
func (c *Coordinator) Tick(playbackState string)
Tick advances scrobble progress by one second when playback is active.
func (*Coordinator) TrackStarted ¶
func (c *Coordinator) TrackStarted(track Track)
TrackStarted resets progress and sends now-playing notifications.
type LastFM ¶
type LastFM interface {
NowPlaying(library.ScrobbleConfig, Track) error
Scrobble(library.ScrobbleConfig, Track, int64) error
ScrobbleBatch(library.ScrobbleConfig, []QueuedTrack) error
}
LastFM submits Last.fm now-playing and scrobble requests.
type ListenBrainz ¶
type ListenBrainz interface {
NowPlaying(library.ListenBrainzConfig, Track) error
Scrobble(library.ListenBrainzConfig, Track, int64) error
ScrobbleBatch(library.ListenBrainzConfig, []QueuedTrack) error
}
ListenBrainz submits ListenBrainz now-playing and scrobble requests.
type Option ¶
type Option func(*Coordinator)
Option configures a Coordinator.
func WithAsync ¶
func WithAsync(async func(func())) Option
WithAsync replaces asynchronous execution. Tests can run functions inline.
func WithListenBrainz ¶
func WithListenBrainz(client ListenBrainz) Option
WithListenBrainz replaces the ListenBrainz adapter.
type QueuedTrack ¶
QueuedTrack is a failed scrobble ready to retry.
type Store ¶
type Store interface {
LoadScrobbleConfig() (library.ScrobbleConfig, error)
LoadListenBrainzConfig() (library.ListenBrainzConfig, error)
RecordPlay(trackID int64, durationPlayedMs int) error
EnqueueScrobble(service, trackJSON string, timestamp int64) error
PruneScrobbleQueue() error
PendingScrobbles(service string, limit int) ([]library.ScrobbleQueueEntry, error)
RemoveScrobble(id int64) error
MarkScrobbleAttempt(id int64) error
}
Store is the persistence interface used by Coordinator.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package lastfm provides stateless functions for the Last.fm Scrobbling API v2.
|
Package lastfm provides stateless functions for the Last.fm Scrobbling API v2. |
|
Package listenbrainz provides stateless functions for the ListenBrainz API.
|
Package listenbrainz provides stateless functions for the ListenBrainz API. |