use consistent case for indexes
This commit is contained in:
@@ -23,14 +23,14 @@ func (c *Controller) GetIndexes(w http.ResponseWriter, r *http.Request) {
|
||||
c.DB.
|
||||
Where("parent_id = 1").
|
||||
Find(&folders)
|
||||
indexMap := make(map[rune]*subsonic.Index)
|
||||
indexMap := make(map[string]*subsonic.Index)
|
||||
indexes := []*subsonic.Index{}
|
||||
for _, folder := range folders {
|
||||
i := indexOf(folder.RightPath)
|
||||
i := indexOf(folder.RightPath[0])
|
||||
index, ok := indexMap[i]
|
||||
if !ok {
|
||||
index = &subsonic.Index{
|
||||
Name: string(i),
|
||||
Name: i,
|
||||
Artists: []*subsonic.Artist{},
|
||||
}
|
||||
indexMap[i] = index
|
||||
|
||||
@@ -15,14 +15,14 @@ import (
|
||||
func (c *Controller) GetArtists(w http.ResponseWriter, r *http.Request) {
|
||||
var artists []*model.Artist
|
||||
c.DB.Find(&artists)
|
||||
indexMap := make(map[rune]*subsonic.Index)
|
||||
indexMap := make(map[string]*subsonic.Index)
|
||||
indexes := &subsonic.Artists{}
|
||||
for _, artist := range artists {
|
||||
i := indexOf(artist.Name)
|
||||
i := indexOf(artist.Name[0])
|
||||
index, ok := indexMap[i]
|
||||
if !ok {
|
||||
index = &subsonic.Index{
|
||||
Name: string(i),
|
||||
Name: i,
|
||||
Artists: []*subsonic.Artist{},
|
||||
}
|
||||
indexMap[i] = index
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
"unicode"
|
||||
@@ -18,13 +19,13 @@ import (
|
||||
"github.com/sentriz/gonic/server/subsonic"
|
||||
)
|
||||
|
||||
func indexOf(s string) rune {
|
||||
first := string(s[0])
|
||||
c := rune(unidecode.Unidecode(first)[0])
|
||||
if !unicode.IsLetter(c) {
|
||||
return '#'
|
||||
func indexOf(in byte) string {
|
||||
lower := strings.ToLower(string(in))
|
||||
decode := unidecode.Unidecode(lower)
|
||||
if !unicode.IsLetter(rune(decode[0])) {
|
||||
return "#"
|
||||
}
|
||||
return c
|
||||
return decode
|
||||
}
|
||||
|
||||
func (c *Controller) Stream(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "A",
|
||||
"name": "a",
|
||||
"artist": [
|
||||
{
|
||||
"id": 1,
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "A",
|
||||
"name": "a",
|
||||
"artist": [
|
||||
{
|
||||
"id": 2,
|
||||
|
||||
Reference in New Issue
Block a user