More metadata for directories (albums)
This commit is contained in:
+9
-1
@@ -83,7 +83,15 @@ func (c *BrowsingController) GetDirectory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *BrowsingController) buildDirectory(d *engine.DirectoryInfo) *responses.Directory {
|
func (c *BrowsingController) buildDirectory(d *engine.DirectoryInfo) *responses.Directory {
|
||||||
dir := &responses.Directory{Id: d.Id, Name: d.Name}
|
dir := &responses.Directory{
|
||||||
|
Id: d.Id,
|
||||||
|
Name: d.Name,
|
||||||
|
Parent: d.Parent,
|
||||||
|
PlayCount: d.PlayCount,
|
||||||
|
}
|
||||||
|
if !d.Starred.IsZero() {
|
||||||
|
dir.Starred = &d.Starred
|
||||||
|
}
|
||||||
|
|
||||||
dir.Child = make([]responses.Child, len(d.Entries))
|
dir.Child = make([]responses.Child, len(d.Entries))
|
||||||
for i, entry := range d.Entries {
|
for i, entry := range d.Entries {
|
||||||
|
|||||||
@@ -104,15 +104,15 @@ type Child struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Directory struct {
|
type Directory struct {
|
||||||
Child []Child `xml:"child" json:"child,omitempty"`
|
Child []Child `xml:"child" json:"child,omitempty"`
|
||||||
Id string `xml:"id,attr" json:"id"`
|
Id string `xml:"id,attr" json:"id"`
|
||||||
Name string `xml:"name,attr" json:"name"`
|
Name string `xml:"name,attr" json:"name"`
|
||||||
|
Parent string `xml:"parent,attr,omitempty" json:"parent,omitempty"`
|
||||||
|
Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
|
||||||
|
PlayCount int32 `xml:"playCount,attr,omitempty" json:"playcount,omitempty"`
|
||||||
/*
|
/*
|
||||||
<xs:attribute name="parent" type="xs:string" use="optional"/>
|
|
||||||
<xs:attribute name="starred" type="xs:dateTime" use="optional"/> <!-- Added in 1.10.1 -->
|
|
||||||
<xs:attribute name="userRating" type="sub:UserRating" use="optional"/> <!-- Added in 1.13.0 -->
|
<xs:attribute name="userRating" type="sub:UserRating" use="optional"/> <!-- Added in 1.13.0 -->
|
||||||
<xs:attribute name="averageRating" type="sub:AverageRating" use="optional"/> <!-- Added in 1.13.0 -->
|
<xs:attribute name="averageRating" type="sub:AverageRating" use="optional"/> <!-- Added in 1.13.0 -->
|
||||||
<xs:attribute name="playCount" type="xs:long" use="optional"/> <!-- Added in 1.14.0 -->
|
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+16
-4
@@ -54,9 +54,12 @@ func (b browser) Indexes(ifModifiedSince time.Time) (domain.ArtistIndexes, time.
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DirectoryInfo struct {
|
type DirectoryInfo struct {
|
||||||
Id string
|
Id string
|
||||||
Name string
|
Name string
|
||||||
Entries Entries
|
Entries Entries
|
||||||
|
Parent string
|
||||||
|
Starred time.Time
|
||||||
|
PlayCount int32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c browser) Directory(id string) (*DirectoryInfo, error) {
|
func (c browser) Directory(id string) (*DirectoryInfo, error) {
|
||||||
@@ -90,12 +93,21 @@ func (c browser) buildArtistDir(a *domain.Artist, albums domain.Albums) *Directo
|
|||||||
dir.Entries = make(Entries, len(albums))
|
dir.Entries = make(Entries, len(albums))
|
||||||
for i, al := range albums {
|
for i, al := range albums {
|
||||||
dir.Entries[i] = FromAlbum(&al)
|
dir.Entries[i] = FromAlbum(&al)
|
||||||
|
dir.PlayCount += int32(al.PlayCount)
|
||||||
}
|
}
|
||||||
return dir
|
return dir
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c browser) buildAlbumDir(al *domain.Album, tracks domain.MediaFiles) *DirectoryInfo {
|
func (c browser) buildAlbumDir(al *domain.Album, tracks domain.MediaFiles) *DirectoryInfo {
|
||||||
dir := &DirectoryInfo{Id: al.Id, Name: al.Name}
|
dir := &DirectoryInfo{
|
||||||
|
Id: al.Id,
|
||||||
|
Name: al.Name,
|
||||||
|
Parent: al.ArtistId,
|
||||||
|
PlayCount: int32(al.PlayCount),
|
||||||
|
}
|
||||||
|
if al.Starred {
|
||||||
|
dir.Starred = al.UpdatedAt
|
||||||
|
}
|
||||||
|
|
||||||
dir.Entries = make(Entries, len(tracks))
|
dir.Entries = make(Entries, len(tracks))
|
||||||
for i, mf := range tracks {
|
for i, mf := range tracks {
|
||||||
|
|||||||
Reference in New Issue
Block a user