diff --git a/.golangci.yml b/.golangci.yml
index 6e4119b..682dfc8 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -30,7 +30,6 @@ linters:
- gocritic
- gocyclo
- gofmt
- - gofumpt
- goheader
- goimports
- gomoddirectives
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 48ebecf..16878ed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,20 @@
# Changelog
+### [0.16.2](https://www.github.com/sentriz/gonic/compare/v0.16.1...v0.16.2) (2023-11-30)
+
+
+### Features
+
+* set global http timeouts except for streaming endpoints ([2edb1b8](https://www.github.com/sentriz/gonic/commit/2edb1b8eda649671aa4b0534ec8065bde65803e3)), closes [#411](https://www.github.com/sentriz/gonic/issues/411)
+
+
+### Bug Fixes
+
+* **admin:** don't start with empty session key ([dd0f6b3](https://www.github.com/sentriz/gonic/commit/dd0f6b3650426a06218bff875301471b92c6f03e)), closes [#414](https://www.github.com/sentriz/gonic/issues/414)
+* **jukebox:** make sure we clean up "seekable" event listener ([b199bc1](https://www.github.com/sentriz/gonic/commit/b199bc104e90eaf760563b6efca409ccd9618788)), closes [#411](https://www.github.com/sentriz/gonic/issues/411)
+* **jukebox:** restore play index only when incoming new track has index >0 ([82c3c5b](https://www.github.com/sentriz/gonic/commit/82c3c5baef5a5145902cd96e1a14d6d3fd50320f)), closes [#411](https://www.github.com/sentriz/gonic/issues/411)
+* **subsonic:** return empty opensubsonic fields ([5022500](https://www.github.com/sentriz/gonic/commit/5022500b307e746f2ff0426b07c4e776873c880a))
+
### [0.16.1](https://www.github.com/sentriz/gonic/compare/v0.16.0...v0.16.1) (2023-11-08)
diff --git a/README.md b/README.md
index 397fa48..fd2160f 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,9 @@

-FLOSS alternative to subsonic, supporting its many clients
+free-software subsonic server API implementation, supporting its many clients
-
-
-
-
-
-
- irc #gonic on libera.chat
- |
- matrix #gonic:libera.chat
+
+
## features
@@ -18,7 +11,7 @@
- browsing by folder (keeping your full tree intact) [see here](#directory-structure)
- browsing by tags (using [taglib](https://taglib.org/) - supports mp3, opus, flac, ape, m4a, wav, etc.)
- on-the-fly audio transcoding and caching (requires [ffmpeg](https://ffmpeg.org/)) (thank you [spijet](https://github.com/spijet/))
-- jukebox mode (thank you [lxea](https://github.com/lxea/))
+- subsonic jukebox mode, for gapless server-side audio playback instead of streaming (thank you [lxea](https://github.com/lxea/))
- support for podcasts (thank you [lxea](https://github.com/lxea/))
- pretty fast scanning (with my library of ~50k tracks, initial scan takes about 10m, and about 6s after incrementally)
- multiple users, each with their own transcoding preferences, playlists, top tracks, top artists, etc.
@@ -30,9 +23,7 @@
- support for the [album-artist](https://mkoby.com/2007/02/18/artist-versus-album-artist/) tag, to not clutter your artist list with compilation album appearances
- written in [go](https://golang.org/), so lightweight and suitable for a raspberry pi, etc. (see ARM images below)
- newer salt and token auth
-- tested on [airsonic-refix](https://github.com/tamland/airsonic-refix), [symfonium](https://symfonium.app), [dsub](https://f-droid.org/en/packages/github.daneren2005.dsub/), [jamstash](http://jamstash.com/),
- [sublime music](https://github.com/sublime-music/sublime-music), [soundwaves](https://apps.apple.com/us/app/soundwaves/id736139596),
- [stmp](https://github.com/wildeyedskies/stmp), [strawberry](https://www.strawberrymusicplayer.org/), and [ultrasonic](https://gitlab.com/ultrasonic/ultrasonic)
+- tested on [airsonic-refix](https://github.com/tamland/airsonic-refix), [symfonium](https://symfonium.app), [dsub](https://f-droid.org/en/packages/github.daneren2005.dsub/), [jamstash](http://jamstash.com/), [subsonic.el](https://git.sr.ht/~amk/subsonic.el), [sublime music](https://github.com/sublime-music/sublime-music), [soundwaves](https://apps.apple.com/us/app/soundwaves/id736139596), [stmp](https://github.com/wildeyedskies/stmp), [strawberry](https://www.strawberrymusicplayer.org/), and [ultrasonic](https://gitlab.com/ultrasonic/ultrasonic)
## installation
@@ -131,8 +122,8 @@ queries like show me "recently played compilations" or "recently added albums" a
when browsing by folder, any arbitrary and nested folder layout is supported, with the following caveats:
-- Files from the same album must all be in the same folder
-- All files in a folder must be from the same album
+- files from the same album must all be in the same folder
+- all files in a folder must be from the same album
please see [here](https://github.com/sentriz/gonic/issues/89) for more context
diff --git a/cmd/gonic/default.pgo b/cmd/gonic/default.pgo
index a3fb704..7a8d9f9 100644
Binary files a/cmd/gonic/default.pgo and b/cmd/gonic/default.pgo differ
diff --git a/cmd/gonic/gonic.go b/cmd/gonic/gonic.go
index 8816789..ee601b2 100644
--- a/cmd/gonic/gonic.go
+++ b/cmd/gonic/gonic.go
@@ -9,6 +9,7 @@ import (
"fmt"
"log"
"net/http"
+ "net/http/pprof"
"os"
"os/signal"
"path"
@@ -87,6 +88,7 @@ func main() {
set.Var(&confMultiValueArtist, "multi-value-artist", "setting for mutli-valued track artist scanning (optional)")
set.Var(&confMultiValueAlbumArtist, "multi-value-album-artist", "setting for mutli-valued album artist scanning (optional)")
+ confPprof := set.Bool("pprof", false, "enable the /debug/pprof endpoint (optional)")
confExpvar := set.Bool("expvar", false, "enable the /debug/vars endpoint (optional)")
deprecatedConfGenreSplit := set.String("genre-split", "", "(deprecated, see multi-value settings)")
@@ -232,7 +234,8 @@ func main() {
log.Panicf("error getting session key: %v\n", err)
}
if sessKey == "" {
- if err := dbc.SetSetting("session_key", string(securecookie.GenerateRandomKey(32))); err != nil {
+ sessKey = string(securecookie.GenerateRandomKey(32))
+ if err := dbc.SetSetting("session_key", sessKey); err != nil {
log.Panicf("error setting session key: %v\n", err)
}
}
@@ -282,12 +285,34 @@ func main() {
}))
}
+ var (
+ readTimeout = 5 * time.Second
+ writeTimeout = 5 * time.Second
+ idleTimeout = 5 * time.Second
+ )
+
+ if *confPprof {
+ // overwrite global WriteTimeout. in future we should set this only for these handlers
+ // https://github.com/golang/go/issues/62358
+ writeTimeout = 0
+
+ mux.HandleFunc("/debug/pprof/", pprof.Index)
+ mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
+ mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
+ mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
+ mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
+ }
+
errgrp, ctx := errgroup.WithContext(context.Background())
errgrp.Go(func() error {
defer logJob("http")()
- server := &http.Server{Addr: *confListenAddr, Handler: mux, ReadHeaderTimeout: 5 * time.Second}
+ server := &http.Server{
+ Addr: *confListenAddr,
+ ReadTimeout: readTimeout, WriteTimeout: writeTimeout, IdleTimeout: idleTimeout,
+ Handler: mux,
+ }
errgrp.Go(func() error {
<-ctx.Done()
return server.Shutdown(context.Background())
diff --git a/go.mod b/go.mod
index 1023eeb..6927647 100644
--- a/go.mod
+++ b/go.mod
@@ -27,8 +27,8 @@ require (
github.com/sentriz/audiotags v0.0.0-20230419125925-8886243b2137
github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981
github.com/stretchr/testify v1.8.4
- golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
- golang.org/x/net v0.18.0
+ golang.org/x/exp v0.0.0-20231127185646-65229373498e
+ golang.org/x/net v0.19.0
golang.org/x/sync v0.5.0
gopkg.in/gormigrate.v1 v1.6.0
jaytaylor.com/html2text v0.0.0-20230321000545-74c2419ad056
@@ -63,9 +63,9 @@ require (
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
- golang.org/x/crypto v0.15.0 // indirect
+ golang.org/x/crypto v0.16.0 // indirect
golang.org/x/image v0.14.0 // indirect
- golang.org/x/sys v0.14.0 // indirect
+ golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
diff --git a/go.sum b/go.sum
index 97de4b5..02966d0 100644
--- a/go.sum
+++ b/go.sum
@@ -160,11 +160,10 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
-golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
-golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
-golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
-golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ=
-golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE=
+golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
+golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
+golang.org/x/exp v0.0.0-20231127185646-65229373498e h1:Gvh4YaCaXNs6dKTlfgismwWZKyjVZXwOPfIyUaqU3No=
+golang.org/x/exp v0.0.0-20231127185646-65229373498e/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4=
golang.org/x/image v0.14.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
@@ -182,9 +181,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
-golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
-golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=
-golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
+golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
+golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -200,10 +198,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
-golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
+golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
diff --git a/handlerutil/handlerutil.go b/handlerutil/handlerutil.go
index 860f91d..4116dc7 100644
--- a/handlerutil/handlerutil.go
+++ b/handlerutil/handlerutil.go
@@ -69,21 +69,20 @@ func Message(message string) http.Handler {
}
func BaseURL(r *http.Request) string {
- fallbackProtocoll := "http"
+ var fallbackScheme = "http"
if r.TLS != nil {
- fallbackProtocoll = "https"
+ fallbackScheme = "https"
}
- fallbackHost := "localhost:4747"
scheme := first(
r.Header.Get("X-Forwarded-Proto"),
r.Header.Get("X-Forwarded-Scheme"),
r.URL.Scheme,
- fallbackProtocoll,
+ fallbackScheme,
)
host := first(
r.Header.Get("X-Forwarded-Host"),
+ r.URL.Host,
r.Host,
- fallbackHost,
)
return fmt.Sprintf("%s://%s", scheme, host)
}
@@ -105,6 +104,10 @@ func (w *statusWriter) Write(b []byte) (int, error) {
return w.ResponseWriter.Write(b)
}
+func (w *statusWriter) Unwrap() http.ResponseWriter {
+ return w.ResponseWriter
+}
+
func statusToBlock(code int) string {
var bg int
switch {
diff --git a/jukebox/jukebox.go b/jukebox/jukebox.go
index 47eae36..1f03e14 100644
--- a/jukebox/jukebox.go
+++ b/jukebox/jukebox.go
@@ -36,11 +36,10 @@ func MPVArg(k string, v any) string {
}
type Jukebox struct {
- cmd *exec.Cmd
- conn *mpvipc.Connection
- events <-chan *mpvipc.Event
+ cmd *exec.Cmd
+ conn *mpvipc.Connection
- mu sync.Mutex
+ mu sync.RWMutex
}
func New() *Jukebox {
@@ -77,7 +76,7 @@ func (j *Jukebox) Start(sockPath string, mpvExtraArgs []string) error {
}
var mpvVersionStr string
- if err := j.getDecode(&mpvVersionStr, "mpv-version"); err != nil {
+ if err := getDecode(j.conn, &mpvVersionStr, "mpv-version"); err != nil {
return fmt.Errorf("get mpv version: %w", err)
}
if major, minor, patch := parseMPVVersion(mpvVersionStr); major == 0 && minor < 34 {
@@ -87,7 +86,6 @@ func (j *Jukebox) Start(sockPath string, mpvExtraArgs []string) error {
if _, err := j.conn.Call("observe_property", 0, "seekable"); err != nil {
return fmt.Errorf("observe property: %w", err)
}
- j.events, _ = j.conn.NewEventListener()
return nil
}
@@ -101,10 +99,10 @@ func (j *Jukebox) Wait() error {
}
func (j *Jukebox) GetPlaylist() ([]string, error) {
- defer lock(&j.mu)()
+ defer lockr(&j.mu)()
var playlist mpvPlaylist
- if err := j.getDecode(&playlist, "playlist"); err != nil {
+ if err := getDecode(j.conn, &playlist, "playlist"); err != nil {
return nil, fmt.Errorf("get playlist: %w", err)
}
var items []string
@@ -118,15 +116,11 @@ func (j *Jukebox) SetPlaylist(items []string) error {
defer lock(&j.mu)()
var playlist mpvPlaylist
- if err := j.getDecode(&playlist, "playlist"); err != nil {
+ if err := getDecode(j.conn, &playlist, "playlist"); err != nil {
return fmt.Errorf("get playlist: %w", err)
}
- current, currentIndex := find(playlist, func(item mpvPlaylistItem) bool {
- return item.Current
- })
-
- filteredItems, foundExistingTrack := filter(items, func(filename string) bool {
- return filename != current.Filename
+ currentPlayingIndex := slices.IndexFunc(playlist, func(pl mpvPlaylistItem) bool {
+ return pl.Current
})
tmp, cleanup, err := tmp()
@@ -134,30 +128,35 @@ func (j *Jukebox) SetPlaylist(items []string) error {
return fmt.Errorf("create temp file: %w", err)
}
defer cleanup()
- for _, item := range filteredItems {
+
+ var newPlayingIndex = -1
+ for i, item := range items {
item, _ = filepath.Abs(item)
+ if currentPlayingIndex >= 0 && playlist[currentPlayingIndex].Filename == item {
+ newPlayingIndex = i
+ continue // don't add current track to loadlist
+ }
+
fmt.Fprintln(tmp, item)
}
- if !foundExistingTrack {
- // easy case - a brand new set of tracks that we can overwrite
+ if newPlayingIndex < 0 {
if _, err := j.conn.Call("loadlist", tmp.Name(), "replace"); err != nil {
return fmt.Errorf("load list: %w", err)
}
return nil
}
- // not so easy, we need to clear the playlist except what's playing, load everything
- // except for what we're playing, then move what's playing back to its original index
- // clear all items except what's playing (will be at index 0)
- if _, err := j.conn.Call("playlist-clear"); err != nil {
+ if _, err := j.conn.Call("playlist-clear"); err != nil { // leaves current at index 0
return fmt.Errorf("clear playlist: %w", err)
}
if _, err := j.conn.Call("loadlist", tmp.Name(), "append-play"); err != nil {
return fmt.Errorf("load list: %w", err)
}
- if _, err := j.conn.Call("playlist-move", 0, currentIndex+1); err != nil {
- return fmt.Errorf("playlist move: %w", err)
+ if newPlayingIndex > 0 {
+ if _, err := j.conn.Call("playlist-move", 0, newPlayingIndex+1); err != nil {
+ return fmt.Errorf("playlist move: %w", err)
+ }
}
return nil
}
@@ -203,19 +202,25 @@ func (j *Jukebox) SkipToPlaylistIndex(i int, offsetSecs int) error {
return fmt.Errorf("pause: %w", err)
}
}
+
+ ch, stop := j.conn.NewEventListener()
+ defer close(stop)
+
if _, err := j.conn.Call("playlist-play-index", i); err != nil {
return fmt.Errorf("playlist play index: %w", err)
}
+
if offsetSecs > 0 {
- if err := waitFor(j.events, matchEventSeekable); err != nil {
+ if err := waitFor(ch, matchEventSeekable); err != nil {
return fmt.Errorf("waiting for file load: %w", err)
}
if _, err := j.conn.Call("seek", offsetSecs, "absolute"); err != nil {
return fmt.Errorf("seek: %w", err)
}
- if err := j.conn.Set("pause", false); err != nil {
- return fmt.Errorf("play: %w", err)
- }
+ }
+
+ if err := j.conn.Set("pause", false); err != nil {
+ return fmt.Errorf("play: %w", err)
}
return nil
}
@@ -257,10 +262,10 @@ func (j *Jukebox) SetVolumePct(v int) error {
}
func (j *Jukebox) GetVolumePct() (float64, error) {
- defer lock(&j.mu)()
+ defer lockr(&j.mu)()
var volume float64
- if err := j.getDecode(&volume, "volume"); err != nil {
+ if err := getDecode(j.conn, &volume, "volume"); err != nil {
return 0, fmt.Errorf("get volume: %w", err)
}
return volume, nil
@@ -276,14 +281,14 @@ type Status struct {
}
func (j *Jukebox) GetStatus() (*Status, error) {
- defer lock(&j.mu)()
+ defer lockr(&j.mu)()
var status Status
- _ = j.getDecode(&status.Position, "time-pos") // property may not always be there
- _ = j.getDecode(&status.GainPct, "volume") // property may not always be there
+ _ = getDecode(j.conn, &status.Position, "time-pos") // property may not always be there
+ _ = getDecode(j.conn, &status.GainPct, "volume") // property may not always be there
var playlist mpvPlaylist
- _ = j.getDecode(&playlist, "playlist")
+ _ = getDecode(j.conn, &playlist, "playlist")
status.CurrentIndex = slices.IndexFunc(playlist, func(pl mpvPlaylistItem) bool {
return pl.Current
@@ -298,7 +303,7 @@ func (j *Jukebox) GetStatus() (*Status, error) {
status.CurrentFilename = playlist[status.CurrentIndex].Filename
var paused bool
- _ = j.getDecode(&paused, "pause") // property may not always be there
+ _ = getDecode(j.conn, &paused, "pause") // property may not always be there
status.Playing = !paused
return &status, nil
@@ -324,8 +329,8 @@ func (j *Jukebox) Quit() error {
return nil
}
-func (j *Jukebox) getDecode(dest any, property string) error {
- raw, err := j.conn.Get(property)
+func getDecode(conn *mpvipc.Connection, dest any, property string) error {
+ raw, err := conn.Get(property)
if err != nil {
return fmt.Errorf("get property: %w", err)
}
@@ -367,8 +372,6 @@ func waitFor[T any](ch <-chan T, match func(e T) bool) error {
quit := time.NewTicker(1 * time.Second)
defer quit.Stop()
- defer time.Sleep(350 * time.Millisecond)
-
for {
select {
case <-quit.C:
@@ -393,32 +396,18 @@ func tmp() (*os.File, func(), error) {
return tmp, cleanup, nil
}
-func find[T any](items []T, f func(T) bool) (T, int) {
- for i, item := range items {
- if f(item) {
- return item, i
- }
- }
- var t T
- return t, -1
-}
-
-func filter[T comparable](items []T, f func(T) bool) ([]T, bool) {
- var found bool
- var ret []T
- for _, item := range items {
- if !f(item) {
- found = true
- continue
- }
- ret = append(ret, item)
- }
- return ret, found
-}
-
-func lock(mu *sync.Mutex) func() {
+func lock(mu *sync.RWMutex) func() {
mu.Lock()
- return mu.Unlock
+ return func() {
+ // let mpv "settle" since it seems to return from ipc calls before everything is sorted out
+ time.Sleep(200 * time.Millisecond)
+ mu.Unlock()
+ }
+}
+
+func lockr(mu *sync.RWMutex) func() {
+ mu.RLock()
+ return mu.RUnlock
}
var mpvVersionExpr = regexp.MustCompile(`mpv\s(\d+)\.(\d+)\.(\d+)`)
diff --git a/jukebox/jukebox_test.go b/jukebox/jukebox_test.go
index 15dfeb7..f771678 100644
--- a/jukebox/jukebox_test.go
+++ b/jukebox/jukebox_test.go
@@ -12,7 +12,7 @@ import (
)
func TestPlaySkipReset(t *testing.T) {
- t.Skip("bit flakey currently")
+ t.Skip("bit flakey since mpv ipc doesn't block while internal state has settled")
t.Parallel()
j := newJukebox(t)
@@ -74,7 +74,7 @@ func TestPlaySkipReset(t *testing.T) {
require.Equal(t, true, status.Playing)
// just add one more by overwriting the playlist like some clients do
- // we should keep the current track unchaned if we find it
+ // we should move keep the playing indedx
require.NoError(t, j.SetPlaylist([]string{
"testdata/tr_0.mp3",
"testdata/tr_1.mp3",
@@ -86,50 +86,13 @@ func TestPlaySkipReset(t *testing.T) {
status, err = j.GetStatus()
require.NoError(t, err)
- require.Equal(t, 3, status.CurrentIndex) // index unchanged
+ require.Equal(t, 3, status.CurrentIndex) // index moved to start
require.Equal(t, testPath("tr_3.mp3"), status.CurrentFilename)
require.Equal(t, 6, status.Length) // we added one more track
require.Equal(t, true, status.Playing)
- // skip to 3 again
- require.NoError(t, j.SkipToPlaylistIndex(3, 0))
-
- status, err = j.GetStatus()
- require.NoError(t, err)
- require.Equal(t, 3, status.CurrentIndex)
- require.Equal(t, testPath("tr_3.mp3"), status.CurrentFilename)
- require.Equal(t, 6, status.Length)
- require.Equal(t, true, status.Playing)
-
- // remove all but 3
+ // new playlist with out current track (tr_2)
require.NoError(t, j.SetPlaylist([]string{
- "testdata/tr_0.mp3",
- "testdata/tr_1.mp3",
- "testdata/tr_2.mp3",
- "testdata/tr_3.mp3",
- }))
-
- status, err = j.GetStatus()
- require.NoError(t, err)
- require.Equal(t, 3, status.CurrentIndex) // index unchanged
- require.Equal(t, testPath("tr_3.mp3"), status.CurrentFilename)
- require.Equal(t, 4, status.Length)
- require.Equal(t, true, status.Playing)
-
- // skip to 2 (5s long) in the middle of the track
- require.NoError(t, j.SkipToPlaylistIndex(2, 2))
-
- status, err = j.GetStatus()
- require.NoError(t, err)
- require.Equal(t, 2, status.CurrentIndex) // index unchanged
- require.Equal(t, testPath("tr_2.mp3"), status.CurrentFilename)
- require.Equal(t, 4, status.Length)
- require.Equal(t, true, status.Playing)
- require.Equal(t, 2, status.Position) // at new position
-
- // overwrite completely
- require.NoError(t, j.SetPlaylist([]string{
- "testdata/tr_5.mp3",
"testdata/tr_6.mp3",
"testdata/tr_7.mp3",
"testdata/tr_8.mp3",
@@ -139,12 +102,72 @@ func TestPlaySkipReset(t *testing.T) {
status, err = j.GetStatus()
require.NoError(t, err)
require.Equal(t, 0, status.CurrentIndex) // index unchanged
- require.Equal(t, testPath("tr_5.mp3"), status.CurrentFilename)
- require.Equal(t, 5, status.Length)
+ require.Equal(t, testPath("tr_6.mp3"), status.CurrentFilename)
+ require.Equal(t, 4, status.Length)
require.Equal(t, true, status.Playing)
+
+ // skip to index 2 (5s long) in the middle of the track
+ require.NoError(t, j.SkipToPlaylistIndex(2, 2))
+
+ status, err = j.GetStatus()
+ require.NoError(t, err)
+ require.Equal(t, 2, status.CurrentIndex) // index unchanged
+ require.Equal(t, testPath("tr_8.mp3"), status.CurrentFilename)
+ require.Equal(t, 4, status.Length)
+ require.Equal(t, true, status.Playing)
+ require.Equal(t, 2, status.Position) // at new position
+}
+
+func TestShuffle(t *testing.T) {
+ t.Skip("bit flakey since mpv ipc doesn't block while internal state has settled")
+
+ t.Parallel()
+ j := newJukebox(t)
+
+ require.NoError(t, j.SetPlaylist([]string{
+ testPath("tr_0.mp3"),
+ testPath("tr_1.mp3"),
+ testPath("tr_2.mp3"),
+ testPath("tr_3.mp3"),
+ testPath("tr_4.mp3"),
+ testPath("tr_5.mp3"),
+ testPath("tr_6.mp3"),
+ testPath("tr_7.mp3"),
+ }))
+
+ require.NoError(t, j.SkipToPlaylistIndex(2, 0))
+
+ status, err := j.GetStatus()
+ require.NoError(t, err)
+ require.Equal(t, 2, status.CurrentIndex)
+ require.True(t, status.Playing)
+
+ desiredOrder := []string{
+ testPath("tr_2.mp3"), // the was-playing index moves to position 0
+ testPath("tr_1.mp3"),
+ testPath("tr_0.mp3"),
+ testPath("tr_3.mp3"),
+ testPath("tr_5.mp3"),
+ testPath("tr_6.mp3"),
+ testPath("tr_7.mp3"),
+ testPath("tr_4.mp3"),
+ }
+
+ require.NoError(t, j.SetPlaylist(desiredOrder))
+
+ status, err = j.GetStatus()
+ require.NoError(t, err)
+ require.Equal(t, 0, status.CurrentIndex)
+ require.Equal(t, len(desiredOrder), status.Length)
+
+ playlist, err := j.GetPlaylist()
+ require.NoError(t, err)
+ require.Equal(t, desiredOrder, playlist)
}
func TestVolume(t *testing.T) {
+ t.Skip("bit flakey since mpv ipc doesn't block while internal state has settled")
+
t.Parallel()
j := newJukebox(t)
diff --git a/playlist/playlist.go b/playlist/playlist.go
index 618af33..6f9f60e 100644
--- a/playlist/playlist.go
+++ b/playlist/playlist.go
@@ -7,11 +7,12 @@ import (
"io/fs"
"os"
"path/filepath"
- "regexp"
"strconv"
"strings"
"sync"
"time"
+
+ "go.senan.xyz/gonic/fileutil"
)
var (
@@ -69,7 +70,7 @@ type Playlist struct {
}
func NewPath(userID int, playlistName string) string {
- playlistName = safeFilename(playlistName)
+ playlistName = fileutil.Safe(playlistName)
if playlistName == "" {
playlistName = "pl"
}
@@ -219,13 +220,6 @@ func (s *Store) Delete(relPath string) error {
return os.Remove(filepath.Join(s.basePath, relPath))
}
-var nonAlphaNum = regexp.MustCompile("[^a-zA-Z0-9_.]+")
-
-func safeFilename(filename string) string {
- filename = nonAlphaNum.ReplaceAllString(filename, "")
- return filename
-}
-
func firstPathEl(path string) string {
path = strings.TrimPrefix(path, string(filepath.Separator))
parts := strings.Split(path, string(filepath.Separator))
diff --git a/scanner/scanner.go b/scanner/scanner.go
index a5af35a..863379a 100644
--- a/scanner/scanner.go
+++ b/scanner/scanner.go
@@ -399,7 +399,9 @@ func populateAlbum(tx *db.DB, album *db.Album, trags tagcommon.Info, modTime tim
album.TagYear = trags.Year()
album.ModifiedAt = modTime
- album.CreatedAt = modTime
+ if album.CreatedAt.After(modTime) {
+ album.CreatedAt = modTime // reset created at to match filesytem for new albums
+ }
if err := tx.Save(&album).Error; err != nil {
return fmt.Errorf("saving album: %w", err)
diff --git a/server/ctrlsubsonic/ctrl.go b/server/ctrlsubsonic/ctrl.go
index 113b33c..8c86c7b 100644
--- a/server/ctrlsubsonic/ctrl.go
+++ b/server/ctrlsubsonic/ctrl.go
@@ -10,6 +10,7 @@ import (
"io"
"log"
"net/http"
+ "time"
"go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/handlerutil"
@@ -96,6 +97,10 @@ func New(dbc *db.DB, scannr *scanner.Scanner, musicPaths []MusicPath, podcastsPa
withRequiredParams,
c.withUser,
)
+ chainRaw := handlerutil.Chain(
+ chain,
+ slow,
+ )
c.Handle("/getLicense", chain(resp(c.ServeGetLicence)))
c.Handle("/ping", chain(resp(c.ServePing)))
@@ -126,10 +131,10 @@ func New(dbc *db.DB, scannr *scanner.Scanner, musicPaths []MusicPath, podcastsPa
c.Handle("/getLyrics", chain(resp(c.ServeGetLyrics)))
// raw
- c.Handle("/getCoverArt", chain(respRaw(c.ServeGetCoverArt)))
- c.Handle("/stream", chain(respRaw(c.ServeStream)))
- c.Handle("/download", chain(respRaw(c.ServeStream)))
- c.Handle("/getAvatar", chain(respRaw(c.ServeGetAvatar)))
+ c.Handle("/getCoverArt", chainRaw(respRaw(c.ServeGetCoverArt)))
+ c.Handle("/stream", chainRaw(respRaw(c.ServeStream)))
+ c.Handle("/download", chainRaw(respRaw(c.ServeStream)))
+ c.Handle("/getAvatar", chainRaw(respRaw(c.ServeGetAvatar)))
// browse by tag
c.Handle("/getAlbum", chain(resp(c.ServeGetAlbum)))
@@ -375,6 +380,15 @@ func createLDAPconnection(tls string, fqdn string, port string) (*ldap.Conn, err
return l, nil
}
+func slow(next http.Handler) http.Handler {
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ rc := http.NewResponseController(w) //nolint:bodyclose
+ _ = rc.SetWriteDeadline(time.Time{}) // set no deadline, since we're probably streaming
+ _ = rc.SetReadDeadline(time.Time{}) // set no deadline, since we're probably streaming
+ next.ServeHTTP(w, r)
+ })
+}
+
func checkCredsToken(password, token, salt string) bool {
toHash := fmt.Sprintf("%s%s", password, salt)
hash := md5.Sum([]byte(toHash))
diff --git a/server/ctrlsubsonic/ctrl_test.go b/server/ctrlsubsonic/ctrl_test.go
index b0e7fa7..2dddea2 100644
--- a/server/ctrlsubsonic/ctrl_test.go
+++ b/server/ctrlsubsonic/ctrl_test.go
@@ -15,6 +15,7 @@ import (
"testing"
jd "github.com/josephburnett/jd/lib"
+ "github.com/stretchr/testify/require"
"go.senan.xyz/gonic"
"go.senan.xyz/gonic/db"
@@ -163,3 +164,23 @@ func makec(tb testing.TB, roots []string, audio bool) *Controller {
return contr
}
+
+func TestParams(t *testing.T) {
+ t.Parallel()
+
+ handler := withParams(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ params := r.Context().Value(CtxParams).(params.Params)
+ require.Equal(t, "Client", params.GetOr("c", ""))
+ }))
+ params := url.Values{}
+ params.Set("c", "Client")
+
+ r, err := http.NewRequest(http.MethodGet, "/?"+params.Encode(), nil)
+ require.NoError(t, err)
+ handler.ServeHTTP(nil, r)
+
+ r, err = http.NewRequest(http.MethodPost, "/", strings.NewReader(params.Encode()))
+ require.NoError(t, err)
+ r.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+ handler.ServeHTTP(nil, r)
+}
diff --git a/server/ctrlsubsonic/handlers_common.go b/server/ctrlsubsonic/handlers_common.go
index e41d0f5..69c091d 100644
--- a/server/ctrlsubsonic/handlers_common.go
+++ b/server/ctrlsubsonic/handlers_common.go
@@ -40,6 +40,7 @@ func (c *Controller) ServeGetOpenSubsonicExtensions(_ *http.Request) *spec.Respo
sub := spec.NewResponse()
sub.OpenSubsonicExtensions = &spec.OpenSubsonicExtensions{
{Name: "transcodeOffset", Versions: []int{1}},
+ {Name: "formPost", Versions: []int{1}},
}
return sub
}
@@ -332,6 +333,10 @@ func (c *Controller) ServeGetRandomSongs(r *http.Request) *spec.Response {
var errNotATrack = errors.New("not a track")
func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:gocyclo
+ if c.jukebox == nil {
+ return spec.NewError(0, "jukebox not enabled")
+ }
+
params := r.Context().Value(CtxParams).(params.Params)
trackPaths := func(ids []specid.ID) ([]string, error) {
var paths []string
diff --git a/server/ctrlsubsonic/spec/construct_by_folder.go b/server/ctrlsubsonic/spec/construct_by_folder.go
index dc65d4a..bbd0655 100644
--- a/server/ctrlsubsonic/spec/construct_by_folder.go
+++ b/server/ctrlsubsonic/spec/construct_by_folder.go
@@ -74,6 +74,7 @@ func NewTCTrackByFolder(t *db.Track, parent *db.Album) *TrackChild {
Bitrate: t.Bitrate,
IsDir: false,
Type: "music",
+ MusicBrainzID: t.TagBrainzID,
CreatedAt: t.CreatedAt,
AverageRating: formatRating(t.AverageRating),
}
diff --git a/server/ctrlsubsonic/spec/construct_by_tags.go b/server/ctrlsubsonic/spec/construct_by_tags.go
index a44d4c7..07d64c7 100644
--- a/server/ctrlsubsonic/spec/construct_by_tags.go
+++ b/server/ctrlsubsonic/spec/construct_by_tags.go
@@ -77,6 +77,7 @@ func NewTrackByTags(t *db.Track, album *db.Album) *TrackChild {
TrackNumber: t.TagTrackNumber,
DiscNumber: t.TagDiscNumber,
Type: "music",
+ MusicBrainzID: t.TagBrainzID,
Year: album.TagYear,
AverageRating: formatRating(t.AverageRating),
TranscodeMeta: TranscodeMeta{},
diff --git a/server/ctrlsubsonic/spec/spec.go b/server/ctrlsubsonic/spec/spec.go
index cd51475..4a33caa 100644
--- a/server/ctrlsubsonic/spec/spec.go
+++ b/server/ctrlsubsonic/spec/spec.go
@@ -200,6 +200,9 @@ type TrackChild struct {
DiscNumber int `xml:"discNumber,attr,omitempty" json:"discNumber,omitempty"`
Type string `xml:"type,attr,omitempty" json:"type,omitempty"`
Year int `xml:"year,attr,omitempty" json:"year,omitempty"`
+
+ MusicBrainzID string `xml:"musicBrainzId,attr" json:"musicBrainzId"`
+
// star / rating
Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
UserRating int `xml:"userRating,attr,omitempty" json:"userRating,omitempty"`
diff --git a/server/ctrlsubsonic/testdata/test_get_album_list_random b/server/ctrlsubsonic/testdata/test_get_album_list_random
index 99b12dc..64fd041 100644
--- a/server/ctrlsubsonic/testdata/test_get_album_list_random
+++ b/server/ctrlsubsonic/testdata/test_get_album_list_random
@@ -8,16 +8,31 @@
"albumList": {
"album": [
{
- "id": "al-4",
+ "id": "al-12",
"created": "2019-11-30T00:00:00Z",
- "artist": "artist-0",
+ "artist": "artist-2",
"artists": null,
"displayArtist": "",
"title": "album-1",
"album": "album-1",
- "parent": "al-2",
+ "parent": "al-10",
"isDir": true,
- "coverArt": "al-4",
+ "coverArt": "al-12",
+ "name": "album-1",
+ "songCount": 3,
+ "duration": 300
+ },
+ {
+ "id": "al-8",
+ "created": "2019-11-30T00:00:00Z",
+ "artist": "artist-1",
+ "artists": null,
+ "displayArtist": "",
+ "title": "album-1",
+ "album": "album-1",
+ "parent": "al-6",
+ "isDir": true,
+ "coverArt": "al-8",
"name": "album-1",
"songCount": 3,
"duration": 300
@@ -38,16 +53,31 @@
"duration": 300
},
{
- "id": "al-12",
+ "id": "al-9",
"created": "2019-11-30T00:00:00Z",
- "artist": "artist-2",
+ "artist": "artist-1",
+ "artists": null,
+ "displayArtist": "",
+ "title": "album-2",
+ "album": "album-2",
+ "parent": "al-6",
+ "isDir": true,
+ "coverArt": "al-9",
+ "name": "album-2",
+ "songCount": 3,
+ "duration": 300
+ },
+ {
+ "id": "al-4",
+ "created": "2019-11-30T00:00:00Z",
+ "artist": "artist-0",
"artists": null,
"displayArtist": "",
"title": "album-1",
"album": "album-1",
- "parent": "al-10",
+ "parent": "al-2",
"isDir": true,
- "coverArt": "al-12",
+ "coverArt": "al-4",
"name": "album-1",
"songCount": 3,
"duration": 300
@@ -111,36 +141,6 @@
"name": "album-0",
"songCount": 3,
"duration": 300
- },
- {
- "id": "al-9",
- "created": "2019-11-30T00:00:00Z",
- "artist": "artist-1",
- "artists": null,
- "displayArtist": "",
- "title": "album-2",
- "album": "album-2",
- "parent": "al-6",
- "isDir": true,
- "coverArt": "al-9",
- "name": "album-2",
- "songCount": 3,
- "duration": 300
- },
- {
- "id": "al-8",
- "created": "2019-11-30T00:00:00Z",
- "artist": "artist-1",
- "artists": null,
- "displayArtist": "",
- "title": "album-1",
- "album": "album-1",
- "parent": "al-6",
- "isDir": true,
- "coverArt": "al-8",
- "name": "album-1",
- "songCount": 3,
- "duration": 300
}
]
}
diff --git a/server/ctrlsubsonic/testdata/test_get_album_list_two_random b/server/ctrlsubsonic/testdata/test_get_album_list_two_random
index 50cab38..0267d2c 100644
--- a/server/ctrlsubsonic/testdata/test_get_album_list_two_random
+++ b/server/ctrlsubsonic/testdata/test_get_album_list_two_random
@@ -8,61 +8,16 @@
"albumList2": {
"album": [
{
- "id": "al-12",
- "created": "2019-11-30T00:00:00Z",
- "artistId": "ar-3",
- "artist": "artist-2",
- "artists": [{ "id": "ar-3", "name": "artist-2" }],
- "displayArtist": "artist-2",
- "title": "album-1",
- "album": "album-1",
- "coverArt": "al-12",
- "name": "album-1",
- "songCount": 3,
- "duration": 300,
- "year": 2021
- },
- {
- "id": "al-11",
- "created": "2019-11-30T00:00:00Z",
- "artistId": "ar-3",
- "artist": "artist-2",
- "artists": [{ "id": "ar-3", "name": "artist-2" }],
- "displayArtist": "artist-2",
- "title": "album-0",
- "album": "album-0",
- "coverArt": "al-11",
- "name": "album-0",
- "songCount": 3,
- "duration": 300,
- "year": 2021
- },
- {
- "id": "al-13",
- "created": "2019-11-30T00:00:00Z",
- "artistId": "ar-3",
- "artist": "artist-2",
- "artists": [{ "id": "ar-3", "name": "artist-2" }],
- "displayArtist": "artist-2",
- "title": "album-2",
- "album": "album-2",
- "coverArt": "al-13",
- "name": "album-2",
- "songCount": 3,
- "duration": 300,
- "year": 2021
- },
- {
- "id": "al-9",
+ "id": "al-7",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-2",
"artist": "artist-1",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "artist-1",
- "title": "album-2",
- "album": "album-2",
- "coverArt": "al-9",
- "name": "album-2",
+ "title": "album-0",
+ "album": "album-0",
+ "coverArt": "al-7",
+ "name": "album-0",
"songCount": 3,
"duration": 300,
"year": 2021
@@ -83,31 +38,16 @@
"year": 2021
},
{
- "id": "al-7",
+ "id": "al-12",
"created": "2019-11-30T00:00:00Z",
- "artistId": "ar-2",
- "artist": "artist-1",
- "artists": [{ "id": "ar-2", "name": "artist-1" }],
- "displayArtist": "artist-1",
- "title": "album-0",
- "album": "album-0",
- "coverArt": "al-7",
- "name": "album-0",
- "songCount": 3,
- "duration": 300,
- "year": 2021
- },
- {
- "id": "al-5",
- "created": "2019-11-30T00:00:00Z",
- "artistId": "ar-1",
- "artist": "artist-0",
- "artists": [{ "id": "ar-1", "name": "artist-0" }],
- "displayArtist": "artist-0",
- "title": "album-2",
- "album": "album-2",
- "coverArt": "al-5",
- "name": "album-2",
+ "artistId": "ar-3",
+ "artist": "artist-2",
+ "artists": [{ "id": "ar-3", "name": "artist-2" }],
+ "displayArtist": "artist-2",
+ "title": "album-1",
+ "album": "album-1",
+ "coverArt": "al-12",
+ "name": "album-1",
"songCount": 3,
"duration": 300,
"year": 2021
@@ -141,6 +81,66 @@
"songCount": 3,
"duration": 300,
"year": 2021
+ },
+ {
+ "id": "al-9",
+ "created": "2019-11-30T00:00:00Z",
+ "artistId": "ar-2",
+ "artist": "artist-1",
+ "artists": [{ "id": "ar-2", "name": "artist-1" }],
+ "displayArtist": "artist-1",
+ "title": "album-2",
+ "album": "album-2",
+ "coverArt": "al-9",
+ "name": "album-2",
+ "songCount": 3,
+ "duration": 300,
+ "year": 2021
+ },
+ {
+ "id": "al-5",
+ "created": "2019-11-30T00:00:00Z",
+ "artistId": "ar-1",
+ "artist": "artist-0",
+ "artists": [{ "id": "ar-1", "name": "artist-0" }],
+ "displayArtist": "artist-0",
+ "title": "album-2",
+ "album": "album-2",
+ "coverArt": "al-5",
+ "name": "album-2",
+ "songCount": 3,
+ "duration": 300,
+ "year": 2021
+ },
+ {
+ "id": "al-13",
+ "created": "2019-11-30T00:00:00Z",
+ "artistId": "ar-3",
+ "artist": "artist-2",
+ "artists": [{ "id": "ar-3", "name": "artist-2" }],
+ "displayArtist": "artist-2",
+ "title": "album-2",
+ "album": "album-2",
+ "coverArt": "al-13",
+ "name": "album-2",
+ "songCount": 3,
+ "duration": 300,
+ "year": 2021
+ },
+ {
+ "id": "al-11",
+ "created": "2019-11-30T00:00:00Z",
+ "artistId": "ar-3",
+ "artist": "artist-2",
+ "artists": [{ "id": "ar-3", "name": "artist-2" }],
+ "displayArtist": "artist-2",
+ "title": "album-0",
+ "album": "album-0",
+ "coverArt": "al-11",
+ "name": "album-0",
+ "songCount": 3,
+ "duration": 300,
+ "year": 2021
}
]
}
diff --git a/server/ctrlsubsonic/testdata/test_get_album_with_cover b/server/ctrlsubsonic/testdata/test_get_album_with_cover
index 2e65ac7..f0185a3 100644
--- a/server/ctrlsubsonic/testdata/test_get_album_with_cover
+++ b/server/ctrlsubsonic/testdata/test_get_album_with_cover
@@ -46,7 +46,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-2",
@@ -72,7 +73,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-3",
@@ -98,7 +100,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
}
]
}
diff --git a/server/ctrlsubsonic/testdata/test_get_music_directory_with_tracks b/server/ctrlsubsonic/testdata/test_get_music_directory_with_tracks
index 745da5f..44af192 100644
--- a/server/ctrlsubsonic/testdata/test_get_music_directory_with_tracks
+++ b/server/ctrlsubsonic/testdata/test_get_music_directory_with_tracks
@@ -32,7 +32,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-2",
@@ -56,7 +57,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-3",
@@ -80,7 +82,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
}
]
}
diff --git a/server/ctrlsubsonic/testdata/test_get_music_directory_without_tracks b/server/ctrlsubsonic/testdata/test_get_music_directory_without_tracks
index f794ed0..6872329 100644
--- a/server/ctrlsubsonic/testdata/test_get_music_directory_without_tracks
+++ b/server/ctrlsubsonic/testdata/test_get_music_directory_without_tracks
@@ -22,7 +22,8 @@
"isDir": true,
"isVideo": false,
"parent": "al-2",
- "title": "album-0"
+ "title": "album-0",
+ "musicBrainzId": ""
},
{
"id": "al-4",
@@ -36,7 +37,8 @@
"isDir": true,
"isVideo": false,
"parent": "al-2",
- "title": "album-1"
+ "title": "album-1",
+ "musicBrainzId": ""
},
{
"id": "al-5",
@@ -50,7 +52,8 @@
"isDir": true,
"isVideo": false,
"parent": "al-2",
- "title": "album-2"
+ "title": "album-2",
+ "musicBrainzId": ""
}
]
}
diff --git a/server/ctrlsubsonic/testdata/test_search_three_q_tra b/server/ctrlsubsonic/testdata/test_search_three_q_tra
index 6c50e10..4b1758d 100644
--- a/server/ctrlsubsonic/testdata/test_search_three_q_tra
+++ b/server/ctrlsubsonic/testdata/test_search_three_q_tra
@@ -33,7 +33,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-2",
@@ -61,7 +62,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-3",
@@ -89,7 +91,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-4",
@@ -117,7 +120,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-5",
@@ -145,7 +149,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-6",
@@ -173,7 +178,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-7",
@@ -201,7 +207,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-8",
@@ -229,7 +236,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-9",
@@ -257,7 +265,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-10",
@@ -285,7 +294,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-11",
@@ -313,7 +323,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-12",
@@ -341,7 +352,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-13",
@@ -369,7 +381,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-14",
@@ -397,7 +410,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-15",
@@ -425,7 +439,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-16",
@@ -453,7 +468,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-17",
@@ -481,7 +497,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-18",
@@ -509,7 +526,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-19",
@@ -537,7 +555,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-20",
@@ -565,7 +584,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
}
]
}
diff --git a/server/ctrlsubsonic/testdata/test_search_two_q_alb b/server/ctrlsubsonic/testdata/test_search_two_q_alb
index 36766a4..41c773e 100644
--- a/server/ctrlsubsonic/testdata/test_search_two_q_alb
+++ b/server/ctrlsubsonic/testdata/test_search_two_q_alb
@@ -19,7 +19,8 @@
"isDir": true,
"isVideo": false,
"parent": "al-2",
- "title": "album-0"
+ "title": "album-0",
+ "musicBrainzId": ""
},
{
"id": "al-4",
@@ -33,7 +34,8 @@
"isDir": true,
"isVideo": false,
"parent": "al-2",
- "title": "album-1"
+ "title": "album-1",
+ "musicBrainzId": ""
},
{
"id": "al-5",
@@ -47,7 +49,8 @@
"isDir": true,
"isVideo": false,
"parent": "al-2",
- "title": "album-2"
+ "title": "album-2",
+ "musicBrainzId": ""
},
{
"id": "al-7",
@@ -61,7 +64,8 @@
"isDir": true,
"isVideo": false,
"parent": "al-6",
- "title": "album-0"
+ "title": "album-0",
+ "musicBrainzId": ""
},
{
"id": "al-8",
@@ -75,7 +79,8 @@
"isDir": true,
"isVideo": false,
"parent": "al-6",
- "title": "album-1"
+ "title": "album-1",
+ "musicBrainzId": ""
},
{
"id": "al-9",
@@ -89,7 +94,8 @@
"isDir": true,
"isVideo": false,
"parent": "al-6",
- "title": "album-2"
+ "title": "album-2",
+ "musicBrainzId": ""
},
{
"id": "al-11",
@@ -103,7 +109,8 @@
"isDir": true,
"isVideo": false,
"parent": "al-10",
- "title": "album-0"
+ "title": "album-0",
+ "musicBrainzId": ""
},
{
"id": "al-12",
@@ -117,7 +124,8 @@
"isDir": true,
"isVideo": false,
"parent": "al-10",
- "title": "album-1"
+ "title": "album-1",
+ "musicBrainzId": ""
},
{
"id": "al-13",
@@ -131,7 +139,8 @@
"isDir": true,
"isVideo": false,
"parent": "al-10",
- "title": "album-2"
+ "title": "album-2",
+ "musicBrainzId": ""
}
]
}
diff --git a/server/ctrlsubsonic/testdata/test_search_two_q_tra b/server/ctrlsubsonic/testdata/test_search_two_q_tra
index 0d16062..a92993d 100644
--- a/server/ctrlsubsonic/testdata/test_search_two_q_tra
+++ b/server/ctrlsubsonic/testdata/test_search_two_q_tra
@@ -29,7 +29,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-2",
@@ -53,7 +54,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-3",
@@ -77,7 +79,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-4",
@@ -101,7 +104,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-5",
@@ -125,7 +129,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-6",
@@ -149,7 +154,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-7",
@@ -173,7 +179,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-8",
@@ -197,7 +204,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-9",
@@ -221,7 +229,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-10",
@@ -245,7 +254,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-11",
@@ -269,7 +279,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-12",
@@ -293,7 +304,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-13",
@@ -317,7 +329,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-14",
@@ -341,7 +354,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-15",
@@ -365,7 +379,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-16",
@@ -389,7 +404,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-17",
@@ -413,7 +429,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-18",
@@ -437,7 +454,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-19",
@@ -461,7 +479,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
},
{
"id": "tr-20",
@@ -485,7 +504,8 @@
"track": 1,
"discNumber": 1,
"type": "music",
- "year": 2021
+ "year": 2021,
+ "musicBrainzId": ""
}
]
}
diff --git a/tags/tagcommon/tagcommmon.go b/tags/tagcommon/tagcommmon.go
index f856013..80beb52 100644
--- a/tags/tagcommon/tagcommmon.go
+++ b/tags/tagcommon/tagcommmon.go
@@ -13,7 +13,7 @@ type Reader interface {
type Info interface {
Title() string
- BrainzID() string
+ BrainzID() string // musicbrainz recording ID
Artist() string
Artists() []string
Album() string
diff --git a/version.txt b/version.txt
index 2a0970c..201a22c 100644
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-0.16.1
+0.16.2