use OpenSubsonic extensions in SubsonicMediaProvider
This commit is contained in:
@@ -276,6 +276,18 @@ func toTrack(ch *subsonic.Child) *mediaprovider.Track {
|
||||
if ch == nil {
|
||||
return nil
|
||||
}
|
||||
var artistNames, artistIDs []string
|
||||
if len(ch.Artists) > 0 {
|
||||
// OpenSubsonic extension
|
||||
for _, a := range ch.Artists {
|
||||
artistIDs = append(artistIDs, a.ID)
|
||||
artistNames = append(artistNames, a.Name)
|
||||
}
|
||||
} else {
|
||||
artistNames = append(artistNames, ch.Artist)
|
||||
artistIDs = append(artistIDs, ch.ArtistID)
|
||||
}
|
||||
|
||||
return &mediaprovider.Track{
|
||||
ID: ch.ID,
|
||||
CoverArtID: ch.CoverArt,
|
||||
@@ -285,8 +297,8 @@ func toTrack(ch *subsonic.Child) *mediaprovider.Track {
|
||||
TrackNumber: ch.Track,
|
||||
DiscNumber: ch.DiscNumber,
|
||||
Genre: ch.Genre,
|
||||
ArtistIDs: []string{ch.ArtistID},
|
||||
ArtistNames: []string{ch.Artist},
|
||||
ArtistIDs: artistIDs,
|
||||
ArtistNames: artistNames,
|
||||
Album: ch.Album,
|
||||
AlbumID: ch.AlbumID,
|
||||
Year: ch.Year,
|
||||
@@ -309,15 +321,37 @@ func toAlbum(al *subsonic.AlbumID3) *mediaprovider.Album {
|
||||
}
|
||||
|
||||
func fillAlbum(subAlbum *subsonic.AlbumID3, album *mediaprovider.Album) {
|
||||
var artistNames, artistIDs []string
|
||||
if len(subAlbum.Artists) > 0 {
|
||||
// OpenSubsonic extension
|
||||
for _, a := range subAlbum.Artists {
|
||||
artistIDs = append(artistIDs, a.ID)
|
||||
artistNames = append(artistNames, a.Name)
|
||||
}
|
||||
} else {
|
||||
artistNames = append(artistNames, subAlbum.Artist)
|
||||
artistIDs = append(artistIDs, subAlbum.ArtistID)
|
||||
}
|
||||
|
||||
var genres []string
|
||||
if len(subAlbum.Genres) > 0 {
|
||||
// OpenSubsonic extension
|
||||
for _, g := range subAlbum.Genres {
|
||||
genres = append(genres, g.Name)
|
||||
}
|
||||
} else {
|
||||
genres = append(genres, subAlbum.Genre)
|
||||
}
|
||||
|
||||
album.ID = subAlbum.ID
|
||||
album.CoverArtID = subAlbum.CoverArt
|
||||
album.Name = subAlbum.Name
|
||||
album.Duration = subAlbum.Duration
|
||||
album.ArtistIDs = []string{subAlbum.ArtistID}
|
||||
album.ArtistNames = []string{subAlbum.Artist}
|
||||
album.ArtistIDs = artistIDs
|
||||
album.ArtistNames = artistNames
|
||||
album.Year = subAlbum.Year
|
||||
album.TrackCount = subAlbum.SongCount
|
||||
album.Genres = []string{subAlbum.Genre}
|
||||
album.Genres = genres
|
||||
album.Favorite = !subAlbum.Starred.IsZero()
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ require (
|
||||
fyne.io/x/fyne v0.0.0-20230611151101-afdcd6b92cf3
|
||||
github.com/20after4/configdir v0.1.1
|
||||
github.com/dweymouth/go-mpv v0.0.0-20230406003141-7f1858e503ee
|
||||
github.com/dweymouth/go-subsonic v0.0.0-20231013011542-14b66c5a1fff
|
||||
github.com/dweymouth/go-subsonic v0.0.0-20231014003317-6a0c88db38ce
|
||||
github.com/fsnotify/fsnotify v1.6.0
|
||||
github.com/godbus/dbus/v5 v5.1.0
|
||||
github.com/google/uuid v1.3.0
|
||||
|
||||
@@ -78,8 +78,8 @@ github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20231019154213-5f32d36c2968 h1:RYHUvyo
|
||||
github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20231019154213-5f32d36c2968/go.mod h1:X2+NrR+62mvAiAt2fwKT7035zQsE77KVV1NlvWo4vW8=
|
||||
github.com/dweymouth/go-mpv v0.0.0-20230406003141-7f1858e503ee h1:ZGyJ6wp7CAfT31BugypcF/TPKEy2RrGR9JFq1JOjOpY=
|
||||
github.com/dweymouth/go-mpv v0.0.0-20230406003141-7f1858e503ee/go.mod h1:Ov0ieN90M7i+0k3OxhA/g1dozGs+UcPHDsMKqPgRDk0=
|
||||
github.com/dweymouth/go-subsonic v0.0.0-20231013011542-14b66c5a1fff h1:71TfIg5TMXMi9rGQYFhW8Gvs/GmBGK9O2gSmgzYXl4I=
|
||||
github.com/dweymouth/go-subsonic v0.0.0-20231013011542-14b66c5a1fff/go.mod h1:fUez6NFiEJiQTZizZ1BThZr5GJXAbigzGYjEPNm4tdI=
|
||||
github.com/dweymouth/go-subsonic v0.0.0-20231014003317-6a0c88db38ce h1:R12c/hE0licao74iAu2YDPJNI0jhGNuTyzmu3dMgFHE=
|
||||
github.com/dweymouth/go-subsonic v0.0.0-20231014003317-6a0c88db38ce/go.mod h1:fUez6NFiEJiQTZizZ1BThZr5GJXAbigzGYjEPNm4tdI=
|
||||
github.com/eclipse/paho.mqtt.golang v1.3.5/go.mod h1:eTzb4gxwwyWpqBUHGQZ4ABAV7+Jgm1PklsYT/eo8Hcc=
|
||||
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=
|
||||
|
||||
Reference in New Issue
Block a user