mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-21 17:40:28 +01:00
createPlaylist
This commit is contained in:
parent
5b2ecc39ca
commit
52850c6ef0
4 changed files with 48 additions and 2 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue