Skip to content

Commit

Permalink
initialise slices for browse-by-tag children
Browse files Browse the repository at this point in the history
  • Loading branch information
sentriz committed Nov 11, 2023
1 parent 5022500 commit 2bf6231
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
46 changes: 25 additions & 21 deletions server/ctrlsubsonic/spec/construct_by_tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ import (

func NewAlbumByTags(a *db.Album, artists []*db.Artist) *Album {
ret := &Album{
Created: a.CreatedAt,
ID: a.SID(),
Created: a.CreatedAt,
Artists: []*ArtistRef{},
DisplayArtist: a.TagAlbumArtist,
Title: a.TagTitle,
Album: a.TagTitle,
Name: a.TagTitle,
Title: a.TagTitle,
Year: a.TagYear,
TrackCount: a.ChildCount,
Duration: a.Duration,
DisplayArtist: a.TagAlbumArtist,
Genres: []*GenreRef{},
Year: a.TagYear,
Tracks: []*TrackChild{},
AverageRating: formatRating(a.AverageRating),
}
if a.Cover != "" {
Expand Down Expand Up @@ -54,29 +57,29 @@ func NewAlbumByTags(a *db.Album, artists []*db.Artist) *Album {
func NewTrackByTags(t *db.Track, album *db.Album) *TrackChild {
ret := &TrackChild{
ID: t.SID(),
Album: album.TagTitle,
AlbumID: album.SID(),
Artist: t.TagTrackArtist,
Artists: []*ArtistRef{},
DisplayArtist: t.TagTrackArtist,
AlbumArtists: []*ArtistRef{},
AlbumDisplayArtist: album.TagAlbumArtist,
Bitrate: t.Bitrate,
ContentType: t.MIME(),
Suffix: formatExt(t.Ext()),
ParentID: t.AlbumSID(),
CreatedAt: t.CreatedAt,
Duration: t.Length,
Genres: []*GenreRef{},
ParentID: t.AlbumSID(),
Path: filepath.Join(album.LeftPath, album.RightPath, t.Filename),
Size: t.Size,
Suffix: formatExt(t.Ext()),
Title: t.TagTitle,
Artist: t.TagTrackArtist,
DisplayArtist: t.TagTrackArtist,
AlbumDisplayArtist: album.TagAlbumArtist,
TrackNumber: t.TagTrackNumber,
DiscNumber: t.TagDiscNumber,
Path: filepath.Join(
album.LeftPath,
album.RightPath,
t.Filename,
),
Album: album.TagTitle,
AlbumID: album.SID(),
Duration: t.Length,
Bitrate: t.Bitrate,
Type: "music",
Year: album.TagYear,
AverageRating: formatRating(t.AverageRating),
Type: "music",
Year: album.TagYear,
AverageRating: formatRating(t.AverageRating),
TranscodeMeta: TranscodeMeta{},
}
if album.Cover != "" {
ret.CoverID = album.SID()
Expand Down Expand Up @@ -113,6 +116,7 @@ func NewArtistByTags(a *db.Artist) *Artist {
ID: a.SID(),
Name: a.Name,
AlbumCount: a.AlbumCount,
Albums: []*Album{},
AverageRating: formatRating(a.AverageRating),
}
if a.Info != nil && a.Info.ImageURL != "" {
Expand Down
2 changes: 1 addition & 1 deletion server/ctrlsubsonic/testdata/test_get_album_without_cover
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"id": "al-2",
"created": "2019-11-30T00:00:00Z",
"artist": "",
"artists": null,
"artists": [],
"displayArtist": "",
"title": "",
"album": "",
Expand Down

0 comments on commit 2bf6231

Please sign in to comment.