Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Including additional fields in Search3 for albums & tracks #422

Closed
ry-gon opened this issue Dec 4, 2023 · 4 comments
Closed

Including additional fields in Search3 for albums & tracks #422

ry-gon opened this issue Dec 4, 2023 · 4 comments

Comments

@ry-gon
Copy link

ry-gon commented Dec 4, 2023

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
Copy link
Owner

sentriz commented Dec 5, 2023

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
Copy link
Author

ry-gon commented Dec 5, 2023

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
Copy link
Owner

sentriz commented Dec 24, 2023

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!

@sentriz sentriz closed this as completed Dec 24, 2023
@ry-gon
Copy link
Author

ry-gon commented Dec 26, 2023

I see. Thanks for trying it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants