(partial) Fix #742: add Genre, Album Artist, File Type columns

This commit is contained in:
zacaj
2025-11-11 03:36:33 +00:00
parent b0d918b93e
commit 7058f74d42
7 changed files with 176 additions and 96 deletions
+33 -30
View File
@@ -123,36 +123,39 @@ type Genre struct {
}
type Track struct {
ID string
CoverArtID string
ParentID string
Title string
Duration time.Duration
TrackNumber int
DiscNumber int
Genres []string
ArtistIDs []string
ArtistNames []string
ComposerIDs []string
ComposerNames []string
Album string
AlbumID string
Year int
Rating int
Favorite bool
Size int64
PlayCount int
LastPlayed time.Time
FilePath string
BitRate int
ContentType string
Comment string
BPM int
ReplayGain ReplayGainInfo
SampleRate int
BitDepth int
Channels int
DateAdded time.Time
ID string
CoverArtID string
ParentID string
Title string
Duration time.Duration
TrackNumber int
DiscNumber int
Genres []string
ArtistIDs []string
ArtistNames []string
AlbumArtistIDs []string
AlbumArtistNames []string
ComposerIDs []string
ComposerNames []string
Album string
AlbumID string
Year int
Rating int
Favorite bool
Size int64
PlayCount int
LastPlayed time.Time
FilePath string
BitRate int
ContentType string
Comment string
BPM int
ReplayGain ReplayGainInfo
SampleRate int
BitDepth int
Extension string
Channels int
DateAdded time.Time
}
type ReplayGainInfo struct {
@@ -544,6 +544,15 @@ func toTrack(ch *subsonic.Child) *mediaprovider.Track {
artistIDs = append(artistIDs, ch.ArtistID)
}
var albumArtistNames, albumArtistIDs []string
if len(ch.AlbumArtists) > 0 {
// OpenSubsonic extension
for _, a := range ch.AlbumArtists {
albumArtistIDs = append(albumArtistIDs, a.ID)
albumArtistNames = append(albumArtistNames, a.Name)
}
}
var rGain mediaprovider.ReplayGainInfo
if rg := ch.ReplayGain; rg != nil {
rGain.AlbumGain = rg.AlbumGain
@@ -570,36 +579,39 @@ func toTrack(ch *subsonic.Child) *mediaprovider.Track {
}
return &mediaprovider.Track{
ID: ch.ID,
CoverArtID: ch.CoverArt,
ParentID: ch.Parent,
Title: ch.Title,
Duration: time.Duration(ch.Duration) * time.Second,
TrackNumber: ch.Track,
DiscNumber: ch.DiscNumber,
Genres: genres,
ArtistIDs: artistIDs,
ArtistNames: artistNames,
ComposerIDs: composerIDs,
ComposerNames: composers,
Album: ch.Album,
AlbumID: ch.AlbumID,
Year: ch.Year,
Rating: ch.UserRating,
Favorite: !ch.Starred.IsZero(),
PlayCount: int(ch.PlayCount),
LastPlayed: ch.Played,
DateAdded: ch.Created,
FilePath: ch.Path,
Size: ch.Size,
BitRate: ch.BitRate,
ContentType: ch.ContentType,
Comment: ch.Comment,
BPM: ch.BPM,
ReplayGain: rGain,
SampleRate: ch.SamplingRate,
BitDepth: ch.BitDepth,
Channels: ch.ChannelCount,
ID: ch.ID,
CoverArtID: ch.CoverArt,
ParentID: ch.Parent,
Title: ch.Title,
Duration: time.Duration(ch.Duration) * time.Second,
TrackNumber: ch.Track,
DiscNumber: ch.DiscNumber,
Genres: genres,
ArtistIDs: artistIDs,
ArtistNames: artistNames,
AlbumArtistIDs: albumArtistIDs,
AlbumArtistNames: albumArtistNames,
ComposerIDs: composerIDs,
ComposerNames: composers,
Album: ch.Album,
AlbumID: ch.AlbumID,
Year: ch.Year,
Rating: ch.UserRating,
Favorite: !ch.Starred.IsZero(),
PlayCount: int(ch.PlayCount),
LastPlayed: ch.Played,
DateAdded: ch.Created,
FilePath: ch.Path,
Size: ch.Size,
BitRate: ch.BitRate,
ContentType: ch.ContentType,
Extension: ch.Suffix,
Comment: ch.Comment,
BPM: ch.BPM,
ReplayGain: rGain,
SampleRate: ch.SamplingRate,
BitDepth: ch.BitDepth,
Channels: ch.ChannelCount,
}
}