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