Skip to content

Commit

Permalink
Reimplement getAlbum without using directory entries
Browse files Browse the repository at this point in the history
  • Loading branch information
ironsmile committed May 17, 2024
1 parent 81dee3b commit facec20
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/webserver/subsonic/get_album.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,28 @@ func (s *subsonic) getAlbum(w http.ResponseWriter, req *http.Request) {

albumID := toAlbumDBID(subsonicID)

entry, err := s.getAlbumDirectory(req, albumID)
album, err := s.lib.GetAlbum(req.Context(), albumID)
if err != nil {
resp := responseError(errCodeGeneric, err.Error())
encodeResponse(w, req, resp)
return
}

artEtr := xsdAlbumWithSongsID3{
xsdAlbumID3: xsdAlbumID3{
ID: entry.ID,
Artist: entry.Artist,
ArtistID: entry.ParentID,
Name: entry.Name,
SongCount: entry.SongCount,
CoverArtID: entry.CoverArtID,
Created: s.lastModified,
Duration: entry.Duration,
PlayCount: entry.PlayCount,
Starred: entry.Starred,
},
Children: entry.Children,
alEntry := xsdAlbumWithSongsID3{
xsdAlbumID3: dbAlbumToAlbumID3Entry(album),
}

tracks := s.lib.GetAlbumFiles(albumID)
for _, track := range tracks {
alEntry.Children = append(alEntry.Children, trackToChild(
track,
s.getLastModified(),
))
}

resp := albumResponse{
baseResponse: responseOk(),
Album: artEtr,
Album: alEntry,
}

encodeResponse(w, req, resp)
Expand Down

0 comments on commit facec20

Please sign in to comment.