Queue songs in playlist view

This commit is contained in:
aditya-K2
2023-12-17 13:58:34 +05:30
parent f5aa878e41
commit 000e9e4a43
3 changed files with 17 additions and 0 deletions

View File

@@ -61,6 +61,7 @@ var (
"playlist_view": {
"normal": {
{R: 'a'}: "add_to_playlist",
{R: 'q'}: "queue_entry",
},
"visual": {
{R: 'a'}: "add_to_playlist",

View File

@@ -297,6 +297,10 @@ func NewApplication() *tview.Application {
playlistView.AddToPlaylist()
return nil
}, nil),
"queue_entry": NewAction(func(e *tcell.EventKey) *tcell.EventKey {
playlistView.QueueEntry()
return nil
}, nil),
}))
recentlyPlayedView.SetActions(utils.MergeMaps(globalActions, map[string]*Action{
"add_to_playlist": NewAction(func(e *tcell.EventKey) *tcell.EventKey {

View File

@@ -1,6 +1,8 @@
package ui
import (
"fmt"
"github.com/aditya-K2/gspt/spt"
"github.com/gdamore/tcell/v2"
"github.com/zmb3/spotify/v2"
@@ -77,4 +79,14 @@ func (p *PlaylistView) OpenEntry() {
}
}
func (p *PlaylistView) QueueEntry() {
r, _ := Main.GetSelection()
track := (*(*p.currentUserFullPlaylist).Tracks)[r].Track
msg := fmt.Sprintf("%s Queued Succesfully!", track.Name)
if err := spt.QueueTracks(track.ID); err != nil {
msg = err.Error()
}
SendNotification(msg)
}
func (p *PlaylistView) Name() string { return "PlaylistView" }