add more to track info dialog

This commit is contained in:
Drew Weymouth
2024-07-18 17:33:42 -07:00
parent 03ce1cc115
commit bf97cdb526
6 changed files with 76 additions and 10 deletions
+5 -1
View File
@@ -14,7 +14,11 @@ func GetSimilarSongsFallback(mp mediaprovider.MediaProvider, track *mediaprovide
tracks, _ = mp.GetSimilarTracks(track.ArtistIDs[0], count)
}
if len(tracks) == 0 {
tracks, _ = mp.GetRandomTracks(track.Genre, count)
genre := ""
if len(track.Genres) > 0 {
genre = track.Genres[0]
}
tracks, _ = mp.GetRandomTracks(genre, count)
}
// make sure to exclude the song itself from the similar list
+4 -1
View File
@@ -1,5 +1,7 @@
package mediaprovider
import "time"
// Bit field flag for the ReleaseTypes property
type ReleaseType = int32
@@ -90,7 +92,7 @@ type Track struct {
Duration int
TrackNumber int
DiscNumber int
Genre string
Genres []string
ArtistIDs []string
ArtistNames []string
Album string
@@ -100,6 +102,7 @@ type Track struct {
Favorite bool
Size int64
PlayCount int
LastPlayed time.Time
FilePath string
BitRate int
ContentType string
@@ -500,6 +500,15 @@ func toTrack(ch *subsonic.Child) *mediaprovider.Track {
rGain.AlbumPeak = rg.AlbumPeak
rGain.TrackPeak = rg.TrackPeak
}
var genres []string
if len(ch.Genres) > 0 {
genres = sharedutil.MapSlice(ch.Genres, func(idName subsonic.IDName) string {
return idName.Name
})
} else if ch.Genre != "" {
genres = []string{ch.Genre}
}
return &mediaprovider.Track{
ID: ch.ID,
CoverArtID: ch.CoverArt,
@@ -508,7 +517,7 @@ func toTrack(ch *subsonic.Child) *mediaprovider.Track {
Duration: ch.Duration,
TrackNumber: ch.Track,
DiscNumber: ch.DiscNumber,
Genre: ch.Genre,
Genres: genres,
ArtistIDs: artistIDs,
ArtistNames: artistNames,
Album: ch.Album,
@@ -517,12 +526,14 @@ func toTrack(ch *subsonic.Child) *mediaprovider.Track {
Rating: ch.UserRating,
Favorite: !ch.Starred.IsZero(),
PlayCount: int(ch.PlayCount),
LastPlayed: ch.Played,
FilePath: ch.Path,
Size: ch.Size,
BitRate: ch.BitRate,
ContentType: ch.ContentType,
Comment: ch.Comment,
BPM: ch.BPM,
ReplayGain: rGain,
}
}
+3 -5
View File
@@ -254,7 +254,7 @@ func (m *MPRISHandler) Metadata() (types.Metadata, error) {
var meta mediaprovider.MediaItemMetadata
// metadata that can come only from tracks
var discNumber, trackNumber, userRating, playCount, year int
var genre string
var genres []string
if np := m.pm.NowPlaying(); np != nil && status.State != player.Stopped {
meta = np.Metadata()
@@ -264,7 +264,7 @@ func (m *MPRISHandler) Metadata() (types.Metadata, error) {
userRating = track.Rating
playCount = track.PlayCount
year = track.Year
genre = track.Genre
genres = track.Genres
}
}
var artURL string
@@ -284,9 +284,7 @@ func (m *MPRISHandler) Metadata() (types.Metadata, error) {
UserRating: float64(userRating) / 5,
UseCount: playCount,
ArtUrl: artURL,
}
if genre != "" {
mprisMeta.Genre = []string{genre}
Genre: genres,
}
if year != 0 {
mprisMeta.ContentCreated = strconv.Itoa(year)