add 'New Playlist' button to Playlists page
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package jellyfin
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"image"
|
||||
"io"
|
||||
"math"
|
||||
@@ -77,7 +78,7 @@ func (j *jellyfinMediaProvider) SetLibrary(id string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (j *jellyfinMediaProvider) CreatePlaylist(name string, trackIDs []string) error {
|
||||
func (j *jellyfinMediaProvider) CreatePlaylistWithTracks(name string, trackIDs []string) error {
|
||||
return j.client.CreatePlaylist(name, trackIDs)
|
||||
}
|
||||
|
||||
@@ -93,6 +94,10 @@ func (j *jellyfinMediaProvider) EditPlaylist(id, name, description string, publi
|
||||
return j.client.UpdatePlaylistMetadata(id, name, description)
|
||||
}
|
||||
|
||||
func (j *jellyfinMediaProvider) CreatePlaylist(name, description string, public bool) error {
|
||||
return errors.New("unimplemented")
|
||||
}
|
||||
|
||||
func (j *jellyfinMediaProvider) AddPlaylistTracks(id string, trackIDsToAdd []string) error {
|
||||
return j.client.AddSongsToPlaylist(id, trackIDsToAdd)
|
||||
}
|
||||
|
||||
@@ -256,10 +256,12 @@ type MediaProvider interface {
|
||||
|
||||
GetPlaylists() ([]*Playlist, error)
|
||||
|
||||
CreatePlaylist(name string, trackIDs []string) error
|
||||
CreatePlaylistWithTracks(name string, trackIDs []string) error
|
||||
|
||||
CanMakePublicPlaylist() bool
|
||||
|
||||
CreatePlaylist(name, description string, public bool) error
|
||||
|
||||
EditPlaylist(id, name, description string, public bool) error
|
||||
|
||||
AddPlaylistTracks(id string, trackIDsToAdd []string) error
|
||||
|
||||
@@ -62,11 +62,32 @@ func (s *subsonicMediaProvider) SetLibrary(id string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *subsonicMediaProvider) CreatePlaylist(name string, trackIDs []string) error {
|
||||
func (s *subsonicMediaProvider) CreatePlaylistWithTracks(name string, trackIDs []string) error {
|
||||
s.playlistsCached = nil
|
||||
return s.client.CreatePlaylistWithTracks(trackIDs, map[string]string{"name": name})
|
||||
}
|
||||
|
||||
func (s *subsonicMediaProvider) CreatePlaylist(name, description string, public bool) error {
|
||||
pl, err := s.client.CreatePlaylist(map[string]string{"name": name})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if pl == nil || (description == "" && !public) {
|
||||
// Subsonic <= 1.14.0 doesn't return a playlist
|
||||
// Not having the ID, we can't set the description or public property
|
||||
return nil
|
||||
}
|
||||
|
||||
params := make(map[string]string)
|
||||
if description != "" {
|
||||
params["description"] = description
|
||||
}
|
||||
if public {
|
||||
params["public"] = "true"
|
||||
}
|
||||
return s.client.UpdatePlaylist(pl.ID, params)
|
||||
}
|
||||
|
||||
func (s *subsonicMediaProvider) DeletePlaylist(id string) error {
|
||||
s.playlistsCached = nil
|
||||
return s.client.DeletePlaylist(id)
|
||||
|
||||
Reference in New Issue
Block a user