From fdd449584b78d0317c8afedfb0bb67e80ea82969 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Thu, 25 Jul 2024 17:46:36 -0700 Subject: [PATCH] Fix #432: use artist sort name if present to sort --- backend/mediaprovider/subsonic/artistiterator.go | 8 +++++++- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/backend/mediaprovider/subsonic/artistiterator.go b/backend/mediaprovider/subsonic/artistiterator.go index 21a9d2c..987795b 100644 --- a/backend/mediaprovider/subsonic/artistiterator.go +++ b/backend/mediaprovider/subsonic/artistiterator.go @@ -49,7 +49,13 @@ func (s *subsonicMediaProvider) IterateArtists(sortOrder string, filter mediapro func(artists []*subsonic.ArtistID3) []*subsonic.ArtistID3 { c := collate.New(language.English, collate.Loose) slices.SortFunc(artists, func(a, b *subsonic.ArtistID3) int { - return c.CompareString(a.Name, b.Name) + sortStr := func(a *subsonic.ArtistID3) string { + if a.SortName != "" { + return a.SortName + } + return a.Name + } + return c.CompareString(sortStr(a), sortStr(b)) }) return artists }, diff --git a/go.mod b/go.mod index ed2e6f6..277e543 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/dweymouth/fyne-lyrics v0.0.0-20240528234907-15eee7ce5e64 github.com/dweymouth/go-jellyfin v0.0.0-20240517151952-5ceca61cb645 github.com/dweymouth/go-mpv v0.0.0-20240724002347-c5e5b36f1bbf - github.com/dweymouth/go-subsonic v0.0.0-20240721002411-f2df85be66f1 + github.com/dweymouth/go-subsonic v0.0.0-20240726004217-2e8e348ad417 github.com/godbus/dbus/v5 v5.1.0 github.com/google/uuid v1.3.0 github.com/pelletier/go-toml/v2 v2.0.8 diff --git a/go.sum b/go.sum index 0010d1e..9b4d4ce 100644 --- a/go.sum +++ b/go.sum @@ -85,8 +85,8 @@ github.com/dweymouth/go-jellyfin v0.0.0-20240517151952-5ceca61cb645 h1:KzqSaQwG3 github.com/dweymouth/go-jellyfin v0.0.0-20240517151952-5ceca61cb645/go.mod h1:fcUagHBaQnt06GmBAllNE0J4O/7064zXRWdqnTTtVjI= github.com/dweymouth/go-mpv v0.0.0-20240724002347-c5e5b36f1bbf h1:QVjXWx7XGkSPOCEu5EL9QVY3fkdDSnG5KEkok5o1svM= github.com/dweymouth/go-mpv v0.0.0-20240724002347-c5e5b36f1bbf/go.mod h1:Ov0ieN90M7i+0k3OxhA/g1dozGs+UcPHDsMKqPgRDk0= -github.com/dweymouth/go-subsonic v0.0.0-20240721002411-f2df85be66f1 h1:Ibjafpy6ds3DtmX43hxsnqiBR7mBcihl4IRq+jwlyJA= -github.com/dweymouth/go-subsonic v0.0.0-20240721002411-f2df85be66f1/go.mod h1:OWtcumdQsan8uM6wmx6PqKhldaCthH10CQ+vb+94kzo= +github.com/dweymouth/go-subsonic v0.0.0-20240726004217-2e8e348ad417 h1:VVVqQvHwm2K3+h8z4Tw3jYIDKETpEMR++XICdJDx0pE= +github.com/dweymouth/go-subsonic v0.0.0-20240726004217-2e8e348ad417/go.mod h1:OWtcumdQsan8uM6wmx6PqKhldaCthH10CQ+vb+94kzo= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=