From 81dee3b425e2151a0d53b7a2a256181685ca2487 Mon Sep 17 00:00:00 2001 From: Doychin Atanasov Date: Fri, 17 May 2024 21:37:40 +0300 Subject: [PATCH] Encode empty year as zero Some players (Amperfy) fail when the year is not present in the response. --- src/webserver/subsonic/get_music_directory.go | 1 + src/webserver/subsonic/xsd_types.go | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/webserver/subsonic/get_music_directory.go b/src/webserver/subsonic/get_music_directory.go index a57beba..df23847 100644 --- a/src/webserver/subsonic/get_music_directory.go +++ b/src/webserver/subsonic/get_music_directory.go @@ -159,6 +159,7 @@ func (s *subsonic) getRootDirectory( xsdChild{ ID: artistFSID(artist.ID), ParentID: combinedMusicFolderID, + CoverArtID: artistCoverArtID(artist.ID), Name: artist.Name, Artist: artist.Name, Title: artist.Name, diff --git a/src/webserver/subsonic/xsd_types.go b/src/webserver/subsonic/xsd_types.go index cf44d9f..7f64fc2 100644 --- a/src/webserver/subsonic/xsd_types.go +++ b/src/webserver/subsonic/xsd_types.go @@ -59,14 +59,14 @@ type xsdChild struct { CoverArtID string `xml:"coverArt,attr,omitempty" json:"coverArt"` Track int64 `xml:"track,attr,omitempty" json:"track,omitempty"` // position in album, I suppose Duration int64 `xml:"duration,attr,omitempty" json:"duration,omitempty"` // in seconds - Year int16 `xml:"year,attr,omitempty" json:"year,omitempty"` + Year int16 `xml:"year,attr" json:"year"` Genre string `xml:"genre,attr,omitempty" json:"gener,omitempty"` Size int64 `xml:"size,attr,omitempty" json:"size,omitempty"` // in bytes ContentType string `xml:"contentType,attr,omitempty" json:"contentType,omitempty"` PlayCount int64 `xml:"playCount,attr,omitempty" json:"playCount,omitempty"` UserRating uint8 `xml:"userRating,attr,omitempty" json:"userRating,omitempty"` Suffix string `xml:"suffix,attr,omitempty" json:"suffix,omitempty"` - BitRate string `xml:"bitRate,attr,omitempty" json:"bitRate,omitempty"` + BitRate int `xml:"bitRate,attr,omitempty" json:"bitRate,omitempty"` Path string `xml:"path,attr,omitempty" json:"path,omitempty"` // on the file system I suppose Created time.Time `xml:"created,attr,omitempty" json:"created,omitempty"` Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"` @@ -178,7 +178,7 @@ type xsdAlbumID3 struct { PlayCount int64 `xml:"playCount,attr,omitempty" json:"playCount,omitempty"` Created time.Time `xml:"created,attr" json:"created"` Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"` - Year int16 `xml:"year,attr,omitempty" json:"year,omitempty"` + Year int16 `xml:"year,attr" json:"year"` Genre string `xml:"genre,attr,omitempty" json:"gener,omitempty"` }