diff --git a/api/get_music_directory.go b/api/get_music_directory.go
index fc16d6fa0..3cddd9d32 100644
--- a/api/get_music_directory.go
+++ b/api/get_music_directory.go
@@ -6,6 +6,7 @@ import (
"github.com/deluan/gosonic/domain"
"github.com/deluan/gosonic/utils"
"github.com/karlkfi/inject"
+ "time"
)
type GetMusicDirectoryController struct {
@@ -54,6 +55,11 @@ func (c *GetMusicDirectoryController) buildArtistDir(a *domain.Artist, albums []
dir.Child[i].Artist = al.Artist
dir.Child[i].Genre = al.Genre
dir.Child[i].CoverArt = al.CoverArtId
+ if al.Starred {
+ t := time.Now()
+ dir.Child[i].Starred = &t
+ }
+
}
return dir
}
@@ -75,6 +81,9 @@ func (c *GetMusicDirectoryController) buildAlbumDir(al *domain.Album, tracks []d
dir.Child[i].Size = mf.Size
dir.Child[i].Suffix = mf.Suffix
dir.Child[i].BitRate = mf.BitRate
+ if mf.Starred {
+ dir.Child[i].Starred = &mf.UpdatedAt
+ }
if mf.HasCoverArt {
dir.Child[i].CoverArt = mf.Id
}
diff --git a/api/responses/responses.go b/api/responses/responses.go
index a0df4c91f..8ad60d5fc 100644
--- a/api/responses/responses.go
+++ b/api/responses/responses.go
@@ -1,6 +1,9 @@
package responses
-import "encoding/xml"
+import (
+ "encoding/xml"
+ "time"
+)
type Subsonic struct {
XMLName xml.Name `xml:"http://subsonic.org/restapi subsonic-response" json:"-"`
@@ -19,7 +22,7 @@ type JsonWrapper struct {
type Error struct {
Code int `xml:"code,attr" json:"code"`
- Message string `xml:"message,attr" json: "message"`
+ Message string `xml:"message,attr" json:"message"`
}
type License struct {
@@ -52,22 +55,23 @@ type Indexes struct {
}
type Child struct {
- Id string `xml:"id,attr" json:"id"`
- IsDir bool `xml:"isDir,attr" json:"isDir"`
- Title string `xml:"title,attr" json:"title"`
- Album string `xml:"album,attr,omitempty" json:"album,omitempty"`
- Artist string `xml:"artist,attr,omitempty" json:"artist,omitempty"`
- Track int `xml:"track,attr,omitempty" json:"track,omitempty"`
- Year int `xml:"year,attr,omitempty" json:"year,omitempty"`
- Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"`
- CoverArt string `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`
- Size string `xml:"size,attr,omitempty" json:"size,omitempty"`
- ContentType string `xml:"contentType,attr,omitempty" json:"contentType,omitempty"`
- Suffix string `xml:"suffix,attr,omitempty" json:"suffix,omitempty"`
- TranscodedContentType string `xml:"transcodedContentType,attr,omitempty" json:"transcodedContentType,omitempty"`
- TranscodedSuffix string `xml:"transcodedSuffix,attr,omitempty" json:"transcodedSuffix,omitempty"`
- Duration int `xml:"duration,attr,omitempty" json:"duration,omitempty"`
- BitRate int `xml:"bitRate,attr,omitempty" json:"bitRate,omitempty"`
+ Id string `xml:"id,attr" json:"id"`
+ IsDir bool `xml:"isDir,attr" json:"isDir"`
+ Title string `xml:"title,attr" json:"title"`
+ Album string `xml:"album,attr,omitempty" json:"album,omitempty"`
+ Artist string `xml:"artist,attr,omitempty" json:"artist,omitempty"`
+ Track int `xml:"track,attr,omitempty" json:"track,omitempty"`
+ Year int `xml:"year,attr,omitempty" json:"year,omitempty"`
+ Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"`
+ CoverArt string `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`
+ Size string `xml:"size,attr,omitempty" json:"size,omitempty"`
+ ContentType string `xml:"contentType,attr,omitempty" json:"contentType,omitempty"`
+ Suffix string `xml:"suffix,attr,omitempty" json:"suffix,omitempty"`
+ Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
+ TranscodedContentType string `xml:"transcodedContentType,attr,omitempty" json:"transcodedContentType,omitempty"`
+ TranscodedSuffix string `xml:"transcodedSuffix,attr,omitempty" json:"transcodedSuffix,omitempty"`
+ Duration int `xml:"duration,attr,omitempty" json:"duration,omitempty"`
+ BitRate int `xml:"bitRate,attr,omitempty" json:"bitRate,omitempty"`
}
type Directory struct {
diff --git a/api/responses/responses_test.go b/api/responses/responses_test.go
index a352630e4..1aa733c79 100644
--- a/api/responses/responses_test.go
+++ b/api/responses/responses_test.go
@@ -5,6 +5,7 @@ import (
. "github.com/deluan/gosonic/tests"
. "github.com/smartystreets/goconvey/convey"
"testing"
+ "time"
)
func TestSubsonicResponses(t *testing.T) {
@@ -106,18 +107,19 @@ func TestSubsonicResponses(t *testing.T) {
})
Convey("With all data", func() {
child := make([]Child, 1)
+ t := time.Date(2016, 03, 2, 20, 30, 0, 0, time.UTC)
child[0] = Child{
Id: "1", IsDir: true, Title: "title", Album: "album", Artist: "artist", Track: 1,
Year: 1985, Genre: "Rock", CoverArt: "1", Size: "8421341", ContentType: "audio/flac",
Suffix: "flac", TranscodedContentType: "audio/mpeg", TranscodedSuffix: "mp3",
- Duration: 146, BitRate: 320,
+ Duration: 146, BitRate: 320, Starred: &t,
}
response.Directory.Child = child
Convey("XML", func() {
- So(response, ShouldMatchXML, ``)
+ So(response, ShouldMatchXML, ``)
})
Convey("JSON", func() {
- So(response, ShouldMatchJSON, `{"directory":{"child":[{"album":"album","artist":"artist","bitRate":320,"contentType":"audio/flac","coverArt":"1","duration":146,"genre":"Rock","id":"1","isDir":true,"size":"8421341","suffix":"flac","title":"title","track":1,"transcodedContentType":"audio/mpeg","transcodedSuffix":"mp3","year":1985}],"id":"1","name":"N"},"status":"ok","version":"1.0.0"}`)
+ So(response, ShouldMatchJSON, `{"directory":{"child":[{"album":"album","artist":"artist","bitRate":320,"contentType":"audio/flac","coverArt":"1","duration":146,"genre":"Rock","id":"1","isDir":true,"size":"8421341","starred":"2016-03-02T20:30:00Z","suffix":"flac","title":"title","track":1,"transcodedContentType":"audio/mpeg","transcodedSuffix":"mp3","year":1985}],"id":"1","name":"N"},"status":"ok","version":"1.0.0"}`)
})
})
})
diff --git a/scanner/scanner.go b/scanner/scanner.go
index 883f682ca..39e208adb 100644
--- a/scanner/scanner.go
+++ b/scanner/scanner.go
@@ -112,7 +112,7 @@ func parseTrack(t *Track) (*domain.MediaFile, *domain.Album, *domain.Artist) {
Name: t.Album,
Year: t.Year,
Compilation: t.Compilation,
- Starred: t.Loved,
+ Starred: t.AlbumLoved,
Genre: t.Genre,
Artist: t.Artist,
AlbumArtist: t.AlbumArtist,