We need to be able to pass the artist and album etc id rather than the

name, so we need to expose that back on the SOAP interface
This commit is contained in:
Rob Emery 2025-01-11 18:12:10 +00:00
parent 96503694f3
commit 23bb6ea712

View File

@ -111,16 +111,21 @@ func (cds *contentDirectoryService) readContainer(o object, host string) (ret []
return cds.doFiles(ret, o.Path, host) return cds.doFiles(ret, o.Path, host)
case "Artists": case "Artists":
indexes, err := cds.ds.Artist(cds.ctx).GetIndex() indexes, err := cds.ds.Artist(cds.ctx).GetIndex()
log.Debug(fmt.Sprintf("Artist indexes: %+v", indexes))
if err != nil { if err != nil {
fmt.Printf("Error retrieving Indexes: %+v", err) fmt.Printf("Error retrieving Indexes: %+v", err)
return nil, err return nil, err
} }
for indexItem := range indexes { for letterIndex := range indexes {
for artist := range indexes[letterIndex].Artists {
artistId := indexes[letterIndex].Artists[artist].ID
child := object{ child := object{
path.Join(o.Path, indexes[indexItem].Artists[0].Name), //TODO handle multiple artists here, fold it into some sort of unique list Path: path.Join(o.Path, indexes[letterIndex].Artists[artist].Name),
Id: artistId,
} }
ret = append(ret, cds.cdsObjectToUpnpavObject(child, true, host)) ret = append(ret, cds.cdsObjectToUpnpavObject(child, true, host))
} }
}
return ret, nil return ret, nil
case "Albums": case "Albums":
indexes, err := cds.ds.Album(cds.ctx).GetAllWithoutGenres() indexes, err := cds.ds.Album(cds.ctx).GetAllWithoutGenres()
@ -130,7 +135,8 @@ func (cds *contentDirectoryService) readContainer(o object, host string) (ret []
} }
for indexItem := range indexes { for indexItem := range indexes {
child := object{ child := object{
path.Join(o.Path, indexes[indexItem].Name), Path: path.Join(o.Path, indexes[indexItem].Name),
Id: indexes[indexItem].ID,
} }
ret = append(ret, cds.cdsObjectToUpnpavObject(child, true, host)) ret = append(ret, cds.cdsObjectToUpnpavObject(child, true, host))
} }
@ -143,7 +149,8 @@ func (cds *contentDirectoryService) readContainer(o object, host string) (ret []
} }
for indexItem := range indexes { for indexItem := range indexes {
child := object{ child := object{
path.Join(o.Path, indexes[indexItem].Name), Path: path.Join(o.Path, indexes[indexItem].Name),
Id: indexes[indexItem].ID,
} }
ret = append(ret, cds.cdsObjectToUpnpavObject(child, true, host)) ret = append(ret, cds.cdsObjectToUpnpavObject(child, true, host))
} }
@ -156,7 +163,8 @@ func (cds *contentDirectoryService) readContainer(o object, host string) (ret []
} }
for indexItem := range indexes { for indexItem := range indexes {
child := object{ child := object{
path.Join(o.Path, indexes[indexItem].Name), Path: path.Join(o.Path, indexes[indexItem].Name),
Id: indexes[indexItem].ID,
} }
ret = append(ret, cds.cdsObjectToUpnpavObject(child, true, host)) ret = append(ret, cds.cdsObjectToUpnpavObject(child, true, host))
} }
@ -169,13 +177,17 @@ func (cds *contentDirectoryService) readContainer(o object, host string) (ret []
case "Files": case "Files":
return cds.doFiles(ret, o.Path, host) return cds.doFiles(ret, o.Path, host)
case "Artists": case "Artists":
x, xerr := cds.ds.Artist(cds.ctx).Get(pathComponents[3])
log.Debug(x, xerr)
case "Albums": case "Albums":
x, xerr := cds.ds.Album(cds.ctx).Get(pathComponents[3])
log.Debug(x, xerr)
case "Genres": case "Genres":
x, xerr := cds.ds.Album(cds.ctx).Get(pathComponents[3])
log.Debug(x, xerr)
case "Playlists": case "Playlists":
x, xerr := cds.ds.Playlist(cds.ctx).Get(pathComponents[3])
log.Debug(x, xerr)
} }
} }
} }
@ -195,7 +207,8 @@ func (cds *contentDirectoryService) doFiles(ret []interface{}, oPath string, hos
files, _ := os.ReadDir(localFilePath) files, _ := os.ReadDir(localFilePath)
for _, file := range files { for _, file := range files {
child := object{ child := object{
path.Join(oPath, file.Name()), Path: path.Join(oPath, file.Name()),
Id: path.Join(oPath, file.Name()),
} }
ret = append(ret, cds.cdsObjectToUpnpavObject(child, file.IsDir(), host)) ret = append(ret, cds.cdsObjectToUpnpavObject(child, file.IsDir(), host))
} }
@ -311,6 +324,7 @@ func (cds *contentDirectoryService) Handle(action string, argsXML []byte, r *htt
// Represents a ContentDirectory object. // Represents a ContentDirectory object.
type object struct { type object struct {
Path string // The cleaned, absolute path for the object relative to the server. Path string // The cleaned, absolute path for the object relative to the server.
Id string
} }
// Returns the actual local filesystem path for the object. // Returns the actual local filesystem path for the object.