mirror of
https://github.com/navidrome/navidrome.git
synced 2025-05-07 05:41:07 +03:00
Rendering out leaf nodes for tracks
This commit is contained in:
parent
bd7df889bb
commit
cdb40ecd3e
@ -119,7 +119,10 @@ func (cds *contentDirectoryService) readContainer(o object, host string) (ret []
|
||||
albumResponse, _ := cds.ds.Album(cds.ctx).Get(album)
|
||||
log.Debug(fmt.Sprintf("Album Returned: %+v for %s", albumResponse, album))
|
||||
basePath := path.Join("/Music/Artists", matchResults["Artist"], matchResults["ArtistAlbum"])
|
||||
return cds.doAlbum(albumResponse, basePath, ret, host)
|
||||
|
||||
tracks, _ := cds.ds.MediaFile(cds.ctx).GetAll(model.QueryOptions{Filters: squirrel.Eq{"album_id": albumResponse.ID}})
|
||||
|
||||
return cds.doMediaFiles(tracks, basePath, ret, host)
|
||||
|
||||
} else if matchResults["Artist"] != "" {
|
||||
log.Debug(fmt.Sprintf("Artist Get an Artist: %s", matchResults["Artist"]))
|
||||
@ -152,9 +155,10 @@ func (cds *contentDirectoryService) readContainer(o object, host string) (ret []
|
||||
//TODO
|
||||
} else if matchResults["AlbumTitle"] != "" {
|
||||
log.Debug("AlbumTitle MATCH")
|
||||
x, _ := cds.ds.Album(cds.ctx).Get(matchResults["AlbumTitle"])
|
||||
basePath := "/Music/Albums"
|
||||
return cds.doAlbum(x, basePath, ret, host)
|
||||
albumResponse, _ := cds.ds.Album(cds.ctx).Get(matchResults["AlbumTitle"])
|
||||
basePath := path.Join("/Music/Albums", matchResults["AlbumTitle"])
|
||||
tracks, _ := cds.ds.MediaFile(cds.ctx).GetAll(model.QueryOptions{Filters: squirrel.Eq{"album_id": albumResponse.ID}})
|
||||
return cds.doMediaFiles(tracks, basePath, ret, host)
|
||||
} else {
|
||||
log.Debug("albumRegex else MATCH")
|
||||
indexes, err := cds.ds.Album(cds.ctx).GetAllWithoutGenres()
|
||||
@ -201,7 +205,7 @@ func (cds *contentDirectoryService) readContainer(o object, host string) (ret []
|
||||
}
|
||||
} else if matchResults, err := recentRegex.Groups(o.Path); err == nil {
|
||||
log.Debug("recent MATCH")
|
||||
fmt.Printf("%+v",matchResults)
|
||||
fmt.Printf("%+v", matchResults)
|
||||
} else if matchResults, err := playlistRegex.Groups(o.Path); err == nil {
|
||||
log.Debug("Playlist MATCH")
|
||||
if _, exists := matchResults["PlaylistTrack"]; exists {
|
||||
@ -250,6 +254,19 @@ func (cds *contentDirectoryService) readContainer(o object, host string) (ret []
|
||||
return
|
||||
}
|
||||
|
||||
func (cds *contentDirectoryService) doMediaFiles(tracks model.MediaFiles, basePath string, ret []interface{}, host string) ([]interface{}, error) {
|
||||
//TODO flesh object out with actually useful metadata about the track
|
||||
for _, track := range tracks {
|
||||
child := object{
|
||||
Path: path.Join(basePath, track.Title),
|
||||
Id: path.Join(basePath, track.ID),
|
||||
}
|
||||
ret = append(ret, cds.cdsObjectToUpnpavObject(child, false, host))
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (cds *contentDirectoryService) doAlbum(album *model.Album, basepath string, ret []interface{}, host string) ([]interface{}, error) {
|
||||
log.Debug(fmt.Sprintf("TODO: doAlbum Called with : '%+v', '%s'", album, basepath))
|
||||
return ret, nil
|
||||
@ -257,7 +274,7 @@ func (cds *contentDirectoryService) doAlbum(album *model.Album, basepath string,
|
||||
|
||||
func (cds *contentDirectoryService) doAlbums(albums model.Albums, basepath string, ret []interface{}, host string) ([]interface{}, error) {
|
||||
for _, album := range albums {
|
||||
child := object {
|
||||
child := object{
|
||||
Path: path.Join(basepath, album.Name),
|
||||
Id: path.Join(basepath, album.ID),
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user