Revert "Return absolute paths in Subsonic API responses"
This reverts commit 338cbacb
This commit is contained in:
parent
df05760769
commit
a541afbfba
|
@ -2,8 +2,10 @@ package engine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/deluan/navidrome/consts"
|
||||||
"github.com/deluan/navidrome/model"
|
"github.com/deluan/navidrome/model"
|
||||||
"github.com/deluan/navidrome/model/request"
|
"github.com/deluan/navidrome/model/request"
|
||||||
)
|
)
|
||||||
|
@ -40,6 +42,7 @@ type Entry struct {
|
||||||
PlayerName string
|
PlayerName string
|
||||||
AlbumCount int
|
AlbumCount int
|
||||||
BookmarkPosition int64
|
BookmarkPosition int64
|
||||||
|
AbsolutePath string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Entries []Entry
|
type Entries []Entry
|
||||||
|
@ -101,7 +104,11 @@ func FromMediaFile(mf *model.MediaFile) Entry {
|
||||||
e.CoverArt = "al-" + mf.AlbumID
|
e.CoverArt = "al-" + mf.AlbumID
|
||||||
}
|
}
|
||||||
e.ContentType = mf.ContentType()
|
e.ContentType = mf.ContentType()
|
||||||
e.Path = mf.Path
|
e.AbsolutePath = mf.Path
|
||||||
|
// Creates a "pseudo" Path, to avoid sending absolute paths to the client
|
||||||
|
if mf.Path != "" {
|
||||||
|
e.Path = fmt.Sprintf("%s/%s/%s.%s", realArtistName(mf), mf.Album, mf.Title, mf.Suffix)
|
||||||
|
}
|
||||||
e.DiscNumber = mf.DiscNumber
|
e.DiscNumber = mf.DiscNumber
|
||||||
e.Created = mf.CreatedAt
|
e.Created = mf.CreatedAt
|
||||||
e.AlbumId = mf.AlbumID
|
e.AlbumId = mf.AlbumID
|
||||||
|
@ -116,6 +123,17 @@ func FromMediaFile(mf *model.MediaFile) Entry {
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func realArtistName(mf *model.MediaFile) string {
|
||||||
|
switch {
|
||||||
|
case mf.Compilation:
|
||||||
|
return consts.VariousArtists
|
||||||
|
case mf.AlbumArtist != "":
|
||||||
|
return mf.AlbumArtist
|
||||||
|
}
|
||||||
|
|
||||||
|
return mf.Artist
|
||||||
|
}
|
||||||
|
|
||||||
func FromAlbums(albums model.Albums) Entries {
|
func FromAlbums(albums model.Albums) Entries {
|
||||||
entries := make(Entries, len(albums))
|
entries := make(Entries, len(albums))
|
||||||
for i := range albums {
|
for i := range albums {
|
||||||
|
|
Loading…
Reference in New Issue