queue tracks, view queue, queue updates when open, hotkey clean up
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
6ed3453dae
commit
b5f76fb321
2
main.go
2
main.go
@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.asdf.cafe/abs3nt/gospt/src/cmd"
|
"git.asdf.cafe/abs3nt/gospt/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -99,6 +99,13 @@ func HandleSkipWithinContext(ctx *gctx.Context, commands *commands.Commands, amt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func HandleQueueItem(ctx *gctx.Context, commands *commands.Commands, item spotify.ID) {
|
||||||
|
err := commands.QueueSong(ctx, item)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func HandleSetDevice(ctx *gctx.Context, commands *commands.Commands, player spotify.PlayerDevice) {
|
func HandleSetDevice(ctx *gctx.Context, commands *commands.Commands, player spotify.PlayerDevice) {
|
||||||
err := commands.SetDevice(ctx, player)
|
err := commands.SetDevice(ctx, player)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -242,6 +242,35 @@ func (m *mainModel) CopyToClipboard() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *mainModel) QueueItem() error {
|
||||||
|
switch item := m.list.SelectedItem().(mainItem).SpotifyItem.(type) {
|
||||||
|
case spotify.PlaylistTrack:
|
||||||
|
go HandleQueueItem(m.ctx, m.commands, item.Track.ID)
|
||||||
|
case spotify.SavedTrack:
|
||||||
|
go HandleQueueItem(m.ctx, m.commands, item.ID)
|
||||||
|
case spotify.SimpleTrack:
|
||||||
|
go HandleQueueItem(m.ctx, m.commands, item.ID)
|
||||||
|
case spotify.FullTrack:
|
||||||
|
go HandleQueueItem(m.ctx, m.commands, item.ID)
|
||||||
|
case *spotify.FullTrack:
|
||||||
|
go HandleQueueItem(m.ctx, m.commands, item.ID)
|
||||||
|
case *spotify.SimpleTrack:
|
||||||
|
go HandleQueueItem(m.ctx, m.commands, item.ID)
|
||||||
|
case *spotify.SimplePlaylist:
|
||||||
|
go HandleQueueItem(m.ctx, m.commands, item.ID)
|
||||||
|
}
|
||||||
|
if m.mode == Queue {
|
||||||
|
go func() {
|
||||||
|
new_items, err := QueueView(m.ctx, m.commands)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m.list.SetItems(new_items)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (m *mainModel) SelectItem() error {
|
func (m *mainModel) SelectItem() error {
|
||||||
switch m.mode {
|
switch m.mode {
|
||||||
case Queue:
|
case Queue:
|
||||||
@ -630,9 +659,14 @@ func (m *mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
m.list.ResetSelected()
|
m.list.ResetSelected()
|
||||||
return m, msg
|
return m, msg
|
||||||
}
|
}
|
||||||
|
if msg.String() == "ctrl+@" || msg.String() == "ctrl+p" {
|
||||||
|
err := m.QueueItem()
|
||||||
|
if err != nil {
|
||||||
|
return m, tea.Quit
|
||||||
|
}
|
||||||
|
}
|
||||||
// select item
|
// select item
|
||||||
if msg.String() == "enter" || msg.String() == "spacebar" {
|
if msg.String() == "enter" || msg.String() == " " || msg.String() == "p" {
|
||||||
err := m.SelectItem()
|
err := m.SelectItem()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return m, tea.Quit
|
return m, tea.Quit
|
||||||
@ -697,27 +731,29 @@ func InitMain(ctx *gctx.Context, c *commands.Commands, mode Mode) (tea.Model, er
|
|||||||
go m.TickPlayback()
|
go m.TickPlayback()
|
||||||
Tick()
|
Tick()
|
||||||
m.list.DisableQuitKeybindings()
|
m.list.DisableQuitKeybindings()
|
||||||
|
m.list.SetFilteringEnabled(false)
|
||||||
m.list.AdditionalShortHelpKeys = func() []key.Binding {
|
m.list.AdditionalShortHelpKeys = func() []key.Binding {
|
||||||
return []key.Binding{
|
return []key.Binding{
|
||||||
key.NewBinding(key.WithKeys("esc"), key.WithHelp("esc", "back")),
|
key.NewBinding(key.WithKeys("q"), key.WithHelp("q", "back")),
|
||||||
key.NewBinding(key.WithKeys("s"), key.WithHelp("s", "search")),
|
key.NewBinding(key.WithKeys("enter"), key.WithHelp("enter", "select")),
|
||||||
key.NewBinding(key.WithKeys("ctrl+c"), key.WithHelp("ctrl+c", "quit")),
|
key.NewBinding(key.WithKeys("/"), key.WithHelp("/", "search")),
|
||||||
key.NewBinding(key.WithKeys("ctrl"+"r"), key.WithHelp("ctrl+r", "start radio")),
|
key.NewBinding(key.WithKeys("ctrl"+"r"), key.WithHelp("ctrl+r", "radio")),
|
||||||
key.NewBinding(key.WithKeys("ctrl"+"shift"+"c"), key.WithHelp("ctrl+shift+c", "copy url")),
|
key.NewBinding(key.WithKeys("ctrl"+"p"), key.WithHelp("ctrl+p", "queue")),
|
||||||
key.NewBinding(key.WithKeys("d"), key.WithHelp("d", "select device")),
|
key.NewBinding(key.WithKeys("d"), key.WithHelp("d", "select device")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.list.AdditionalFullHelpKeys = func() []key.Binding {
|
m.list.AdditionalFullHelpKeys = func() []key.Binding {
|
||||||
return []key.Binding{
|
return []key.Binding{
|
||||||
key.NewBinding(key.WithKeys("esc"), key.WithHelp("esc", "back")),
|
key.NewBinding(key.WithKeys("esc"), key.WithHelp("esc", "back")),
|
||||||
key.NewBinding(key.WithKeys("s"), key.WithHelp("s", "search")),
|
key.NewBinding(key.WithKeys("enter"), key.WithHelp("enter", "select")),
|
||||||
|
key.NewBinding(key.WithKeys("/"), key.WithHelp("/", "search")),
|
||||||
key.NewBinding(key.WithKeys(">"), key.WithHelp(">", "seek forward")),
|
key.NewBinding(key.WithKeys(">"), key.WithHelp(">", "seek forward")),
|
||||||
key.NewBinding(key.WithKeys("<"), key.WithHelp("<", "seek backward")),
|
key.NewBinding(key.WithKeys("<"), key.WithHelp("<", "seek backward")),
|
||||||
key.NewBinding(key.WithKeys("+"), key.WithHelp("+", "volume up")),
|
key.NewBinding(key.WithKeys("+"), key.WithHelp("+", "volume up")),
|
||||||
key.NewBinding(key.WithKeys("-"), key.WithHelp("-", "volume down")),
|
key.NewBinding(key.WithKeys("-"), key.WithHelp("-", "volume down")),
|
||||||
key.NewBinding(key.WithKeys("ctrl+c"), key.WithHelp("ctrl+c", "quit")),
|
key.NewBinding(key.WithKeys("ctrl+c"), key.WithHelp("ctrl+c", "quit")),
|
||||||
key.NewBinding(key.WithKeys("ctrl"+"r"), key.WithHelp("ctrl+r", "start radio")),
|
key.NewBinding(key.WithKeys("ctrl"+"r"), key.WithHelp("ctrl+r", "start radio")),
|
||||||
key.NewBinding(key.WithKeys("ctrl"+"shift"+"c"), key.WithHelp("ctrl+shift+c", "copy url")),
|
key.NewBinding(key.WithKeys("ctrl"+"p"), key.WithHelp("ctrl+p", "queue song")),
|
||||||
key.NewBinding(key.WithKeys("d"), key.WithHelp("d", "select device")),
|
key.NewBinding(key.WithKeys("d"), key.WithHelp("d", "select device")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user