about summary refs log tree commit diff
path: root/tools/mpd-stats/internal
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tools/mpd-stats/internal/mpd/mpd.go8
-rw-r--r--tools/mpd-stats/internal/scrobbler/scrobbler.go2
2 files changed, 8 insertions, 2 deletions
diff --git a/tools/mpd-stats/internal/mpd/mpd.go b/tools/mpd-stats/internal/mpd/mpd.go
index 5b57ee4..859348e 100644
--- a/tools/mpd-stats/internal/mpd/mpd.go
+++ b/tools/mpd-stats/internal/mpd/mpd.go
@@ -7,6 +7,11 @@ import (
 	"github.com/fhs/gompd/v2/mpd"
 )
 
+const (
+	// List of subsystems: https://mpd.readthedocs.io/en/latest/protocol.html#querying-mpd-s-status
+	SubSystemPlayer = "player"
+)
+
 type Player struct {
 	Watcher *mpd.Watcher
 	Client  *mpd.Client
@@ -18,7 +23,8 @@ func NewPlayer(net string, addr string) (*Player, error) {
 		err error
 	)
 
-	p.Watcher, err = mpd.NewWatcher(net, addr, "", "player")
+	// We are only subscribing to the player subsystem
+	p.Watcher, err = mpd.NewWatcher(net, addr, "", SubSystemPlayer)
 	if err != nil {
 		log.Fatalf("failed to create a watcher: %v", err)
 	}
diff --git a/tools/mpd-stats/internal/scrobbler/scrobbler.go b/tools/mpd-stats/internal/scrobbler/scrobbler.go
index f0f9d0e..eb4eb9c 100644
--- a/tools/mpd-stats/internal/scrobbler/scrobbler.go
+++ b/tools/mpd-stats/internal/scrobbler/scrobbler.go
@@ -44,7 +44,7 @@ func (s *Scrobbler) Run() error {
 
 	for {
 		e := <-s.player.Watcher.Event
-		if e != "" {
+		if e == mpd.SubSystemPlayer {
 			status, err := s.player.Client.Status()
 			if err != nil {
 				log.Printf("could not read the status: %v", err)