fix(subsonic): find lyrics by artist or albumartist (#4093)
* find artist by multivalued exact match, instead of 'artist' field * check if lyrics are not empty * refactor(filters): rename function to better reflect its purpose Signed-off-by: Deluan <deluan@navidrome.org> --------- Signed-off-by: Deluan <deluan@navidrome.org> Co-authored-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -108,12 +108,19 @@ func SongsByRandom(genre string, fromYear, toYear int) Options {
|
|||||||
return addDefaultFilters(options)
|
return addDefaultFilters(options)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SongWithArtistTitle(artist, title string) Options {
|
func SongWithLyrics(artist, title string) Options {
|
||||||
return addDefaultFilters(Options{
|
return addDefaultFilters(Options{
|
||||||
Sort: "updated_at",
|
Sort: "updated_at",
|
||||||
Order: "desc",
|
Order: "desc",
|
||||||
Max: 1,
|
Max: 1,
|
||||||
Filters: And{Eq{"artist": artist, "title": title}},
|
Filters: And{
|
||||||
|
Eq{"title": title},
|
||||||
|
NotEq{"lyrics": "[]"},
|
||||||
|
Or{
|
||||||
|
persistence.Exists("json_tree(participants, '$.albumartist')", Eq{"value": artist}),
|
||||||
|
persistence.Exists("json_tree(participants, '$.artist')", Eq{"value": artist}),
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ func (api *Router) GetLyrics(r *http.Request) (*responses.Subsonic, error) {
|
|||||||
response := newResponse()
|
response := newResponse()
|
||||||
lyricsResponse := responses.Lyrics{}
|
lyricsResponse := responses.Lyrics{}
|
||||||
response.Lyrics = &lyricsResponse
|
response.Lyrics = &lyricsResponse
|
||||||
mediaFiles, err := api.ds.MediaFile(r.Context()).GetAll(filter.SongWithArtistTitle(artist, title))
|
mediaFiles, err := api.ds.MediaFile(r.Context()).GetAll(filter.SongWithLyrics(artist, title))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
Reference in New Issue
Block a user