createPlaylist
This commit is contained in:
+17
-2
@@ -1,19 +1,25 @@
|
||||
package engine
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/deluan/gosonic/domain"
|
||||
"github.com/deluan/gosonic/itunesbridge"
|
||||
)
|
||||
|
||||
type Playlists interface {
|
||||
GetAll() (domain.Playlists, error)
|
||||
Get(id string) (*PlaylistInfo, error)
|
||||
Create(name string, ids []string) error
|
||||
}
|
||||
|
||||
func NewPlaylists(pr domain.PlaylistRepository, mr domain.MediaFileRepository) Playlists {
|
||||
return &playlists{pr, mr}
|
||||
func NewPlaylists(itunes itunesbridge.ItunesControl, pr domain.PlaylistRepository, mr domain.MediaFileRepository) Playlists {
|
||||
return &playlists{itunes, pr, mr}
|
||||
}
|
||||
|
||||
type playlists struct {
|
||||
itunes itunesbridge.ItunesControl
|
||||
plsRepo domain.PlaylistRepository
|
||||
mfileRepo domain.MediaFileRepository
|
||||
}
|
||||
@@ -32,6 +38,15 @@ type PlaylistInfo struct {
|
||||
Owner string
|
||||
}
|
||||
|
||||
func (p *playlists) Create(name string, ids []string) error {
|
||||
pid, err := p.itunes.CreatePlaylist(name, ids)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
beego.Info(fmt.Sprintf("Created playlist '%s' with id '%s'", name, pid))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *playlists) Get(id string) (*PlaylistInfo, error) {
|
||||
pl, err := p.plsRepo.Get(id)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user