mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Add config option to show album participations under artists in Subsonic clients
This commit is contained in:
parent
8ae0bcb459
commit
136d5f9a83
3 changed files with 75 additions and 69 deletions
|
@ -141,15 +141,12 @@ func (api *Router) GetArtist(r *http.Request) (*responses.Subsonic, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
albums, err := api.ds.Album(ctx).GetAllWithoutGenres(filter.AlbumsByArtistID(id))
|
||||
if err != nil {
|
||||
log.Error(ctx, "Error retrieving albums by artist", "id", id, "name", artist.Name, err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response := newResponse()
|
||||
response.ArtistWithAlbumsID3 = api.buildArtist(r, artist, albums)
|
||||
return response, nil
|
||||
response.ArtistWithAlbumsID3, err = api.buildArtist(r, artist)
|
||||
if err != nil {
|
||||
log.Error(ctx, "Error retrieving albums by artist", "id", artist.ID, "name", artist.Name, err)
|
||||
}
|
||||
return response, err
|
||||
}
|
||||
|
||||
func (api *Router) GetAlbum(r *http.Request) (*responses.Subsonic, error) {
|
||||
|
@ -370,11 +367,18 @@ func (api *Router) buildArtistDirectory(ctx context.Context, artist *model.Artis
|
|||
return dir, nil
|
||||
}
|
||||
|
||||
func (api *Router) buildArtist(r *http.Request, artist *model.Artist, albums model.Albums) *responses.ArtistWithAlbumsID3 {
|
||||
func (api *Router) buildArtist(r *http.Request, artist *model.Artist) (*responses.ArtistWithAlbumsID3, error) {
|
||||
ctx := r.Context()
|
||||
a := &responses.ArtistWithAlbumsID3{}
|
||||
a.ArtistID3 = toArtistID3(r, *artist)
|
||||
|
||||
albums, err := api.ds.Album(ctx).GetAllWithoutGenres(filter.AlbumsByArtistID(artist.ID))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
a.Album = childrenFromAlbums(r.Context(), albums)
|
||||
return a
|
||||
return a, nil
|
||||
}
|
||||
|
||||
func (api *Router) buildAlbumDirectory(ctx context.Context, album *model.Album) (*responses.Directory, error) {
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package filter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/navidrome/navidrome/conf"
|
||||
"github.com/navidrome/navidrome/model"
|
||||
)
|
||||
|
||||
|
@ -49,9 +51,15 @@ func AlbumsByGenre(genre string) Options {
|
|||
}
|
||||
|
||||
func AlbumsByArtistID(artistId string) Options {
|
||||
var filters squirrel.Sqlizer
|
||||
if conf.Server.SubsonicArtistParticipations {
|
||||
filters = squirrel.Like{"all_artist_ids": fmt.Sprintf("%%%s%%", artistId)}
|
||||
} else {
|
||||
filters = squirrel.Eq{"album_artist_id": artistId}
|
||||
}
|
||||
return Options{
|
||||
Sort: "max_year",
|
||||
Filters: squirrel.Eq{"album_artist_id": artistId},
|
||||
Filters: filters,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue