use sub dir model for artist in folder search

This commit is contained in:
sentriz
2019-05-28 17:02:27 +01:00
parent 8429c980f9
commit 47c4743682
3 changed files with 36 additions and 30 deletions

View File

@@ -3,6 +3,7 @@ package handler
import (
"fmt"
"net/http"
"strings"
"github.com/jinzhu/gorm"
@@ -82,12 +83,7 @@ func (c *Controller) GetMusicDirectory(w http.ResponseWriter, r *http.Request) {
//
// respond section
sub := subsonic.NewResponse()
sub.Directory = &subsonic.Directory{
ID: folder.ID,
Parent: folder.ParentID,
Name: folder.Name,
Children: childrenObj,
}
sub.Directory = makeDirFromFolder(&folder, childrenObj)
respond(w, r, sub)
}
@@ -153,6 +149,7 @@ func (c *Controller) SearchTwo(w http.ResponseWriter, r *http.Request) {
respondError(w, r, 10, "please provide a `query` parameter")
return
}
query = strings.TrimSuffix(query, "*")
query = fmt.Sprintf("%%%s%%", query)
results := &subsonic.SearchResultTwo{}
//
@@ -165,7 +162,7 @@ func (c *Controller) SearchTwo(w http.ResponseWriter, r *http.Request) {
Find(&artists)
for _, a := range artists {
results.Artists = append(results.Artists,
makeChildFromFolder(&a, nil))
makeDirFromFolder(&a, nil))
}
//
// search "albums"