Add `/` to `_` mapping for paths based on tags. (#888)

Closes  #592
This commit is contained in:
Yash Jipkate 2021-03-26 07:18:28 +05:30 committed by GitHub
parent 5abc215270
commit e575825c33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt"
"mime"
"net/http"
"strings"
"github.com/navidrome/navidrome/consts"
"github.com/navidrome/navidrome/model"
@ -151,7 +152,7 @@ func childFromMediaFile(ctx context.Context, mf model.MediaFile) responses.Child
if ok && player.ReportRealPath {
child.Path = mf.Path
} else {
child.Path = fmt.Sprintf("%s/%s/%s.%s", realArtistName(mf), mf.Album, mf.Title, mf.Suffix)
child.Path = fmt.Sprintf("%s/%s/%s.%s", mapSlashToDash(realArtistName(mf)), mapSlashToDash(mf.Album), mapSlashToDash(mf.Title), mf.Suffix)
}
child.DiscNumber = mf.DiscNumber
child.Created = &mf.CreatedAt
@ -184,6 +185,10 @@ func realArtistName(mf model.MediaFile) string {
return mf.Artist
}
func mapSlashToDash(target string) string {
return strings.ReplaceAll(target, "/", "_")
}
func childrenFromMediaFiles(ctx context.Context, mfs model.MediaFiles) []responses.Child {
children := make([]responses.Child, len(mfs))
for i, mf := range mfs {