scrobbling

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

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 WithLastFM

func WithLastFM(client LastFM) Option

WithLastFM replaces the Last.fm adapter.

func WithListenBrainz

func WithListenBrainz(client ListenBrainz) Option

WithListenBrainz replaces the ListenBrainz adapter.

func WithNow

func WithNow(now func() time.Time) Option

WithNow replaces the clock used for scrobble timestamps.

type QueuedTrack

type QueuedTrack struct {
	Track
	Timestamp int64
}

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.

type Track

type Track struct {
	ID         int64
	Artist     string
	Title      string
	Album      string
	DurationMs int
}

Track is the playback metadata needed for scrobbling.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址