sentriz / gonic

music streaming server / free-software subsonic server API implementation
ircs://irc.libera.chat/#gonic
GNU General Public License v3.0
1.5k stars 105 forks source link

Including additional fields in Search3 for albums & tracks #422

Closed ry-gon closed 6 months ago

ry-gon commented 7 months ago

Hello, thank you for your work on gonic, I switched to using it some time ago and it's been great :)

One problem - ideally when searching for an artist name, I would like to see all albums which include a track by that artist and all individual tracks by that artist. To my understanding this is the behavior in services like Spotify/Youtube music, also Navidrome. In the context of gonic, I find this particularly useful in the case where I want to find all tracks for an artist that doesn't have their own entry in the artist table (i.e. an artist included in compilation albums, only listed in the track_artist tag).

I figured I'd ask here first if this behavior sounds desirable. If it does, the following diff seems to be working fine for me:

index 1f45247..414d88a 100644
--- a/server/ctrlsubsonic/handlers_by_tags.go
+++ b/server/ctrlsubsonic/handlers_by_tags.go
@@ -252,14 +252,16 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
    // search albums
    var albums []*db.Album
    q = c.dbc.
+       Group("albums.id").
        Preload("Artists").
        Preload("Genres").
        Preload("AlbumStar", "user_id=?", user.ID).
        Preload("AlbumRating", "user_id=?", user.ID)
    for _, s := range queries {
-       q = q.Where(`tag_title LIKE ? OR tag_title_u_dec LIKE ?`, s, s)
+       q = q.Where(`albums.tag_title LIKE ? OR albums.tag_title_u_dec LIKE ? OR albums.tag_album_artist LIKE ? OR tracks.tag_track_artist LIKE ? OR tracks.tag_title LIKE ?`, s, s, s, s, s)
    }
    q = q.
+       Joins("JOIN tracks ON tracks.album_id=albums.id").
        Offset(params.GetOrInt("albumOffset", 0)).
        Limit(params.GetOrInt("albumCount", 20))
    if m := getMusicFolder(c.musicPaths, params); m != "" {
@@ -282,7 +284,7 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
        Preload("TrackStar", "user_id=?", user.ID).
        Preload("TrackRating", "user_id=?", user.ID)
    for _, s := range queries {
-       q = q.Where(`tracks.tag_title LIKE ? OR tracks.tag_title_u_dec LIKE ?`, s, s)
+       q = q.Where(`tracks.tag_title LIKE ? OR tracks.tag_title_u_dec LIKE ? OR tracks.tag_track_artist LIKE ?`, s, s, s)
    }
    q = q.Offset(params.GetOrInt("songOffset", 0)).
        Limit(params.GetOrInt("songCount", 20))
-- 
2.43.0
sentriz commented 7 months ago

i'm not entirely sure about returning albums based on artist appearances. maybe it's redudant if we already update to search artist by artist? in most clients you can click on the relevant album from the track results.

for example i search for artist X who only appears on a compilation album, see the track in the track list, click on the track's album

ry-gon commented 7 months ago

My reasoning for including the albums is that there's no existing way to list all the albums for an appearing artist (as you'd normally see on a regular artist view), and it can be quicker to find the right album by recognizing the art, or just be more convenient to browse if you've forgotten which albums that artist appeared on. Seeing a track in the track list and going to the album from there does work fine, but on clients like e.g. DSub the track list doesn't include any information on what that album is (without an extra two clicks to show details) so it might take a few tries to find the album you're looking for.

I think it provides value, but can see how it might clutter the results a bit

sentriz commented 6 months ago

hey, i just got around for trying this out for a couple days. and at least to my taste and library, the search is too cluttered to find anything. i think i'd close this for now. but i am still not opposed to futher changes

perhaps something like search both track & artist fields for the tracks results (maybe only matching on artist when that artist is a track-only artist such as compilation albums)

on top of that it should be the clients resposibilty to generate a clickable link back to the album - like how airsonic-refix does

thanks!

ry-gon commented 6 months ago

I see. Thanks for trying it out!