Even more metadata for playlists
This commit is contained in:
+12
-5
@@ -23,11 +23,14 @@ func (c *PlaylistsController) GetAll() {
|
|||||||
c.SendError(responses.ERROR_GENERIC, "Internal error")
|
c.SendError(responses.ERROR_GENERIC, "Internal error")
|
||||||
}
|
}
|
||||||
playlists := make([]responses.Playlist, len(allPls))
|
playlists := make([]responses.Playlist, len(allPls))
|
||||||
for i, f := range allPls {
|
for i, p := range allPls {
|
||||||
playlists[i].Id = f.Id
|
playlists[i].Id = p.Id
|
||||||
playlists[i].Name = f.Name
|
playlists[i].Name = p.Name
|
||||||
playlists[i].Comment = "Original: " + f.FullPath
|
playlists[i].Comment = "Original: " + p.FullPath
|
||||||
playlists[i].SongCount = len(f.Tracks)
|
playlists[i].SongCount = len(p.Tracks)
|
||||||
|
playlists[i].Duration = p.Duration
|
||||||
|
playlists[i].Owner = p.Owner
|
||||||
|
playlists[i].Public = p.Public
|
||||||
}
|
}
|
||||||
response := c.NewEmpty()
|
response := c.NewEmpty()
|
||||||
response.Playlists = &responses.Playlists{Playlist: playlists}
|
response.Playlists = &responses.Playlists{Playlist: playlists}
|
||||||
@@ -56,6 +59,10 @@ func (c *PlaylistsController) buildPlaylist(d *engine.PlaylistInfo) *responses.P
|
|||||||
pls := &responses.PlaylistWithSongs{}
|
pls := &responses.PlaylistWithSongs{}
|
||||||
pls.Id = d.Id
|
pls.Id = d.Id
|
||||||
pls.Name = d.Name
|
pls.Name = d.Name
|
||||||
|
pls.SongCount = d.SongCount
|
||||||
|
pls.Owner = d.Owner
|
||||||
|
pls.Duration = d.Duration
|
||||||
|
pls.Public = d.Public
|
||||||
|
|
||||||
pls.Entry = c.ToChildren(d.Entries)
|
pls.Entry = c.ToChildren(d.Entries)
|
||||||
return pls
|
return pls
|
||||||
|
|||||||
@@ -124,15 +124,14 @@ type Playlist struct {
|
|||||||
Name string `xml:"name,attr" json:"name"`
|
Name string `xml:"name,attr" json:"name"`
|
||||||
Comment string `xml:"comment,attr,omitempty" json:"comment,omitempty"`
|
Comment string `xml:"comment,attr,omitempty" json:"comment,omitempty"`
|
||||||
SongCount int `xml:"songCount,attr,omitempty" json:"songCount,omitempty"`
|
SongCount int `xml:"songCount,attr,omitempty" json:"songCount,omitempty"`
|
||||||
|
Duration int `xml:"duration,attr,omitempty" json:"duration,omitempty"`
|
||||||
|
Public bool `xml:"public,attr,omitempty" json:"public,omitempty"`
|
||||||
|
Owner string `xml:"owner,attr,omitempty" json:"owner,omitempty"`
|
||||||
/*
|
/*
|
||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
<xs:element name="allowedUser" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> <!--Added in 1.8.0-->
|
<xs:element name="allowedUser" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> <!--Added in 1.8.0-->
|
||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
<xs:attribute name="comment" type="xs:string" use="optional"/> <!--Added in 1.8.0-->
|
<xs:attribute name="comment" type="xs:string" use="optional"/> <!--Added in 1.8.0-->
|
||||||
<xs:attribute name="owner" type="xs:string" use="optional"/> <!--Added in 1.8.0-->
|
|
||||||
<xs:attribute name="public" type="xs:boolean" use="optional"/> <!--Added in 1.8.0-->
|
|
||||||
<xs:attribute name="songCount" type="xs:int" use="required"/> <!--Added in 1.8.0-->
|
|
||||||
<xs:attribute name="duration" type="xs:int" use="required"/> <!--Added in 1.8.0-->
|
|
||||||
<xs:attribute name="created" type="xs:dateTime" use="required"/> <!--Added in 1.8.0-->
|
<xs:attribute name="created" type="xs:dateTime" use="required"/> <!--Added in 1.8.0-->
|
||||||
<xs:attribute name="changed" type="xs:dateTime" use="required"/> <!--Added in 1.13.0-->
|
<xs:attribute name="changed" type="xs:dateTime" use="required"/> <!--Added in 1.13.0-->
|
||||||
<xs:attribute name="coverArt" type="xs:string" use="optional"/> <!--Added in 1.11.0-->
|
<xs:attribute name="coverArt" type="xs:string" use="optional"/> <!--Added in 1.11.0-->
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ type Playlist struct {
|
|||||||
Id string
|
Id string
|
||||||
Name string
|
Name string
|
||||||
FullPath string
|
FullPath string
|
||||||
|
Duration int
|
||||||
|
Owner string
|
||||||
|
Public bool
|
||||||
Tracks []string
|
Tracks []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-1
@@ -26,6 +26,10 @@ type PlaylistInfo struct {
|
|||||||
Id string
|
Id string
|
||||||
Name string
|
Name string
|
||||||
Entries Entries
|
Entries Entries
|
||||||
|
SongCount int
|
||||||
|
Duration int
|
||||||
|
Public bool
|
||||||
|
Owner string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p playlists) Get(id string) (*PlaylistInfo, error) {
|
func (p playlists) Get(id string) (*PlaylistInfo, error) {
|
||||||
@@ -37,7 +41,14 @@ func (p playlists) Get(id string) (*PlaylistInfo, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
pinfo := &PlaylistInfo{Id: pl.Id, Name: pl.Name}
|
pinfo := &PlaylistInfo{
|
||||||
|
Id: pl.Id,
|
||||||
|
Name: pl.Name,
|
||||||
|
SongCount: len(pl.Tracks),
|
||||||
|
Duration: pl.Duration,
|
||||||
|
Public: pl.Public,
|
||||||
|
Owner: pl.Owner,
|
||||||
|
}
|
||||||
pinfo.Entries = make(Entries, len(pl.Tracks))
|
pinfo.Entries = make(Entries, len(pl.Tracks))
|
||||||
|
|
||||||
// TODO Optimize: Get all tracks at once
|
// TODO Optimize: Get all tracks at once
|
||||||
|
|||||||
@@ -199,6 +199,8 @@ func (i *Importer) importLibrary() (err error) {
|
|||||||
|
|
||||||
j = 0
|
j = 0
|
||||||
for _, pl := range i.scanner.Playlists() {
|
for _, pl := range i.scanner.Playlists() {
|
||||||
|
pl.Public = true
|
||||||
|
pl.Owner = beego.AppConfig.String("user")
|
||||||
pls[j] = *pl
|
pls[j] = *pl
|
||||||
j++
|
j++
|
||||||
if err := i.plsRepo.Put(pl); err != nil {
|
if err := i.plsRepo.Put(pl); err != nil {
|
||||||
|
|||||||
@@ -150,8 +150,9 @@ func (s *ItunesScanner) collectPlaylists(p *itl.Playlist, fullPath string) {
|
|||||||
pl.Tracks = make([]string, 0, len(p.PlaylistItems))
|
pl.Tracks = make([]string, 0, len(p.PlaylistItems))
|
||||||
for _, item := range p.PlaylistItems {
|
for _, item := range p.PlaylistItems {
|
||||||
id := strconv.Itoa(item.TrackID)
|
id := strconv.Itoa(item.TrackID)
|
||||||
if _, found := s.mediaFiles[id]; found {
|
if mf, found := s.mediaFiles[id]; found {
|
||||||
pl.Tracks = append(pl.Tracks, id)
|
pl.Tracks = append(pl.Tracks, id)
|
||||||
|
pl.Duration += mf.Duration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(pl.Tracks) > 0 {
|
if len(pl.Tracks) > 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user