aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2021-10-10 13:01:21 -0700
committerFranck Cuny <franck@fcuny.net>2021-10-10 13:01:21 -0700
commitc95f72a953e6a9068c1e7b89f530fa05f10c4bde (patch)
treee1ab6da25addb12e0555422857918caf53544595 /cmd
parentscrobbler: add timestamp to the record (diff)
downloadx-c95f72a953e6a9068c1e7b89f530fa05f10c4bde.tar.gz
mpd-stats: pass database path to the scrobbler
When creating a scrobbler, we provide the path to the database. The scrobbler then get a handler to the database. When a new record is created, we persist it to the database using the `save` function.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/mpd-scrobbler/main.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/cmd/mpd-scrobbler/main.go b/cmd/mpd-scrobbler/main.go
index 3540807..fdd9e4d 100644
--- a/cmd/mpd-scrobbler/main.go
+++ b/cmd/mpd-scrobbler/main.go
@@ -1,7 +1,9 @@
package main
import (
+ "fmt"
"log"
+ "os"
"golang.fcuny.net/mpd-stats/internal/scrobbler"
)
@@ -9,8 +11,9 @@ import (
func main() {
net := "tcp"
addr := "localhost:6600"
+ dbpath := fmt.Sprintf("%s/.config/scrobbler.sql", os.Getenv("HOME"))
- s, err := scrobbler.NewScrobbler(net, addr)
+ s, err := scrobbler.NewScrobbler(net, addr, dbpath)
if err != nil {
log.Fatalf("failed to create a client: %v", err)
}